Chameleon

Chameleon Commit Details

Date:2015-04-28 01:31:20 (4 years 3 months ago)
Author:ErmaC
Commit:2662
Parents: 2661
Message:Move hex2bin fund to better location.
Changes:
M/trunk/i386/boot2/drivers.c
M/trunk/i386/libsaio/gma.c
M/trunk/i386/libsaio/convert.h
M/trunk/i386/boot2/boot.c
M/trunk/i386/boot2/gui.c
M/trunk/i386/libsaio/fake_efi.c
M/trunk/i386/libsaio/nvidia.c
M/trunk/i386/libsaio/device_inject.c
M/trunk/i386/libsaio/hda.c
M/trunk/i386/libsaio/ati.c
M/trunk/i386/libsaio/convert.c
M/trunk/i386/libsaio/device_inject.h

File differences

trunk/i386/libsaio/gma.c
3939
4040
4141
42
4243
4344
4445
4546
4647
47
48
4849
4950
5051
51
52
5253
5354
5455
55
56
5657
57
58
5859
5960
6061
......
6465
6566
6667
67
68
6869
6970
7071
......
843844
844845
845846
846
847
847848
848849
849850
#include "pci.h"
#include "platform.h"
#include "device_inject.h"
#include "convert.h"
#include "gma.h"
#include "vbe.h"
#include "graphics.h"
#ifndef DEBUG_GMA
#define DEBUG_GMA 0
#define DEBUG_GMA 0
#endif
#ifndef DEBUG_BDW
#define DEBUG_BDW 1
#define DEBUG_BDW 1
#endif
#if DEBUG_GMA
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#define DBG(x...)
#endif
static booldoit= false;
#define AAPL_LEN_HSW ( sizeof(default_aapl_haswell) / sizeof(uint8_t) )
#if DEBUG_BDW
static uint8_t default_aapl_broadwell[]={ 0x00,0x00,0x1e,0x16 }; // broadwell_ig_vals[3]
static uint8_t default_aapl_broadwell[]={ 0x00,0x00,0x1e,0x16 }; // broadwell_ig_vals[2]
#define AAPL_LEN_BDW ( sizeof(default_aapl_broadwell) / sizeof(uint8_t) )
#endif
}
else
{
uint32_t ig_platform_id = 0x161e0000; // set the default platform ig
uint32_t ig_platform_id = 0x16160000; // set the default platform ig
devprop_add_value(device, "AAPL,ig-platform-id", (uint8_t *)&ig_platform_id, 4);
}
trunk/i386/libsaio/device_inject.c
1414
1515
1616
17
17
1818
1919
2020
21
21
2222
23
23
2424
2525
2626
......
400400
401401
402402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439403
440404
441405
#include "convert.h"
#ifndef DEBUG_INJECT
#define DEBUG_INJECT 0
#define DEBUG_INJECT 0
#endif
#if DEBUG_INJECT
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#define DBG(x...)msglog(x)
#endif
uint32_tdevices_number= 1;
/* ======================================================= */
/*******************************************************************
* Decodes a sequence of 'len' hexadecimal chars from 'hex' into *
* a binary. returns -1 in case of error (i.e. badly formed chars) *
*******************************************************************/
int hex2bin( const char *hex, uint8_t *bin, int len )
{
char*p;
inti;
charbuf[3];
if (hex == NULL || bin == NULL || len <= 0 || strlen(hex) != len * 2)
{
printf("[ERROR] bin2hex input error\n");
return -1;
}
buf[2] = '\0';
p = (char *) hex;
for (i = 0; i < len; i++)
{
if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1]))
{
printf("[ERROR] bin2hex '%s' syntax error\n", hex);
return -2;
}
buf[0] = *p++;
buf[1] = *p++;
bin[i] = (unsigned char) strtoul(buf, NULL, 16);
}
return 0;
}
/* ======================================================= */
/* a fine place for this code */
int devprop_add_network_template(DevPropDevice *device, uint16_t vendor_id)
trunk/i386/libsaio/hda.c
6666
6767
6868
69
6970
7071
7172
7273
73
74
7475
7576
7677
77
78
7879
79
80
8081
8182
8283
#include "pci_root.h"
#include "platform.h"
#include "device_inject.h"
#include "convert.h"
#include "hda.h"
//#include "aml_generator.h"
#ifndef DEBUG_HDA
#define DEBUG_HDA 0
#define DEBUG_HDA 0
#endif
#if DEBUG_HDA
#define DBG(x...) verbose(x)
#define DBG(x...) verbose(x)
#else
#define DBG(x...)
#define DBG(x...)
#endif
extern uint32_t devices_number;
trunk/i386/libsaio/device_inject.h
7979
8080
8181
82
8382
8483
voiddevprop_free_string(DevPropString *string);
intdevprop_add_network_template(DevPropDevice *device, uint16_t vendor_id);
inthex2bin(const char *hex, uint8_t *bin, int len);
#endif /* !__LIBSAIO_DEVICE_INJECT_H */
trunk/i386/libsaio/nvidia.c
5252
5353
5454
55
5556
5657
5758
5859
59
60
6061
6162
6263
63
64
6465
65
66
6667
6768
6869
......
9394
9495
9596
96
97
97
98
9899
99100
100101
#include "pci.h"
#include "platform.h"
#include "device_inject.h"
#include "convert.h"
#include "nvidia.h"
#include "nvidia_helper.h"
#ifndef DEBUG_NVIDIA
#define DEBUG_NVIDIA 0
#define DEBUG_NVIDIA 0
#endif
#if DEBUG_NVIDIA
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#define DBG(x...)
#endif
#define NVIDIA_ROM_SIZE0x20000
const char *nvidia_slot_name[] ={ "AAPL,slot-name", "Slot-1" };
static uint8_t default_NVCAP[]= {
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x00
};
trunk/i386/libsaio/ati.c
77
88
99
10
10
1111
1212
1313
14
14
1515
16
16
1717
1818
1919
#include "ati.h"
#ifndef DEBUG_ATI
#define DEBUG_ATI 0
#define DEBUG_ATI 0
#endif
#if DEBUG_ATI
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#define DBG(x...)msglog(x)
#endif
/* vals */
trunk/i386/libsaio/convert.c
163163
164164
165165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
166199
167200
168201
/* ======================================================= */
/*******************************************************************
* Decodes a sequence of 'len' hexadecimal chars from 'hex' into *
* a binary. returns -1 in case of error (i.e. badly formed chars) *
*******************************************************************/
int hex2bin( const char *hex, uint8_t *bin, int len )
{
char*p;
inti;
charbuf[3];
if (hex == NULL || bin == NULL || len <= 0 || strlen(hex) != len * 2)
{
printf("[ERROR] bin2hex input error\n");
return -1;
}
buf[2] = '\0';
p = (char *) hex;
for (i = 0; i < len; i++)
{
if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1]))
{
printf("[ERROR] bin2hex '%s' syntax error\n", hex);
return -2;
}
buf[0] = *p++;
buf[1] = *p++;
bin[i] = (unsigned char) strtoul(buf, NULL, 16);
}
return 0;
}
/* ======================================================= */
// FIXME: can't use my original code here,
trunk/i386/libsaio/convert.h
1515
1616
1717
18
1819
1920
2021
EFI_CHAR8*getUUIDFromString(const char *source);
void*convertHexStr2Binary(const char *hexStr, int *outLength);
uint32_tascii_hex_to_int(char *buff);
inthex2bin( const char *hex, uint8_t *bin, int len );
static inline uint16_t dp_swap16(uint16_t toswap)
{
trunk/i386/libsaio/fake_efi.c
1919
2020
2121
22
22
2323
2424
2525
26
26
2727
28
28
2929
3030
3131
#include "sl.h"
#ifndef DEBUG_EFI
#define DEBUG_EFI 0
#define DEBUG_EFI 0
#endif
#if DEBUG_EFI
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#define DBG(x...)
#endif
extern void setup_pci_devs(pci_dt_t *pci_dt);
trunk/i386/boot2/drivers.c
4141
4242
4343
44
44
4545
46
46
4747
4848
4949
#include "modules.h"
#if DEBUG
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#define DBG(x...)msglog(x)
#endif
// extern char gMacOSVersion[8];
trunk/i386/boot2/boot.c
5757
5858
5959
60
60
6161
6262
63
64
65
66
6367
64
68
6569
66
70
6771
6872
6973
......
7781
7882
7983
80
84
85
86
8187
8288
8389
......
446452
447453
448454
455
449456
450457
451458
452459
453460
454461
462
455463
456464
457465
......
856864
857865
858866
867
859868
860869
861870
862871
872
873
863874
864875
865876
#include "device_tree.h"
#ifndef DEBUG_BOOT2
#define DEBUG_BOOT2 0
#define DEBUG_BOOT2 0
#endif
#ifndef DEBUG_INTERRUPTS
#define DEBUG_INTERRUPTS 0
#endif
#if DEBUG_BOOT2
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)msglog(x)
#define DBG(x...)msglog(x)
#endif
/*
boolgScanSingleDrive;
booluseGUI;
static intinterruptsAvailable = 0;
#if DEBUG_INTERRUPTS
static intinterruptsAvailable = 0;
#endif
static boolgUnloadPXEOnExit = false;
// Initialize boot-log
initBooterLog();
#if DEBUG_INTERRUPTS
// Enable interrupts
interruptsAvailable = SetupInterrupts();
if (interruptsAvailable)
{
EnableInterrupts();
}
#endif
// Initialize boot info structure.
initKernBootStruct();
nbpUnloadBaseCode();
}
#if DEBUG_INTERRUPTS
if (interruptsAvailable)
{
DisableInterrupts();
}
#endif
}
/*!
trunk/i386/boot2/gui.c
1414
1515
1616
17
17
1818
1919
2020
21
21
2222
23
23
2424
2525
2626
#include "vers.h"
#ifndef DEBUG_GUI
#define DEBUG_GUI 0
#define DEBUG_GUI 0
#endif
#if DEBUG_GUI
#define DBG(x...)printf(x)
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#define DBG(x...)
#endif
#define IMG_REQUIRED -1

Archive Download the corresponding diff file

Revision: 2662