Chameleon

Chameleon Commit Details

Date:2012-11-12 16:27:35 (11 years 5 months ago)
Author:armel cadet-petit
Commit:2118
Parents: 2117
Message:please see the changelog
Changes:
A/branches/cparm/i386/libsaio/pack.c
A/branches/cparm/i386/libsaio/unpack.c
A/branches/cparm/i386/libsaio/uuidP.h
A/branches/cparm/i386/libsaio/gen_uuid-uuid.c
A/branches/cparm/i386/libsaio/uuid.h
M/branches/cparm/i386/libsaio/modules.h
M/branches/cparm/i386/modules/HibernateEnabler/graphic_utils.c
M/branches/cparm/i386/libsaio/load.c
M/branches/cparm/i386/libsaio/pci.h
M/branches/cparm/i386/libsaio/convert.c
M/branches/cparm/Chameleon.xcodeproj/project.pbxproj
M/branches/cparm/i386/libsaio/convert.h
M/branches/cparm/i386/util/amlsgn.m
M/branches/cparm/i386/libsaio/platform.h
M/branches/cparm/i386/libsaio/disk.c
M/branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c
M/branches/cparm/i386/libsaio/device_inject.c
M/branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
M/branches/cparm/i386/libsaio/Makefile
M/branches/cparm/i386/libsaio/acpi_tools.c
M/branches/cparm/i386/boot2/options.c
M/branches/cparm/i386/util/fdisk/cmd.c
M/branches/cparm/i386/libsaio/device_inject.h
M/branches/cparm/i386/libsaio/xml.c
M/branches/cparm/i386/libsaio/SMBIOS.h
M/branches/cparm/i386/util/fdisk/auto.c
M/branches/cparm/i386/boot2/graphics.c
M/branches/cparm/i386/modules/YellowIconFixer/Makefile
M/branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c
M/branches/cparm/i386/modules/Networking/Makefile
M/branches/cparm/i386/modules/ACPICodec/acpi_codec.c
M/branches/cparm/i386/modules/GraphicsEnabler/Makefile
M/branches/cparm/CHANGES
M/branches/cparm/i386/libsaio/sys.c
M/branches/cparm/i386/libsaio/nbp.c
M/branches/cparm/i386/libsaio/biosfn.c
M/branches/cparm/i386/boot2/drivers.c
M/branches/cparm/xcode3_sym.zip
M/branches/cparm/i386/libsaio/device_tree.h
M/branches/cparm/i386/libsaio/saio_types.h
M/branches/cparm/i386/libsaio/hfs_compare.c
M/branches/cparm/i386/libsaio/fake_efi.c
M/branches/cparm/i386/util/md.c
M/branches/cparm/i386/libsaio/fake_efi.h
M/branches/cparm/i386/modules/RamDiskLoader/ramdisk.c
M/branches/cparm/i386/util/fdisk/part.c
M/branches/cparm/i386/libsaio/cpu_intel_amd.c
M/branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c
M/branches/cparm/i386/modules/Networking/Networking.c
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/i386/libsaio/arc4random-fbsd.c
M/branches/cparm/i386/modules/GUI/graphic_utils.c
M/branches/cparm/i386/libsaio/modules.c
M/branches/cparm/i386/libsaio/bootstruct.c
M/branches/cparm/i386/modules/Keymapper/Keylayout.c
M/branches/cparm/i386/util/fdisk/user.c
M/branches/cparm/i386/libsaio/pci.c
M/branches/cparm/i386/libsaio/hfs_CaseTables.h

File differences

branches/cparm/Chameleon.xcodeproj/project.pbxproj
480480
481481
482482
483
484
485
486
487
483488
484489
485490
......
10411046
10421047
10431048
1049
10441050
1051
1052
1053
1054
10451055
10461056
10471057
AB43B3F214C383120018D529 /* udivdi3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = udivdi3.c; sourceTree = "<group>"; };
AB43B3F314C383120018D529 /* umoddi3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = umoddi3.c; sourceTree = "<group>"; };
AB43B3F814C384040018D529 /* stack_protector.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stack_protector.c; sourceTree = "<group>"; };
AB5BBD60164D270C000C872E /* gen_uuid-uuid.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "gen_uuid-uuid.c"; sourceTree = "<group>"; };
AB5BBD68164D391E000C872E /* uuid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uuid.h; sourceTree = "<group>"; };
AB5BBD69164D39FC000C872E /* unpack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = unpack.c; sourceTree = "<group>"; };
AB5BBD6A164D3A46000C872E /* uuidP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uuidP.h; sourceTree = "<group>"; };
AB5BBD77164D3C9A000C872E /* pack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pack.c; sourceTree = "<group>"; };
AB6DE3E6163976A80065E17F /* bcopy_scalar.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = bcopy_scalar.s; sourceTree = "<group>"; };
AB79217514F38CF200F5EB39 /* bootXnu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootXnu.h; sourceTree = "<group>"; };
AB79219214F3919E00F5EB39 /* ModuleHelp.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ModuleHelp.txt; sourceTree = "<group>"; };
AB43B2ED14C37E520018D529 /* libsaio */ = {
isa = PBXGroup;
children = (
AB5BBD60164D270C000C872E /* gen_uuid-uuid.c */,
ABA0C7BF1568190C003440AF /* arc4random-fbsd.c */,
AB5BBD69164D39FC000C872E /* unpack.c */,
AB5BBD77164D3C9A000C872E /* pack.c */,
AB5BBD6A164D3A46000C872E /* uuidP.h */,
AB5BBD68164D391E000C872E /* uuid.h */,
ABA0C7C01568190C003440AF /* lib.c */,
ABA0C7C11568190C003440AF /* rtc.c */,
ABA0C7C21568190C003440AF /* time.c */,
branches/cparm/CHANGES
11
2
3
4
5
26
37
48
- Security fixes
- Implemented random uuid
- device_inject is now embedded into the modules that need it, and not in the core anymore
- Security fixes
- Fixed few bugs in AcpiCodec
- Fixes some bugs related to the auto-installer
branches/cparm/i386/libsaio/fake_efi.h
99
1010
1111
12
1213
1314
1415
#define MAX_CONFIGURATION_TABLE_ENTRIES (uint32_t)10
#include "efi.h"
#include "SMBIOS.h"
#include "device_tree.h"
extern void
branches/cparm/i386/libsaio/xml.c
10271027
10281028
10291029
1030
1030
1031
1032
1033
1034
1035
10311036
10321037
10331038
// Update the refCount and return the string.
symbol->refCount++;
if (lastGuy && lastGuy->next != 0) stop("last guy not last!");
if (lastGuy && lastGuy->next != 0)
{
free(symbol);
stop("last guy not last!");
return 0;
}
return symbol->string;
}
branches/cparm/i386/libsaio/bootstruct.c
5757
5858
5959
60
6061
62
63
6164
6265
6366
......
9497
9598
9699
100
97101
98102
99103
......
204208
205209
206210
211
207212
208213
209214
......
281286
282287
283288
289
284290
285291
286292
......
305311
306312
307313
314
308315
309316
310317
311318
312319
320
313321
314322
315323
bootArgs = (boot_args *)malloc(sizeof(boot_args));
bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t));
if (bootArgs == NULL || bootInfo == NULL)
{
stop("Couldn't allocate boot info\n");
return;
}
else
{
bzero(bootArgs, sizeof(boot_args));
node = DT__FindNode("/", true);
if (node == 0) {
stop("Couldn't create root node");
return;
}
getPlatformName(platformName, sizeof(platformName));
// XXX could make a two-part map here
stop("No memory map found\n");
return;
}
// I Guess that if sane_size == 0 we've got a big problem here,
// and it means that the memory map was not converted properly
stop("Unable to convert memory map into proper format\n");
return;
}
#define MEG(1024*1024)
addr = (void *)AllocateKernelMemory(size);
if (addr == 0) {
stop("Couldn't allocate device tree\n");
return;
}
DT__FlattenDeviceTree((void **)&addr, &size);
if (!size) {
stop("Couldn't get flatten device tree\n");
return;
}
bootArgs->deviceTreeP = (uint32_t)addr;
bootArgs->deviceTreeLength = size;
branches/cparm/i386/libsaio/hfs_CaseTables.h
476476
477477
478478
479
479
480480
481481
482482
......
552552
553553
554554
555
555
556556
557557
558558
// Please update count if you add/remove entries but also please just let
// the compiler calculate it so you don't get it wrong.
//#define kLowerCaseTableNBlocks 182
#define kLowerCaseTableNBlocks (sizeof(gLowerCaseTableCompressed)/sizeof(*gLowerCaseTableCompressed))
#define kLowerCaseTableNBlocks (sizeof(gLowerCaseTableCompressed)/sizeof(struct compressed_block))
// WARNING: The expanded size MUST be updated if you change the table and
// cannot be calculated at compile time.
#define kLowerCaseTableDataSize 5632 /* size of uncompressed structure in bytes */
// Please update count if you add/remove entries but also please just let
// the compiler calculate it so you don't get it wrong.
//#define kCompareTableNBlocks 64
#define kCompareTableNBlocks (sizeof(gCompareTableCompressed)/sizeof(*gCompareTableCompressed))
#define kCompareTableNBlocks (sizeof(gCompareTableCompressed)/sizeof(struct compressed_block))
// WARNING: The expanded size MUST be updated if you change the table and
// cannot be calculated at compile time.
#define kCompareTableDataSize 512 /* size of uncompressed structure in bytes */
branches/cparm/i386/libsaio/uuid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Public include file for the UUID library
*
* Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
*
* %Begin-Header%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
* %End-Header%
*/
#ifndef _UUID_UUID_H
#define _UUID_UUID_H
#include <sys/_types.h>
#ifndef _UUID_T
#define _UUID_T
typedef __darwin_uuid_tuuid_t;
#endif /* _UUID_T */
#ifndef _UUID_STRING_T
#define _UUID_STRING_T
typedef __darwin_uuid_string_tuuid_string_t;
#endif /* _UUID_STRING_T */
#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
#ifdef __cplusplus
extern "C" {
#endif
void uuid_generate_random(uuid_t out);
void uuid_generate(uuid_t out);
#ifdef __cplusplus
}
#endif
#endif /* _UUID_UUID_H */
branches/cparm/i386/libsaio/unpack.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Internal routine for unpacking UUID
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
* %End-Header%
*/
#include "libsaio.h"
void uuid_unpack(const uuid_t in, struct uuid *uu)
{
const uint8_t*ptr = in;
uint32_ttmp;
tmp = *ptr++;
tmp = (tmp << 8) | *ptr++;
tmp = (tmp << 8) | *ptr++;
tmp = (tmp << 8) | *ptr++;
uu->time_low = tmp;
tmp = *ptr++;
tmp = (tmp << 8) | *ptr++;
uu->time_mid = tmp;
tmp = *ptr++;
tmp = (tmp << 8) | *ptr++;
uu->time_hi_and_version = tmp;
tmp = *ptr++;
tmp = (tmp << 8) | *ptr++;
uu->clock_seq = tmp;
memcpy(uu->node, ptr, 6);
}
branches/cparm/i386/libsaio/device_tree.h
2525
2626
2727
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
2885
2986
3087
struct _Node * next;
} Node;
#define MAX_PCI_DEV_PATHS 4
#define MAX_STRING_NUM_ENTRIES 100
#define DEV_PATH_HEADER\
uint8_ttype;\
uint8_tsubtype;\
uint16_tlength;
struct ACPIDevPath {
//uint8_ttype;// = 2 ACPI device-path
//uint8_tsubtype;// = 1 ACPI Device-path
//uint16_t length;// = 0x0c
DEV_PATH_HEADER
uint32_t_HID;// = 0xD041030A ?
uint32_t_UID;// = 0x00000000 PCI ROOT
};
struct PCIDevPath {
//uint8_ttype;// = 1 Hardware device-path
//uint8_tsubtype;// = 1 PCI
//uint16_t length;// = 6
DEV_PATH_HEADER
uint8_tfunction;// pci func number
uint8_tdevice;// pci dev number
};
struct DevicePathEnd {
//uint8_ttype;// = 0x7f
//uint8_tsubtype;// = 0xff
//uint16_tlength;// = 4;
DEV_PATH_HEADER
};
struct DevPropDevice {
uint32_t length;
uint16_t numentries;
uint16_t WHAT2;// 0x0000 ?
struct ACPIDevPath acpi_dev_path;// = 0x02010c00 0xd041030a
struct PCIDevPath pci_dev_path[MAX_PCI_DEV_PATHS]; // = 0x01010600 func dev
struct DevicePathEnd path_end;// = 0x7fff0400
uint8_t *data;
// ------------------------
uint8_t num_pci_devpaths;
struct DevPropString *string;
// ------------------------
};
struct DevPropString {
uint32_t length;
uint32_t WHAT2;// 0x01000000 ?
uint16_t numentries;
uint16_t WHAT3;// 0x0000 ?
struct DevPropDevice *entries;
};
extern Property *
DT__AddProperty(Node *node, const char *name, uint32_t length, void *value);
branches/cparm/i386/libsaio/hfs_compare.c
4848
4949
5050
51
5152
5253
5354
if(out + size <= op + bp->count)
{
stop("HFS+ Unicode tables are malformed\n");
return 0;
}
data = bp->data;
for (j=0; j<bp->count; j++) {
branches/cparm/i386/libsaio/Makefile
3636
3737
3838
39
40
39
4140
4241
4342
xml.o md5.o device_tree.o modules.o \
cpu.o platform.o \
fake_efi.o \
device_inject.o \
convert.o acpi_tools.o smbios.o uterror.o lzss.o lib.o rtc.o time.o
convert.o acpi_tools.o smbios.o uterror.o lzss.o lib.o rtc.o time.o gen_uuid-uuid.o pack.o unpack.o
# Options enabled by default:
branches/cparm/i386/libsaio/SMBIOS.h
181181
182182
183183
184
184
185185
186186
187187
SMBString version;
SMBString serialNumber;
// 2.1+ spec (25 bytes)
SMBByte uuid[16]; // can be all 0 or all 1's
SMBByte uuid[UUID_LEN]; // can be all 0 or all 1's
SMBByte wakeupReason; // reason for system wakeup
// 2.4+ spec (27 bytes)
SMBString skuNumber;
branches/cparm/i386/libsaio/cpu_intel_amd.c
448448
449449
450450
451
451
452452
453453
454454
else if (Vendor != CPUID_VENDOR_AMD)
{
stop("Error: CPU unsupported\n");
halt();
return;
}
/* get extended cpuid results */
branches/cparm/i386/libsaio/gen_uuid-uuid.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* gen_uuid.c --- generate a DCE-compatible uuid
*
* Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o.
*
* %Begin-Header%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
* %End-Header%
*/
/*
* Force inclusion of SVID stuff since we need it if we're compiling in
* gcc-wall wall mode
*/
#define _SVID_SOURCE
#include "libsaio.h"
#include "uuid.h"
static void get_random_bytes(void *buf, int nbytes);
/*
* Generate a series of random bytes, using arc4random
*/
static void get_random_bytes(void *buf, int nbytes)
{
unsigned char *cp = (unsigned char *) buf;
u_int32_t u;
int n = nbytes / sizeof(u);
while (n-- > 0) {
u = arc4random();
memcpy(cp, &u, sizeof(u));
cp += sizeof(u);
}
if ((n = nbytes % sizeof(u)) > 0) {
u = arc4random();
memcpy(cp, &u, n);
}
return;
}
void uuid_generate_random(uuid_t out)
{
uuid_tbuf;
struct uuid uu;
get_random_bytes(buf, sizeof(buf));
uuid_unpack(buf, &uu);
uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000;
uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x4000;
uuid_pack(&uu, out);
}
/*
* This is the generic front-end
*/
void uuid_generate(uuid_t out)
{
uuid_generate_random(out);
}
branches/cparm/i386/libsaio/modules.c
357357
358358
359359
360
361
362
363
364
365
360
361
366362
367363
368364
......
402398
403399
404400
401
402
403
404
405
405406
407
408
409
406410
407411
412
413
414
415
416
417
418
419
420
421
422
423
424
408425
409426
410427
*hook is executed. When registering a new callback name, the callback is added sorted.
*NOTE: the hooks take four void* arguments.
*/
VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*))
{
DBG("Adding callback for hook '%s'.\n", name);
moduleHook_t* hook = get_callback(name);
static VOID __register_hook_callback(moduleHook_t* hook, const char* name, void(*callback)(void*, void*, void*, void*, void*, void*))
{
if(hook)
{
// append
print_hook_list();
getc();
#endif
}
VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*))
{
DBG("Adding callback for hook '%s'.\n", name);
moduleHook_t* hook = get_callback(name);
__register_hook_callback(hook, name, callback);
}
VOID register_one_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*))
{
DBG("Adding one callback for hook '%s'.\n", name);
moduleHook_t* hook = get_callback(name);
if (hook)
{
return;
}
__register_hook_callback(hook, name, callback);
}
#if DEBUG_MODULES
unsigned long vmaddr;
long vmsize;
branches/cparm/i386/libsaio/modules.h
2424
2525
2626
27
27
2828
2929
3030
......
7474
7575
7676
77
7778
7879
7980
#include "efi.h"
#define DEFAULT_BUNDLE_SPEC_SIZE 4096
#define macho_64 1
#define macho_64 0
extern unsigned long long textAddress;
extern unsigned long long textSection;
*/
EFI_STATUS execute_hook(const char* name, void*, void*, void*, void*, void*, void*);
VOID register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*));
VOID register_one_callback(const char* name, void(*callback)(void*, void*, void*, void*, void*, void*));
void rebase_location(UInt32* location, char* base, int type);
void bind_location(UInt32* location, char* value, UInt32 addend, int type);
branches/cparm/i386/libsaio/uuidP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* uuid.h -- private header file for uuids
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
* %End-Header%
*/
#include "uuid.h"
/*
* Offset between 15-Oct-1582 and 1-Jan-70
*/
#define TIME_OFFSET_HIGH 0x01B21DD2
#define TIME_OFFSET_LOW 0x13814000
struct uuid {
uint32_ttime_low;
uint16_ttime_mid;
uint16_ttime_hi_and_version;
uint16_tclock_seq;
uint8_tnode[6];
};
/* UUID Variant definitions */
#define UUID_VARIANT_NCS 0
#define UUID_VARIANT_DCE 1
#define UUID_VARIANT_MICROSOFT2
#define UUID_VARIANT_OTHER3
/* UUID Type definitions */
#define UUID_TYPE_DCE_TIME 1
#define UUID_TYPE_DCE_RANDOM 4
/*
* prototypes
*/
void uuid_pack(const struct uuid *uu, uuid_t ptr);
void uuid_unpack(const uuid_t in, struct uuid *uu);
branches/cparm/i386/libsaio/device_inject.c
1111
1212
1313
14
1415
1516
1617
......
2223
2324
2425
25
26
27
26
27
28
2829
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
7730
7831
7932
......
9750
9851
9952
100
53
10154
10255
10356
......
200153
201154
202155
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337156
338157
339158
......
344163
345164
346165
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375166
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
376194
377195
378196
......
394212
395213
396214
397
215
398216
399
400
401
402
403217
404218
405219
......
421235
422236
423237
424
238
425239
426240
427241
428242
429243
430
244
431245
432246
433
247
434248
435249
436250
......
438252
439253
440254
441
255
442256
443257
444258
445259
446
447
448
449
260
261
262
263
450264
451265
452266
......
456270
457271
458272
459
460
461
462
273
274
275
276
463277
464278
465279
......
467281
468282
469283
470
471
284
285
472286
473287
474288
......
500314
501315
502316
503
317
504318
505319
506320
......
519333
520334
521335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
522401
#include "device_inject.h"
#include "convert.h"
#include "platform.h"
#include "modules.h"
#ifndef DEBUG_INJECT
#define DEBUG_INJECT 0
#define DBG(x...)
#endif
char *efi_inject_get_devprop_string(uint32_t *len)
{
struct DevPropString *string = (struct DevPropString *)(uint32_t)get_env(envEFIString);
static char *efi_inject_get_devprop_string(uint32_t *len);
void setupDeviceProperties_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
static EFI_STATUS setupDeviceProperties(Node *node);
if(string)
{
*len = string->length;
return devprop_generate_string(string);
}
return NULL;
}
void setupDeviceProperties(Node *node)
{
const char *val;
uint8_t *binStr;
uint8_t *kbinStr;
int cnt = 0, cnt2 = 0;
static char DEVICE_PROPERTIES_PROP[] = "device-properties";
/* Generate devprop string.
*/
uint32_t strlength;
char *string = efi_inject_get_devprop_string(&strlength);
if (string == NULL) {
verbose("efi_inject_get_devprop_string NULL trying stringdata\n");
return;
}
/* Use the static "device-properties" boot config key contents if available,
* otheriwse use the generated one.
*/
if (!getValueForKey(kDeviceProperties, &val, &cnt, DEFAULT_BOOT_CONFIG))
{
val = (const char*)string;
cnt = strlength * 2;
}
if (cnt > 1)
{
binStr = convertHexStr2Binary(val, &cnt2);
if (cnt2 > 0)
{
kbinStr = (uint8_t*)AllocateKernelMemory(cnt2);
bcopy(binStr,kbinStr,cnt2);
DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, kbinStr);
}
}
}
struct DevPropString *devprop_create_string(void)
{
struct DevPropString *string = (struct DevPropString*)malloc(sizeof(struct DevPropString));
pci_dt_t*current;
pci_dt_t*end;
end = root_pci_dev;
end = (pci_dt_t *)(uint32_t)get_env(envPCIRootDev);
device = malloc(sizeof(struct DevPropDevice));
if (!device) {
return device;
}
#if 0
struct DevPropDevice *devprop_add_device(struct DevPropString *string, char *path)
{
struct DevPropDevice*device;
const charpciroot_string[] = "PciRoot(0x";
const charpci_device_string[] = "Pci(0x";
if (string == NULL || path == NULL) {
return NULL;
}
device = malloc(sizeof(struct DevPropDevice));
if (!device) {
return NULL;
}
if (strncmp(path, pciroot_string, strlen(pciroot_string))) {
free(device);
printf("ERROR parsing device path 1\n");
return NULL;
}
memset(device, 0, sizeof(struct DevPropDevice));
device->acpi_dev_path._UID = getPciRootUID();
int numpaths = 0;
intx, curr = 0, w = 0;
charbuff[16];
for (x = 0; x < strlen(path); x++)
{
if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string)))
{
x+=strlen(pci_device_string);
curr=x;
while(path[++x] != ',');
w = x-curr;
if ((w > 4) || /*(w > sizeof(buff)) ||*/ (w == 0)) {
printf("ERROR parsing device path 2\n");
break;
}
snprintf(buff, x-curr, "%s",&path[curr]);
device->pci_dev_path[numpaths].device =(uint8_t)strtoul(buff, NULL, 16);
bzero(buff, sizeof(buff));
x += 3; // 0x
curr = x;
while(path[++x] != ')');
w = x-curr;
if ((w > 4) || /*(w > sizeof(buff)) ||*/ (w == 0)) {
printf("ERROR parsing device path 3\n");
break;
}
snprintf(buff, x-curr, "%s",&path[curr]);
device->pci_dev_path[numpaths].function = (uint8_t)strtoul(buff, NULL, 16); // TODO: find dev from char *path
numpaths++;
}
}
if(!numpaths)
{
printf("ERROR parsing device path 4\n");
free(device);
return NULL;
}
device->numentries = 0x00;
device->acpi_dev_path.length = 0x0c;
device->acpi_dev_path.type = 0x02;
device->acpi_dev_path.subtype = 0x01;
device->acpi_dev_path._HID = 0xd041030a;
device->num_pci_devpaths = numpaths;
device->length = 24 + (6*numpaths);
inti;
for(i = 0; i < numpaths; i++)
{
device->pci_dev_path[i].length = 0x06;
device->pci_dev_path[i].type = 0x01;
device->pci_dev_path[i].subtype = 0x01;
}
device->path_end.length = 0x04;
device->path_end.type = 0x7f;
device->path_end.subtype = 0xff;
device->string = string;
device->data = NULL;
string->length += device->length;
if(!string->entries)
{
if((string->entries = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice) * MAX_STRING_NUM_ENTRIES))== NULL)
{
printf("ERROR parsing device path 6\n");
free(device);
return NULL;
}
}
struct DevPropDevice **string_entries_arrey = (struct DevPropDevice **) string->entries;
if ((string->numentries+1) < MAX_STRING_NUM_ENTRIES)
{
string->numentries++;
}
else
{
free(string->entries);
free(device);
return NULL;
}
string_entries_arrey[string->numentries-1] = device;
return device;
}
#endif
int devprop_add_value(struct DevPropDevice *device, char *nm, uint8_t *vl, uint32_t len)
{
uint32_t length = ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2);
uint8_t *data = (uint8_t*)malloc(length);
{
if(!data)
{
return 0;
}
memset(data, 0, length);
uint32_t off= 0;
data[off+1] = ((strlen(nm) * 2) + 6) >> 8;
data[off] = ((strlen(nm) * 2) + 6) & 0x00FF;
off += 4;
uint32_t i=0, l = strlen(nm);
for(i = 0 ; i < l ; i++, off += 2)
{
data[off] = *nm++;
}
off += 2;
l = len;
uint32_t *datalength = (uint32_t*)&data[off];
*datalength = l + 4;
off += 4;
for(i = 0 ; i < l ; i++, off++)
{
data[off] = *vl++;
}
}
if(!data)
{
return 0;
}
memset(data, 0, length);
uint32_t off= 0;
data[off+1] = ((strlen(nm) * 2) + 6) >> 8;
data[off] = ((strlen(nm) * 2) + 6) & 0x00FF;
off += 4;
uint32_t i=0, l = strlen(nm);
for(i = 0 ; i < l ; i++, off += 2)
{
data[off] = *nm++;
}
off += 2;
l = len;
uint32_t *datalength = (uint32_t*)&data[off];
*datalength = l + 4;
off += 4;
for(i = 0 ; i < l ; i++, off++)
{
data[off] = *vl++;
}
uint32_t offset = device->length - (24 + (6 * device->num_pci_devpaths));
uint8_t *newdata = (uint8_t*)malloc((length + offset));
device->string->length += length;
device->numentries++;
if(!device->data)
if(device->data)
{
//device->data = (uint8_t*)malloc(sizeof(uint8_t)); //IMHO this is useless
}
else
{
free(device->data);
}
}
snprintf(buffer, len, "%08x%08x%04x%04x", dp_swap32(string->length), string->WHAT2,
dp_swap16(string->numentries), string->WHAT3);
dp_swap16(string->numentries), string->WHAT3);
buffer += 24;
len -= 24;
int i = 0, x = 0;
struct DevPropDevice **string_entries_arrey = (struct DevPropDevice **) string->entries;
while(i < string->numentries)
{
if (!(i<MAX_STRING_NUM_ENTRIES))
if (!(i<MAX_STRING_NUM_ENTRIES))
{
break;
}
break;
}
snprintf(buffer, len, "%08x%04x%04x", dp_swap32(string_entries_arrey[i]->length),
dp_swap16(string_entries_arrey[i]->numentries), string_entries_arrey[i]->WHAT2);
dp_swap16(string_entries_arrey[i]->numentries), string_entries_arrey[i]->WHAT2);
buffer += 16;
len -= 16;
snprintf(buffer, len,"%02x%02x%04x%08x%08x", string_entries_arrey[i]->acpi_dev_path.type,
string_entries_arrey[i]->acpi_dev_path.subtype,
dp_swap16(string_entries_arrey[i]->acpi_dev_path.length),
string_entries_arrey[i]->acpi_dev_path._HID,
dp_swap32(string_entries_arrey[i]->acpi_dev_path._UID));
string_entries_arrey[i]->acpi_dev_path.subtype,
dp_swap16(string_entries_arrey[i]->acpi_dev_path.length),
string_entries_arrey[i]->acpi_dev_path._HID,
dp_swap32(string_entries_arrey[i]->acpi_dev_path._UID));
buffer += 24;
len -= 24;
break;
}
snprintf(buffer, len,"%02x%02x%04x%02x%02x", string_entries_arrey[i]->pci_dev_path[x].type,
string_entries_arrey[i]->pci_dev_path[x].subtype,
dp_swap16(string_entries_arrey[i]->pci_dev_path[x].length),
string_entries_arrey[i]->pci_dev_path[x].function,
string_entries_arrey[i]->pci_dev_path[x].device);
string_entries_arrey[i]->pci_dev_path[x].subtype,
dp_swap16(string_entries_arrey[i]->pci_dev_path[x].length),
string_entries_arrey[i]->pci_dev_path[x].function,
string_entries_arrey[i]->pci_dev_path[x].device);
buffer += 12;
len -= 12;
}
break;
}
snprintf(buffer, len,"%02x%02x%04x", string_entries_arrey[i]->path_end.type,
string_entries_arrey[i]->path_end.subtype,
dp_swap16(string_entries_arrey[i]->path_end.length));
string_entries_arrey[i]->path_end.subtype,
dp_swap16(string_entries_arrey[i]->path_end.length));
buffer += 8;
len -= 8;
for(i = 0; i < string->numentries; i++)
{
if (!(i<MAX_STRING_NUM_ENTRIES))
if (!(i<MAX_STRING_NUM_ENTRIES))
{
break;
}
free(string);
string = NULL;
}
static char *efi_inject_get_devprop_string(uint32_t *len)
{
struct DevPropString *string = (struct DevPropString *)(uint32_t)get_env(envEFIString);
if(string)
{
*len = string->length;
return devprop_generate_string(string);
}
return NULL;
}
static EFI_STATUS setupDeviceProperties(Node *node)
{
const char *val;
uint8_t *binStr;
uint8_t *kbinStr;
int cnt = 0, cnt2 = 0;
static char DEVICE_PROPERTIES_PROP[] = "device-properties";
/* Generate devprop string.
*/
uint32_t strlength = 0;
char *string = efi_inject_get_devprop_string(&strlength);
if (string == NULL) {
DBG("efi_inject_get_devprop_string NULL trying stringdata\n");
return EFI_NO_MEDIA;
}
val = (const char*)string;
cnt = strlength * 2;
if (cnt > 1)
{
binStr = convertHexStr2Binary(val, &cnt2);
if (cnt2 > 0)
{
kbinStr = (uint8_t*)AllocateKernelMemory(cnt2);
if (kbinStr)
{
bcopy(binStr,kbinStr,cnt2);
DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, kbinStr);
return EFI_SUCCESS;
}
}
}
return EFI_DEVICE_ERROR;
}
void setupDeviceProperties_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
{
Node *node = (Node *)arg1;
EFI_STATUS *ret = (EFI_STATUS*)arg2;
*ret = setupDeviceProperties(node);
}
void register_device_inject(void)
{
register_one_callback("setupDeviceProperties", &setupDeviceProperties_hook);
}
branches/cparm/i386/libsaio/device_inject.h
99
1010
1111
12
1213
1314
1415
15
16
1716
18
17
18
19
20
21
22
23
1924
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
8125
#define __LIBSAIO_DEVICE_INJECT_H
#include "pci.h"
#include "device_tree.h"
#define DP_ADD_TEMP_VAL(dev, val) devprop_add_value(dev, (char*)val[0], (uint8_t*)val[1], strlen(val[1]) + 1)
#define DP_ADD_TEMP_VAL_DATA(dev, val) devprop_add_value(dev, (char*)val.name, (uint8_t*)val.data, val.size)
#define MAX_PCI_DEV_PATHS 4
#define MAX_STRING_NUM_ENTRIES 100
extern void setupDeviceProperties(Node *node);
structDevPropString*devprop_create_string(void);
structDevPropDevice *devprop_add_device(struct DevPropString *string, pci_dt_t * pci_dt);
structDevPropDevice *devprop_make_device(pci_dt_t *pci_dt);
intdevprop_add_value(struct DevPropDevice *device, char *nm, uint8_t *vl, uint32_t len);
voidregister_device_inject(void);
char*devprop_generate_string(struct DevPropString *string);
voiddevprop_free_string(struct DevPropString *string);
#define DEV_PATH_HEADER\
uint8_ttype;\
uint8_tsubtype;\
uint16_tlength;
struct ACPIDevPath {
//uint8_ttype;// = 2 ACPI device-path
//uint8_tsubtype;// = 1 ACPI Device-path
//uint16_t length;// = 0x0c
DEV_PATH_HEADER
uint32_t_HID;// = 0xD041030A ?
uint32_t_UID;// = 0x00000000 PCI ROOT
};
struct PCIDevPath {
//uint8_ttype;// = 1 Hardware device-path
//uint8_tsubtype;// = 1 PCI
//uint16_t length;// = 6
DEV_PATH_HEADER
uint8_tfunction;// pci func number
uint8_tdevice;// pci dev number
};
struct DevicePathEnd {
//uint8_ttype;// = 0x7f
//uint8_tsubtype;// = 0xff
//uint16_tlength;// = 4;
DEV_PATH_HEADER
};
struct DevPropDevice {
uint32_t length;
uint16_t numentries;
uint16_t WHAT2;// 0x0000 ?
struct ACPIDevPath acpi_dev_path;// = 0x02010c00 0xd041030a
struct PCIDevPath pci_dev_path[MAX_PCI_DEV_PATHS]; // = 0x01010600 func dev
struct DevicePathEnd path_end;// = 0x7fff0400
uint8_t *data;
// ------------------------
uint8_t num_pci_devpaths;
struct DevPropString *string;
// ------------------------
};
struct DevPropString {
uint32_t length;
uint32_t WHAT2;// 0x01000000 ?
uint16_t numentries;
uint16_t WHAT3;// 0x0000 ?
struct DevPropDevice *entries;
};
char*efi_inject_get_devprop_string(uint32_t *len);
struct DevPropString*devprop_create_string(void);
struct DevPropDevice *devprop_add_device(struct DevPropString *string, pci_dt_t * pci_dt);
struct DevPropDevice *devprop_make_device(pci_dt_t *pci_dt);
intdevprop_add_value(struct DevPropDevice *device, char *nm, uint8_t *vl, uint32_t len);
char*devprop_generate_string(struct DevPropString *string);
voiddevprop_free_string(struct DevPropString *string);
#endif /* !__LIBSAIO_DEVICE_INJECT_H */
branches/cparm/i386/libsaio/sys.c
6767
6868
6969
70
71
72
73
7470
7571
76
7772
7873
7974
......
400395
401396
402397
403
398
404399
405400
406401
......
632627
633628
634629
635
630
636631
637632
638633
#include "modules.h"
#include "xml.h"
# include "md5.h"
#include <uuid/uuid.h>
#if 0 /* No OS X release has ever included this. */
#include <Kernel/uuid/namespace.h>
#else
/* copied from uuid/namespace.h, just like BootX's fs.c does. */
UUID_DEFINE( kFSUUIDNamespaceSHA1, 0xB3, 0xE2, 0x0F, 0x39, 0xF2, 0x92, 0x11, 0xD6, 0x97, 0xA4, 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC );
#endif
#if UNUSED
extern int multiboot_partition;
fdesc = GetFreeFd();
io = &iob[fdesc];
bzero(io, sizeof(*io));
bzero(io, sizeof(struct iob));
// Mark the descriptor as taken.
io->i_flgs = F_ALLOC;
fdesc = GetFreeFd();
io = &iob[fdesc];
bzero(io, sizeof(*io));
bzero(io, sizeof(struct iob));
// Mark the descriptor as taken. Set the F_MEM flag to indicate
// that the file buffer is provided by the caller.
branches/cparm/i386/libsaio/pack.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Internal routine for packing UUID's
*
* Copyright (C) 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, and the entire permission notice in its entirety,
* including the disclaimer of warranties.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
* %End-Header%
*/
#include "libsaio.h"
void uuid_pack(const struct uuid *uu, uuid_t ptr)
{
uint32_ttmp;
unsigned char*out = ptr;
tmp = uu->time_low;
out[3] = (unsigned char) tmp;
tmp >>= 8;
out[2] = (unsigned char) tmp;
tmp >>= 8;
out[1] = (unsigned char) tmp;
tmp >>= 8;
out[0] = (unsigned char) tmp;
tmp = uu->time_mid;
out[5] = (unsigned char) tmp;
tmp >>= 8;
out[4] = (unsigned char) tmp;
tmp = uu->time_hi_and_version;
out[7] = (unsigned char) tmp;
tmp >>= 8;
out[6] = (unsigned char) tmp;
tmp = uu->clock_seq;
out[9] = (unsigned char) tmp;
tmp >>= 8;
out[8] = (unsigned char) tmp;
memcpy(out+10, uu->node, 6);
}
branches/cparm/i386/libsaio/nbp.c
116116
117117
118118
119
119
120120
121121
122
122
123123
124124
125125
if ( !gNetBVR )
{
gNetBVR = malloc( sizeof(*gNetBVR) );
gNetBVR = malloc( sizeof(struct BootVolume) );
if ( gNetBVR )
{
bzero(gNetBVR, sizeof(*gNetBVR));
bzero(gNetBVR, sizeof(struct BootVolume));
gNetBVR->biosdev = biosdev;
gNetBVR->flags = kBVFlagPrimary | kBVFlagNativeBoot;
gNetBVR->description = NBPGetDescription;
branches/cparm/i386/libsaio/load.c
269269
270270
271271
272
272
273
274
275
273276
274277
275278
(vmaddr >= HIB_ADDR &&
(vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN))))
{
stop("Kernel overflows available space");
*load_addr = ~0;
*load_size = 0;
stop("Kernel overflows available space");
return -1;
}
if (vmsize && (strncmp(segname, "__PRELINK", sizeof("__PRELINK")) == 0 || strncmp(segname, "__PRELINK_INFO", sizeof("__PRELINK_INFO")) == 0))
branches/cparm/i386/libsaio/platform.h
6262
6363
6464
65
66
67
6865
6966
7067
......
121118
122119
123120
121
122
124123
125124
126125
/* Maximum number of SPD bytes */
#define MAX_SPD_SIZE256
/* Size of SMBIOS UUID in bytes */
#define UUID_LEN16
typedef struct _RamSlotInfo_t {
uint32_tModuleSize;// Size of Module in MB
uint32_tFrequency; // in Mhz
#define envgDeviceCount "boot.hw.device_count"
#define envarchCpuType"boot.hw.cputype"
#define envPCIRootDev "boot.hw.pci_root_dev"
#define envgHaveKernelCache"boot.kern.HaveKernelCache"
#define envAdler32"boot.kern.adler32"
#define envkCacheFile "boot.kern.kernelcache"
branches/cparm/i386/libsaio/disk.c
588588
589589
590590
591
591
592592
593593
594
594
595595
596596
597597
......
658658
659659
660660
661
661
662662
663663
664
664
665665
666666
667667
......
739739
740740
741741
742
742
743743
744744
745
745
746746
747747
748748
......
837837
838838
839839
840
840
841841
842842
843843
......
11381138
11391139
11401140
1141
1141
11421142
11431143
11441144
......
13991399
14001400
14011401
1402
1402
14031403
14041404
14051405
......
18301830
18311831
18321832
1833
1834
1835
1836
18331837
18341838
18351839
......
18561860
18571861
18581862
1859
1863
1864
1865
1866
18601867
18611868
18621869
......
19661973
19671974
19681975
1969
1976
19701977
19711978
19721979
1973
1980
19741981
19751982
19761983
......
22452252
22462253
22472254
2248
2255
22492256
22502257
22512258
......
22832290
22842291
22852292
2286
2293
22872294
22882295
22892296
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef) malloc( sizeof(struct BootVolume) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
bzero(bvr, sizeof(struct BootVolume));
bvr->biosdev = biosdev;
bvr->part_no = partno;
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef) malloc( sizeof(struct BootVolume) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
bzero(bvr, sizeof(struct BootVolume));
bvr->biosdev = biosdev;
bvr->part_no = partno;
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef) malloc( sizeof(struct BootVolume) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
bzero(bvr, sizeof(struct BootVolume));
bvr->biosdev = biosdev;
bvr->part_no = partno;
#endif
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
map = (struct DiskBVMap *) malloc( sizeof(struct DiskBVMap) );
if ( !map )
{
return NULL;
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
map = (struct DiskBVMap *) malloc( sizeof(struct DiskBVMap) );
if ( !map )
{
return NULL;
DBG("Read GPT\n");
// Allocate a new map for this BIOS device and insert it into the chain
map = malloc(sizeof(*map));
map = (struct DiskBVMap *) malloc(sizeof(struct DiskBVMap));
if (!map) {
goto scanErr;
}
void rescanBIOSDevice(int biosdev)
{
struct DiskBVMap *oldMap = diskResetBootVolumes(biosdev);
if (oldMap == NULL)
{
return;
}
CacheReset();
diskFreeMap(oldMap);
oldMap = NULL;
else if(prevMap != NULL)
prevMap->next = map->next;
else
stop("");
{
stop("diskResetBootVolumes error\n");
return NULL;
}
}
// Return the old map, either to be freed, or reinserted later
return map;
/*
* Allocate and copy the matched bvr entry into a new one.
*/
newBVR = (BVRef) malloc(sizeof(*newBVR));
newBVR = (BVRef) malloc(sizeof(struct BootVolume));
if (!newBVR) {
continue;
}
bcopy(bvr, newBVR, sizeof(*newBVR));
bcopy(bvr, newBVR, sizeof(struct BootVolume));
/*
* Adjust the new bvr's fields.
{
if ( gBootSector == NULL )
{
gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector));
gBootSector = (struct disk_blk0 *) malloc(sizeof(struct disk_blk0));
if ( gBootSector == NULL ) return -1;
}
bootSector = gBootSector;
{
if ( gBootSector == NULL )
{
gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector));
gBootSector = (struct disk_blk0 *) malloc(sizeof(struct disk_blk0));
if ( gBootSector == NULL ) return -1;
}
bootSector = (struct disk_boot1f32_blk *) gBootSector;
branches/cparm/i386/libsaio/acpi_tools.c
194194
195195
196196
197
197
198
199
200
198201
199
202
203
200204
201205
202206
......
222226
223227
224228
225
229
230
226231
227232
233
234
228235
229
236
237
230238
231239
232240
......
237245
238246
239247
240
248
249
250
251
241252
242
253
254
243255
244256
245257
......
292304
293305
294306
295
296
297
307
308
309
310
311
312
313
314
298315
299316
300317
// Compute number of table pointers included in RSDT
num_tables = get_num_tables(rsdt);
for (index = 0; index < num_tables; index++) {
for (index = 0; index < num_tables; index++)
{
if (!table_array[index]) continue;
if ((*(U32 *) (table_array[index]->Signature) == signature) &&
(GetChecksum(table_array[index], table_array[index]->Length) == 0)) {
(GetChecksum(table_array[index], table_array[index]->Length) == 0))
{
return (table_array[index]);
}
}
switch (method) {
case 0x2:
{
for (index = 0; index < num_tables; index++) {
for (index = 0; index < num_tables; index++)
{
U64 ptr = xsdt->TableOffsetEntry[index];
if (!ptr) continue;
if ((*(U32 *) ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Signature == signature) &&
(GetChecksum(((ACPI_TABLE_HEADER *) (unsigned long)ptr), ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Length) == 0)) {
(GetChecksum(((ACPI_TABLE_HEADER *) (unsigned long)ptr), ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Length) == 0))
{
return (((ACPI_TABLE_HEADER *) (unsigned long)ptr));
}
}
{
ACPI_TABLE_HEADER *table = (ACPI_TABLE_HEADER *) xsdt->TableOffsetEntry;
for (index = 0; index < num_tables; index++) {
for (index = 0; index < num_tables; index++)
{
if (!table) continue;
if (((U32) (table->Signature) == signature) &&
(GetChecksum(table, table->Length) == 0)) {
(GetChecksum(table, table->Length) == 0))
{
return (table);
}
// Move array pointer to next 64-bit pointer
if (current == 0ul)
return (0ul);
for (; current < end; current += 16) {
if (*(volatile U64 *)current == NAMESEG64("RSD PTR ")) {
if (GetChecksum(current, ACPI_RSDP_REV0_SIZE) == 0) {
for (; current < end; current += 16)
{
if (!current) continue;
if (*(volatile U64 *)current == NAMESEG64("RSD PTR "))
{
if (GetChecksum(current, ACPI_RSDP_REV0_SIZE) == 0)
{
// RSD pointer structure checksum okay, lookup the RSDT pointer.
acpi_tables->RsdPointer = (ACPI_TABLE_RSDP *)current;
acpi_tables->RsdtPointer = (ACPI_TABLE_RSDT *) acpi_tables->RsdPointer->RsdtPhysicalAddress;
branches/cparm/i386/libsaio/arc4random-fbsd.c
284284
285285
286286
287
287288
288289
289290
290291
291292
292
293293
294294
295295
return (r % upper_bound);
}
#if 0
void
arc4_init(void)
{
}
#if 0
/*-------- Test code for i386 --------*/
#include <stdio.h>
#include <machine/pctr.h>
branches/cparm/i386/libsaio/pci.c
88
99
1010
11
11
1212
1313
1414
......
2020
2121
2222
23
24
2523
2624
2725
......
145143
146144
147145
148
149
150
146
147
148
151149
152
150
151
153152
154153
155154
155
156
156157
157158
158159
......
164165
165166
166167
167
168
169
170
168
169
171170
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
199
200
201
202
203
204
205
206
207
208
209
210171
211
172
212173
213174
214175
......
216177
217178
218179
180
181
182
183
184
185
186
187
188
189
190
191
192
219193
220194
221195
#include "bootstruct.h"
#include "pci.h"
#include "modules.h"
#include "device_inject.h"
#include "platform.h"
#ifndef DEBUG_PCI
#define DEBUG_PCI 0
#define DBG(x...)
#endif
pci_dt_t*root_pci_dev;
static char* dev_path;// TODO: Figure out what is going on here...
static void scan_pci_bus(pci_dt_t *start, uint8_t bus);
static void enable_pci_devs(void);
void build_pci_dt(void)
{
dev_path = malloc(sizeof(char) * 256);// TODO: remove
root_pci_dev = malloc(sizeof(pci_dt_t));
pci_dt_t*root_pci_dev;
root_pci_dev = malloc(sizeof(pci_dt_t));
if (!dev_path || !root_pci_dev) {
if (!root_pci_dev)
{
stop("Couldn't allocate memory for the pci root device\n");
return ;
}
set_env(envPCIRootDev,(uint32_t)root_pci_dev);
bzero(root_pci_dev, sizeof(pci_dt_t));
enable_pci_devs();
scan_pci_bus(root_pci_dev, 0);
#endif
}
#if 0
char *get_pci_dev_path(pci_dt_t *pci_dt)
{
char* buffer = malloc(sizeof(char) * 256);
static void setup_pci_devs(pci_dt_t *current)
{
if (!buffer) {
return NULL;
}
pci_dt_t*current;
pci_dt_t*end;
chartmp[64];
buffer[0] = 0;
end = root_pci_dev;
int uid = getPciRootUID();
while (end != pci_dt)
{
current = pci_dt;
while (current->parent != end)
current = current->parent;
end = current;
if (current->parent == root_pci_dev)
{
snprintf(tmp, sizeof(tmp),"PciRoot(0x%x)/Pci(0x%x,0x%x)", uid,
current->dev.bits.dev, current->dev.bits.func);
}
else
{
snprintf(tmp, sizeof(tmp) ,"/Pci(0x%x,0x%x)",
current->dev.bits.dev, current->dev.bits.func);
}
snprintf(buffer, sizeof(char) * 256,"%s%s", buffer, tmp);
}
return buffer;
}
#endif
void setup_pci_devs(pci_dt_t *pci_dt)
{
pci_dt_t *current = pci_dt;
while (current)
{
{
execute_hook("PCIDevice", (void*)current, NULL, NULL, NULL, NULL, NULL);
setup_pci_devs(current->children);
}
}
void setup_root_pci_devs(void)
{
pci_dt_t *root_pci_dev = (pci_dt_t *)(uint32_t)get_env(envPCIRootDev);
if (!root_pci_dev)
{
stop("No PCI root device\n");
return ;
}
setup_pci_devs(root_pci_dev);
}
#ifndef OPTION_ROM
void dump_pci_dt(pci_dt_t *pci_dt)
{
branches/cparm/i386/libsaio/biosfn.c
827827
828828
829829
830
830
831831
832832
833833
dp->cylinders = bb.ecx.r.h | ((bb.ecx.r.l & 0xC0) << 2);
dp->totalDrives = bb.edx.r.l;
} else {
bzero(dp, sizeof(*dp));
bzero(dp, sizeof(struct driveParameters));
}
return bb.eax.r.h;
branches/cparm/i386/libsaio/convert.c
7979
8080
8181
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
10482
10583
10684
return uuid;
}
/** XXX AsereBLN replace by strtoul */
#if UNUSED
uint32_t ascii_hex_to_int(char *buff)
{
uint32_tvalue = 0, i, digit;
for(i = 0; i < (uint32_t)strlen(buff); i++)
{
if (buff[i] >= 48 && buff[i] <= 57)// '0' through '9'
digit = buff[i] - 48;
else if (buff[i] >= 65 && buff[i] <= 70)// 'A' through 'F'
digit = buff[i] - 55;
else if (buff[i] >= 97 && buff[i] <= 102)// 'a' through 'f'
digit = buff[i] - 87;
else
return value;
value = digit + 16 * value;
}
returnvalue;
}
#endif
void *convertHexStr2Binary(const char *hexStr, int *outLength)
{
int len;
branches/cparm/i386/libsaio/pci.h
5353
5454
5555
56
5756
5857
5958
......
6362
6463
6564
66
65
6766
6867
6968
#define PCI_ADDR_REG0xcf8
#define PCI_DATA_REG0xcfc
extern pci_dt_t*root_pci_dev;
extern uint8_tpci_config_read8(uint32_t, uint8_t);
extern uint16_tpci_config_read16(uint32_t, uint8_t);
extern uint32_tpci_config_read32(uint32_t, uint8_t);
//extern char*get_pci_dev_path(pci_dt_t *);
extern voidbuild_pci_dt(void);
extern voiddump_pci_dt(pci_dt_t *);
extern voidsetup_pci_devs(pci_dt_t *pci_dt);
extern voidsetup_root_pci_devs(void);
extern int getPciRootUID(void);
//-----------------------------------------------------------------------------
branches/cparm/i386/libsaio/saio_types.h
3535
3636
3737
38
3839
3940
4041
......
7778
7879
7980
81
8082
8183
8284
......
8688
8789
8890
91
92
8993
94
9095
9196
9297
#include <IOKit/IOTypes.h>
#endif
#include "bootXnu.h"
#include "uuidP.h"
#if DEBUG
#define DEBUG_DISK(x) printf x
#define kRenamePartition"Rename Partition"/* disk.c */
#define kSMBIOSKey"SMBIOS"/* fake_efi.c */
#define kSystemID"SystemId"/* fake_efi.c */
#define kRandomSystemID"RandomSystemId"/* fake_efi.c */
#define kSystemType"SystemType"/* fake_efi.c */
#define kPCIRootUID"PCIRootUID"/* pci_root.c */
#define kDefaultPartition"Default Partition"/* sys.c */
#define kRebootOnPanic"RebootOnPanic"
#define kEnableHiDPI"EnableHiDPI"// enable High resolution display (aka Retina)
#define UUID_LEN sizeof(uuid_t)
#define UUID_STR_LEN sizeof(uuid_string_t)
#define PLATFORM_NAME_LEN 64
#define ROOT_PATH_LEN 256
branches/cparm/i386/libsaio/convert.h
99
1010
1111
12
13
14
15
1612
1713
1814
#include "libsaio.h"
#include "efi.h"
#define UUID_LEN16
#define UUID_STR_LEN UUID_LEN*2 + 8
const char * getStringFromUUID(const EFI_CHAR8* uuid);
EFI_CHAR8* getUUIDFromString(const char *source);
void *convertHexStr2Binary(const char *hexStr, int *outLength);
branches/cparm/i386/libsaio/fake_efi.c
1414
1515
1616
17
1817
1918
2019
......
7574
7675
7776
77
7878
7979
8080
......
110110
111111
112112
113
114
113
114
115115
116116
117
118
119
120117
121118
122119
......
240237
241238
242239
243
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
244284
245285
246286
......
691731
692732
693733
694
734
735
695736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
696756
697757
698758
699759
700760
701
702
761
762
763
703764
704765
705766
......
710771
711772
712773
774
713775
714
776
777
715778
716779
717780
......
727790
728791
729792
730
793
794
795
796
797
731798
732799
733800
......
740807
741808
742809
743
810
811
812
813
814
744815
745816
746817
......
9341005
9351006
9361007
937
1008
9381009
9391010
9401011
......
10901161
10911162
10921163
1093
1164
10941165
10951166
10961167
#include "fake_efi.h"
#include "efi_tables.h"
#include "platform.h"
#include "device_inject.h"
#include "convert.h"
#include "pci.h"
#include "sl.h"
static VOID setup_machine_signature(VOID);
static VOID setupEfiConfigurationTable(VOID);
static EFI_STATUS EFI_FindAcpiTables(VOID);
static VOID efi_setupDeviceProperties(Node *node);
/*==========================================================================
* Utility function to make a device tree string from an EFI_GUID
/* Info About the current Firmware */
#define FIRMWARE_MAINTENER "cparm, armelcadetpetit@gmail.com"
static EFI_CHAR16 const FIRMWARE_NAME[] = {'M','a','s','h','e','r','b','r','u','m','-','2', 0};
static EFI_UINT32 const FIRMWARE_REVISION = 0x00010800; //1.8
static EFI_CHAR16 const FIRMWARE_NAME[] = {'M','a','s','h','e','r','b','r','u','m','-','2','.','1', 0};
static EFI_UINT32 const FIRMWARE_REVISION = 0x00020100; //2.1
static EFI_UINT32 const DEVICE_SUPPORTED = 0x00000001;
/* Default platform system_id (fix by IntVar) */
static EFI_CHAR8 const SYSTEM_ID[] = "0123456789ABCDEF"; //random value gen by uuidgen
/* Just a ret instruction */
static uint8_t const VOIDRET_INSTRUCTIONS[] = {0xc3};
}
}
void finalizeEFIConfigTable(void )
static VOID efi_setupDeviceProperties(Node *node)
{
const char *val;
uint8_t *binStr;
uint8_t *kbinStr;
int cnt = 0, cnt2 = 0;
static char DEVICE_PROPERTIES_PROP[] = "device-properties";
EFI_STATUS ret = EFI_NO_MEDIA;
execute_hook("setupDeviceProperties", node, &ret, NULL, NULL, NULL, NULL);
if (ret != EFI_SUCCESS)
{
/*
* Use the static "device-properties" boot config key contents if available
*/
if (!getValueForKey(kDeviceProperties, &val, &cnt, DEFAULT_BOOT_CONFIG))
{
return;
}
if (cnt > 1)
{
binStr = convertHexStr2Binary(val, &cnt2);
if (cnt2 > 0)
{
kbinStr = (uint8_t*)AllocateKernelMemory(cnt2);
if (kbinStr)
{
bcopy(binStr,kbinStr,cnt2);
DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, kbinStr);
}
}
}
}
}
void finalizeEFIConfigTable(void)
{
if (get_env(envarchCpuType) == CPU_TYPE_I386)
{
// unable to determine UUID for host. Error: 35 fix
// Rek: new SMsystemid option conforming to smbios notation standards, this option should
// belong to smbios config only ...
EFI_CHAR8*ret = getUUIDFromString(getStringForKey(kSystemID, DEFAULT_BOOT_CONFIG));
EFI_CHAR8*ret = NULL;
uuid_t uuid;
{
bool value = false;
if (getBoolForKey( kRandomSystemID, &value, DEFAULT_BOOT_CONFIG ) && value)
{
uuid_generate_random(uuid);
ret = (EFI_CHAR8*)uuid;
if (ret) goto out;
}
}
{
const char *user_uuid = getStringForKey(kSystemID, DEFAULT_BOOT_CONFIG);
if (user_uuid)
{
ret = getUUIDFromString(user_uuid);
}
}
if (!ret) // try bios dmi info UUID extraction
ret = getSmbiosUUID();
if (!ret)
{
// no bios dmi UUID available, set a fixed value for system-id
ret=getUUIDFromString((const char*) SYSTEM_ID);
// no bios dmi UUID available, get random uuid
uuid_generate_random(uuid);
ret = (EFI_CHAR8*)uuid;
verbose("Customizing SystemID with : %s\n", getStringFromUUID(ret)); // apply a nice formatting to the displayed output
}
else
}
out:
if (ret)
{
{
memcpy(sysid, ret, UUID_LEN);
set_env_copy(envSysId, sysid, sizeof(sysid));
}
static VOID setupSystemType(VOID)
{
Node *node = DT__FindNode("/", false);
if (node == 0) stop("Couldn't get root node");
if (node == 0)
{
stop("Couldn't get root node");
return;
}
// we need to write this property after facp parsing
// Export system-type only if it has been overrriden by the SystemType option
kType = get_env(envType);
node = DT__FindNode("/", false);
if (node == 0) stop("Couldn't get root node");
if (node == 0)
{
stop("Couldn't get root node");
return;
}
#ifndef NO_BOOT_IMG
{
}
// Fill /efi/device-properties node.
setupDeviceProperties(efiNode);
efi_setupDeviceProperties(efiNode);
}
/*
void setupFakeEfi(void)
{
// Collect PCI info &| Generate device prop string
setup_pci_devs(root_pci_dev);
setup_root_pci_devs();
// load smbios.plist file if any
setupSmbiosConfigFile("SMBIOS.plist");
branches/cparm/i386/boot2/graphics.c
143143
144144
145145
146
147146
148147
149148
150149
151
152150
153151
154152
// Clear output mode info.
//bzero( outModeInfo, sizeof(*outModeInfo) );
bzero( outModeInfo, sizeof(VBEModeInfoBlock) );
// Get VBE controller info containing the list of supported modes.
//bzero( &vbeInfo, sizeof(vbeInfo) );
bzero( &vbeInfo, sizeof(VBEInfoBlock) );
strlcpy( (char*)&vbeInfo, "VBE2", sizeof(VBEInfoBlock) );
branches/cparm/i386/boot2/boot.c
407407
408408
409409
410
410411
411
412
412413
413414
414415
......
419420
420421
421422
422
423
423424
424425
425426
426427
427
428
428429
429430
430431
......
899900
900901
901902
902
903
903904
904905
905906
// Scan and record the system's hardware information.
scan_platform();
// Pseudo-random generator initialization.
arc4_init();
// arc4_init();
set_env(envgBIOSDev, (BIOSDev = biosdev & kBIOSDevMask));
set_env(envShouldboot, false);
set_env(envgHaveKernelCache, false);
InitBootPrompt();
// First get info for boot volume.
scanBootVolumes(BIOSDev, 0);
bvChain = getBVChainForBIOSDev(BIOSDev);
setBootGlobals(bvChain);
// Load Booter boot.plist config file
SetgRootPath(platformInfo->rootPath);
#endif
Adler32 = OSSwapHostToBigInt32(adler32((unsigned char *)platformInfo, sizeof(*platformInfo)));
Adler32 = OSSwapHostToBigInt32(adler32((unsigned char *)platformInfo, sizeof(PlatformInfo)));
safe_set_env(envAdler32, Adler32);
free(platformInfo);
branches/cparm/i386/boot2/drivers.c
129129
130130
131131
132
132133
134
135
133136
134137
135138
gFileName = malloc( DEFAULT_DRIVER_SPEC_SIZE );
if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName )
{
stop("InitDriverSupport error");
return -1;
}
DriverSet = true;
set_env(envDriverExtSpec,(uint32_t)gExtensionsSpec);
branches/cparm/i386/boot2/options.c
561561
562562
563563
564
564
565565
566566
567567
setCursorPosition(0, 0, 1);
}
dump_pci_dt(root_pci_dev->children);
dump_pci_dt(((pci_dt_t *)(uint32_t)get_env(envPCIRootDev))->children);
pause();
branches/cparm/i386/modules/RamDiskLoader/ramdisk.c
130130
131131
132132
133
134
135
136
133137
134138
135139
{
// Release ramdisk BVRef and DiskBVMap.
struct DiskBVMap *oldMap = diskResetBootVolumes(0x100);
if (oldMap == NULL)
{
return;
}
CacheReset();
diskFreeMap(oldMap);
branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c
6464
6565
6666
67
6768
6869
6970
void YellowIconFixer_start(void);
void YellowIconFixer_start(void)
{
register_device_inject();
register_hook_callback("PCIDevice", &SATA_hook);
}
branches/cparm/i386/modules/YellowIconFixer/Makefile
5858
5959
6060
61
61
6262
6363
6464
......
8484
8585
8686
87
87
8888
8989
9090
......
118118
119119
120120
121
122
123
124
121125
122126
123127
VPATH = $(OBJROOT):$(SYMROOT)
SATA_OBJS = YellowIconFixer.o stack_protector.o
SATA_OBJS = YellowIconFixer.o device_inject.o stack_protector.o
SFILES =
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
-macosx_version_min 10.6 \
$(OBJROOT)/stack_protector.o $(OBJROOT)/YellowIconFixer.o -o $(SYMROOT)/$(BUNDLE_EXEC)
$(OBJROOT)/stack_protector.o $(OBJROOT)/device_inject.o $(OBJROOT)/YellowIconFixer.o -o $(SYMROOT)/$(BUNDLE_EXEC)
@rm -rf $(SYMROOT)/$(BUNDLE_NAME).bundle
@mkdir $(SYMROOT)/$(BUNDLE_NAME).bundle
@mkdir $(SYMROOT)/$(BUNDLE_NAME).bundle/Contents
YellowIconFixer.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "YellowIconFixer.c" $(INC) -o "$(OBJROOT)/YellowIconFixer.o"
device_inject.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/device_inject.c" $(INC) -o "$(OBJROOT)/device_inject.o"
include ../../MakeInc.dir
# dependencies
branches/cparm/i386/modules/GUI/graphic_utils.c
486486
487487
488488
489
490489
491490
492491
493492
494
495493
496494
497495
// Clear output mode info.
//bzero( outModeInfo, sizeof(*outModeInfo) );
bzero( outModeInfo, sizeof(VBEModeInfoBlock) );
// Get VBE controller info containing the list of supported modes.
//bzero( &vbeInfo, sizeof(vbeInfo) );
bzero( &vbeInfo, sizeof(VBEInfoBlock) );
strlcpy( (char*)&vbeInfo, "VBE2", sizeof(VBEInfoBlock) );
branches/cparm/i386/modules/KernelPatcher/kernel_patcher.c
88
99
1010
11
12
13
14
15
16
17
18
19
20
1121
1222
1323
......
1727
1828
1929
30
31
2032
2133
2234
......
219231
220232
221233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
222538
223539
224540
......
226542
227543
228544
229
545
230546
231547
232548
#include "platform.h"
#include "modules.h"
#ifndef DEBUG_KERNEL_PATCHER
#define DEBUG_KERNEL_PATCHER 0
#endif
#if DEBUG_KERNEL_PATCHER
#define DBG(x...)printf(x)
#else
#define DBG(x...)
#endif
long long symbol_handler(char* module, char* symbolName, long long addr, char is64);
patchRoutine_t* patches = NULL;
static kernSymbols_t* lookup_kernel_symbol(const char* name);
static int determineKernelArchitecture(void* kernelData);
static int locate_symbols(void* kernelData);
static unsigned int parse_mach_64(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long, char));
static unsigned int handle_symtable_64(char *module, UInt32 base, struct symtab_command* symtabCommand, long long(*symbol_handler)(char*, char*, long long, char), char is64);
/*
* Internal patches provided by this module.
}
}
static unsigned int parse_mach_64(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long, char))// TODO: add param to specify valid archs
{
char is64 = false;
unsigned int module_start = 0xFFFFFFFF;
EFI_STATUS bind_status = EFI_SUCCESS;
// TODO convert all of the structs to a union
struct dyld_info_command* dyldInfoCommand = NULL;
struct symtab_command* symtabCommand = NULL;
{
struct segment_command *segCommand = NULL;
struct segment_command_64 *segCommand64 = NULL;
struct load_command *loadCommand = NULL;
UInt32 binaryIndex = 0;
UInt16 cmd = 0;
// Parse through the load commands
if(((struct mach_header*)binary)->magic == MH_MAGIC)
{
is64 = false;
binaryIndex += sizeof(struct mach_header);
}
else if(((struct mach_header_64*)binary)->magic == MH_MAGIC_64)
{
// NOTE: modules cannot be 64bit...
is64 = true;
binaryIndex += sizeof(struct mach_header_64);
}
else
{
printf("Modules: Invalid mach magic\n");
getc();
return 0xFFFFFFFF;
}
/*if(((struct mach_header*)binary)->filetype != MH_DYLIB)
{
printf("Module is not a dylib. Unable to load.\n");
getc();
return NULL; // Module is in the incorrect format
}*/
while(cmd < ((struct mach_header*)binary)->ncmds)
{
cmd++;
loadCommand = binary + binaryIndex;
UInt32 cmdSize = loadCommand->cmdsize;
switch ((loadCommand->cmd & 0x7FFFFFFF))
{
case LC_SYMTAB:
symtabCommand = binary + binaryIndex;
break;
case LC_SEGMENT: // 32bit macho
{
segCommand = binary + binaryIndex;
//printf("Segment name is %s\n", segCommand->segname);
if(strncmp("__TEXT", segCommand->segname, sizeof("__TEXT")) == 0)
{
UInt32 sectionIndex;
#if DEBUG_KERNEL_PATCHER
unsigned long fileaddr;
long filesize;
vmaddr = (segCommand->vmaddr & 0x3fffffff);
vmsize = segCommand->vmsize;
fileaddr = ((unsigned long)(binary + binaryIndex) + segCommand->fileoff);
filesize = segCommand->filesize;
printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n",
segCommand->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize,
(unsigned) segCommand->nsects, (unsigned)segCommand->flags);
#if DEBUG_KERNEL_PATCHER==2
getc();
#endif
#endif
sectionIndex = sizeof(struct segment_command);
struct section *sect;
while(sectionIndex < segCommand->cmdsize)
{
sect = binary + binaryIndex + sectionIndex;
sectionIndex += sizeof(struct section);
if(strncmp("__text", sect->sectname,sizeof("__text")) == 0)
{
// __TEXT,__text found, save the offset and address for when looking for the calls.
textSection = sect->offset;
textAddress = sect->addr;
break;
}
}
}
break;
}
case LC_SEGMENT_64:// 64bit macho's
{
segCommand64 = binary + binaryIndex;
//printf("Segment name is %s\n", segCommand->segname);
if(strncmp("__TEXT", segCommand64->segname, sizeof("__TEXT")) == 0)
{
UInt32 sectionIndex;
#if DEBUG_KERNEL_PATCHER
unsigned long fileaddr;
long filesize;
vmaddr = (segCommand64->vmaddr & 0x3fffffff);
vmsize = segCommand64->vmsize;
fileaddr = ((unsigned long)(binary + binaryIndex) + segCommand64->fileoff);
filesize = segCommand64->filesize;
printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n",
segCommand64->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize,
(unsigned) segCommand64->nsects, (unsigned)segCommand64->flags);
#if DEBUG_KERNEL_PATCHER==2
getc();
#endif
#endif
sectionIndex = sizeof(struct segment_command_64);
struct section_64 *sect;
while(sectionIndex < segCommand64->cmdsize)
{
sect = binary + binaryIndex + sectionIndex;
sectionIndex += sizeof(struct section_64);
if(strncmp("__text", sect->sectname, sizeof("__text")) == 0)
{
// __TEXT,__text found, save the offset and address for when looking for the calls.
textSection = sect->offset;
textAddress = sect->addr;
break;
}
}
}
break;
}
case LC_DYSYMTAB:
break;
case LC_LOAD_DYLIB:
case LC_LOAD_WEAK_DYLIB ^ LC_REQ_DYLD:
break;
case LC_ID_DYLIB:
break;
case LC_DYLD_INFO:
// Bind and rebase info is stored here
dyldInfoCommand = binary + binaryIndex;
break;
case LC_UUID:
break;
case LC_UNIXTHREAD:
break;
default:
DBG("Unhandled loadcommand 0x%X\n", loadCommand->cmd & 0x7FFFFFFF);
break;
}
binaryIndex += cmdSize;
}
//if(!moduleName) return NULL;
}
// bind_macho uses the symbols.
module_start = handle_symtable_64(module, (UInt32)binary, symtabCommand, symbol_handler, is64);
// Rebase the module before binding it.
if(dyldInfoCommand && dyldInfoCommand->rebase_off)
{
rebase_macho(binary, (char*)dyldInfoCommand->rebase_off, dyldInfoCommand->rebase_size);
}
if(dyldInfoCommand && dyldInfoCommand->bind_off)
{
bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->bind_off, dyldInfoCommand->bind_size);
}
if(dyldInfoCommand && dyldInfoCommand->weak_bind_off && (bind_status == EFI_SUCCESS))
{
// NOTE: this currently should never happen.
bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->weak_bind_off, dyldInfoCommand->weak_bind_size);
}
if(dyldInfoCommand && dyldInfoCommand->lazy_bind_off && (bind_status == EFI_SUCCESS))
{
// NOTE: we are binding the lazy pointers as a module is laoded,
// This should be changed to bind when a symbol is referened at runtime instead.
bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->lazy_bind_off, dyldInfoCommand->lazy_bind_size);
}
if (bind_status != EFI_SUCCESS) {
module_start = 0xFFFFFFFF;
}
return module_start;
}
static unsigned int handle_symtable_64(char *module, UInt32 base, struct symtab_command* symtabCommand, long long(*symbol_handler)(char*, char*, long long, char), char is64)
{
unsigned int module_start = 0xFFFFFFFF;
UInt32 symbolIndex = 0;
if (!symtabCommand) {
return 0xFFFFFFFF;
}
char* symbolString = base + (char*)symtabCommand->stroff;
if(!is64)
{
struct nlist* symbolEntry = (void*)base + symtabCommand->symoff;
while(symbolIndex < symtabCommand->nsyms)
{
if(symbolEntry->n_value)
{
if(strstr(symbolString + symbolEntry->n_un.n_strx, "module_start") || (strncmp(symbolString + symbolEntry->n_un.n_strx, "start", sizeof("start")) == 0))
{
module_start = base + symbolEntry->n_value;
DBG("n_value %x module_start %x\n", (unsigned)symbolEntry->n_value, (unsigned)module_start);
}
else
{
symbol_handler(module, symbolString + symbolEntry->n_un.n_strx, (long long)base + symbolEntry->n_value, is64);
}
#if DEBUG_KERNEL_PATCHER
bool isTexT = (((unsigned)symbolEntry->n_value > (unsigned)vmaddr) && ((unsigned)(vmaddr + vmsize) > (unsigned)symbolEntry->n_value ));
printf("%s %s\n", isTexT ? "__TEXT :" : "__DATA(OR ANY) :", symbolString + symbolEntry->n_un.n_strx);
#if DEBUG_KERNEL_PATCHER==2
if(strcmp(symbolString + symbolEntry->n_un.n_strx, "_BootHelp_txt") == 0)
{
long long addr = (long long)base + symbolEntry->n_value;
unsigned char *BootHelp = NULL;
BootHelp = (unsigned char*)(UInt32)addr;
printf("method 1: __DATA : BootHelp_txt[0] %x\n", BootHelp[0]);
long long addr2 = symbolEntry->n_value;
unsigned char *BootHelp2 = NULL;
BootHelp2 = (unsigned char*)(UInt32)addr2;
printf("method 2: __DATA : BootHelp_txt[0] %x\n", BootHelp2[0]);
}
#endif
#endif
}
symbolEntry++;
symbolIndex++;// TODO remove
}
}
else
{
struct nlist_64* symbolEntry = (void*)base + symtabCommand->symoff;
// NOTE First entry is *not* correct, but we can ignore it (i'm getting radar:// right now)
while(symbolIndex < symtabCommand->nsyms)
{
if(strstr(symbolString + symbolEntry->n_un.n_strx, "module_start") || (strncmp(symbolString + symbolEntry->n_un.n_strx, "start",sizeof("start")) == 0))
{
module_start = (unsigned int)(base + symbolEntry->n_value);
}
else
{
symbol_handler(module, symbolString + symbolEntry->n_un.n_strx, (long long)base + symbolEntry->n_value, is64);
}
symbolEntry++;
symbolIndex++;// TODO remove
}
}
return module_start;
}
/**
**This functions located the requested symbols in the mach-o file.
**as well as determines the start of the __TEXT segment and __TEXT,__text sections
static int locate_symbols(void* kernelData)
{
char is64 = 1;
parse_mach("VirtualXnuSyms",kernelData, symbol_handler);
parse_mach_64("VirtualXnuSyms",kernelData, symbol_handler);
//handle_symtable((UInt32)kernelData, symtableData, &symbol_handler, determineKernelArchitecture(kernelData) == KERNEL_64);
return 1 << is64;
}
branches/cparm/i386/modules/Networking/Networking.c
99
1010
1111
12
1213
1314
1415
......
6364
6465
6566
67
6668
6769
6870
#include "pci.h"
#include "device_inject.h"
#include "platform.h"
#include "fake_efi.h"
#ifndef DEBUG_ETHERNET
#define DEBUG_ETHERNET 0
void Networking_start(void);
void Networking_start(void)
{
register_device_inject();
register_hook_callback("PCIDevice", &Networking_hook);
}
branches/cparm/i386/modules/Networking/Makefile
5858
5959
6060
61
61
6262
6363
6464
......
8484
8585
8686
87
87
8888
8989
9090
......
118118
119119
120120
121
122
123
124
121125
122126
123127
VPATH = $(OBJROOT):$(SYMROOT)
NET_OBJS = Networking.o stack_protector.o
NET_OBJS = Networking.o device_inject.o stack_protector.o
SFILES =
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
-macosx_version_min 10.6 \
$(OBJROOT)/stack_protector.o $(OBJROOT)/Networking.o -o $(SYMROOT)/$(BUNDLE_EXEC)
$(OBJROOT)/stack_protector.o $(OBJROOT)/device_inject.o $(OBJROOT)/Networking.o -o $(SYMROOT)/$(BUNDLE_EXEC)
@rm -rf $(SYMROOT)/$(BUNDLE_NAME).bundle
@mkdir $(SYMROOT)/$(BUNDLE_NAME).bundle
@mkdir $(SYMROOT)/$(BUNDLE_NAME).bundle/Contents
Networking.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "Networking.c" $(INC) -o "$(OBJROOT)/Networking.o"
device_inject.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/device_inject.c" $(INC) -o "$(OBJROOT)/device_inject.o"
include ../../MakeInc.dir
# dependencies
branches/cparm/i386/modules/GraphicsEnabler/GraphicsEnabler.c
1212
1313
1414
15
1516
1617
1718
......
1920
2021
2122
23
2224
2325
2426
#include "ati.h"
#include "gma.h"
#include "modules.h"
#include "device_inject.h"
void GraphicsEnabler_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
void GraphicsEnabler_start(void)
{
register_device_inject();
register_hook_callback("PCIDevice", &GraphicsEnabler_hook);
}
branches/cparm/i386/modules/GraphicsEnabler/Makefile
5858
5959
6060
61
61
6262
6363
6464
......
8484
8585
8686
87
8788
8889
8990
......
130131
131132
132133
134
135
136
137
133138
134139
135140
VPATH = $(OBJROOT):$(SYMROOT)
GRAPHICS_ENABLER_OBJS = nvidia.o ati.o gma.o GraphicsEnabler.o stack_protector.o
GRAPHICS_ENABLER_OBJS = nvidia.o ati.o gma.o GraphicsEnabler.o device_inject.o stack_protector.o
SFILES =
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
$(OBJROOT)/stack_protector.o \
$(OBJROOT)/device_inject.o \
$(OBJROOT)/nvidia.o \
$(OBJROOT)/ati.o \
$(OBJROOT)/gma.o \
gma.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "gma.c" $(INC) -o "$(OBJROOT)/gma.o"
device_inject.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "$(LIBSAIODIR)/device_inject.c" $(INC) -o "$(OBJROOT)/device_inject.o"
include ../../MakeInc.dir
# dependencies
branches/cparm/i386/modules/HibernateEnabler/graphic_utils.c
180180
181181
182182
183
184183
185184
186185
187186
188
189187
190188
191189
// Clear output mode info.
//bzero( outModeInfo, sizeof(*outModeInfo) );
bzero( outModeInfo, sizeof(VBEModeInfoBlock) );
// Get VBE controller info containing the list of supported modes.
//bzero( &vbeInfo, sizeof(vbeInfo) );
bzero( &vbeInfo, sizeof(VBEInfoBlock) );
strlcpy( (char*)&vbeInfo, "VBE2", sizeof(VBEInfoBlock) );
branches/cparm/i386/modules/Keymapper/Keylayout.c
111111
112112
113113
114
114
115115
116116
117117
118118
119119
120
120
121121
122122
123123
if (current_layout)
free(current_layout);
current_layout = malloc(sizeof(*current_layout));
current_layout = malloc(sizeof(struct keyboard_layout));
if (!current_layout)
goto fail;
key_b_lseek(fd, KEYBOARD_LAYOUTS_MAP_OFFSET, 0);
if (read(fd, (char*) current_layout, sizeof(*current_layout)) != sizeof(*current_layout)) {
if (read(fd, (char*) current_layout, sizeof(struct keyboard_layout)) != sizeof(struct keyboard_layout)) {
printf("Wrong keyboard layout file %s size\n", filename);
goto fail;
}
branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
923923
924924
925925
926
926
927927
928928
929929
......
13611361
13621362
13631363
1364
1364
13651365
13661366
13671367
ret->anchor[1] = 0x53;
ret->anchor[2] = 0x4d;
ret->anchor[3] = 0x5f;
ret->entryPointLength = sizeof(*ret);
ret->entryPointLength = sizeof(struct SMBEntryPoint);
ret->majorVersion = 2;
ret->minorVersion = 1;
ret->maxStructureSize = 0; // will be calculated later in this function
newsmbios->dmi.checksum = 0;
newsmbios->dmi.checksum = 256 - checksum8(&newsmbios->dmi, sizeof(newsmbios->dmi));
newsmbios->checksum = 0;
newsmbios->checksum = 256 - checksum8(newsmbios, sizeof(*newsmbios));
newsmbios->checksum = 256 - checksum8(newsmbios, sizeof(struct SMBEntryPoint));
if (!done) {
verbose("Patched DMI Table\n");
branches/cparm/i386/modules/ACPICodec/acpi_codec.c
379379
380380
381381
382
383
384
382385
383386
384387
......
493496
494497
495498
499
500
496501
497502
498503
......
516521
517522
518523
519
524
520525
521526
522527
......
703708
704709
705710
706
711
707712
708713
709714
......
37163721
37173722
37183723
3724
3725
37193726
37203727
37213728
......
45544561
45554562
45564563
4557
4564
4565
45584566
45594567
45604568
{
U64 ptr = xsdt->TableOffsetEntry[index];
if (!ptr) continue;
{
if (ptr > ULONG_MAX)
{
for (index=0;index<num_tables;index++)
{
if (!table_array[index]) continue;
{
#if DEBUG_ACPI
printf("* Processing : ");
}
{
{
if (*(U32 *) (table_array[index]->Signature) == NAMESEG(ACPI_SIG_FADT))
{
ACPI_TABLE_FADT *FacpPointer = ((ACPI_TABLE_FADT*)table_array[index]);
current = (U8 *) DsdtPointer;
current = decodeTableHeader(current, &header);
end = current - sizeof(*header) + header->Length;
end = current - sizeof(ACPI_TABLE_HEADER) + header->Length;
ns.depth = 0;
acpi_processor_count = 0;
//DBG("* DSDT debug start\n");
return(0);
}
bzero(&cpu, sizeof(CPU_DETAILS));
collect_cpu_info(&cpu);
if (enable_cstates && pmbase)
for (index = 0; index < num_tables; index++)
{
if (!table_array[index]) continue;
{
int method = 0;
branches/cparm/i386/util/fdisk/cmd.c
202202
203203
204204
205
205
206206
207207
208208
/* Unused, so just zero out */
if (pp->id == DOSPTYP_UNUSED) {
memset(pp, 0, sizeof(*pp));
memset(pp, 0, sizeof(prt_t));
printf("Partition %d is disabled.\n", pn + 1);
return (ret);
}
branches/cparm/i386/util/fdisk/part.c
241241
242242
243243
244
244
245245
246246
247247
......
353353
354354
355355
356
356
357357
358358
359359
......
390390
391391
392392
393
393
394394
395395
396396
/* Zero out entry if not used */
if (partn->id == DOSPTYP_UNUSED ) {
memset(partn, 0, sizeof(*partn));
memset(partn, 0, sizeof(prt_t));
}
}
/* Zero out entry if not used */
if (part->id == DOSPTYP_UNUSED ) {
memset(part, 0, sizeof(*part));
memset(part, 0, sizeof(prt_t));
return;
}
/* Zero out entry if not used */
if (part->id == DOSPTYP_UNUSED ) {
memset(part, 0, sizeof(*part));
memset(part, 0, sizeof(prt_t));
return;
}
branches/cparm/i386/util/fdisk/auto.c
4444
4545
4646
47
48
49
47
48
49
5050
51
52
53
54
55
56
57
51
52
53
54
55
56
57
5858
5959
6060
6161
6262
63
64
65
66
67
68
63
64
65
66
67
68
6969
7070
7171
7272
7373
7474
75
76
77
78
79
80
81
82
83
84
75
76
77
78
79
80
81
82
83
84
8585
8686
8787
8888
8989
9090
91
92
93
94
95
96
91
92
93
94
95
96
9797
9898
9999
100100
101101
102102
103
104
105
106
107
108
103
104
105
106
107
108
109109
110110
111111
112112
113113
114114
115
116
117
118
119
120
115
116
117
118
119
120
121121
122122
123123
124124
125125
126126
127
128
129
130
131
132
127
128
129
130
131
132
133133
134134
135135
136136
137137
138138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161161
162162
163163
164164
165165
166166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189189
190190
191191
192192
193193
194194
195
195
196196
197197
/* The default style is the first one in the list */
struct _auto_style {
char *style_name;
int (*style_fn)(disk_t *, mbr_t *);
char *description;
char *style_name;
int (*style_fn)(disk_t *, mbr_t *);
char *description;
} style_fns[] = {
{"boothfs", AUTO_boothfs, "8Mb boot plus HFS+ root partition"},
{"bootufs", AUTO_bootufs, "8Mb boot plus UFS root partition"},
{"hfs", AUTO_hfs, "Entire disk as one HFS+ partition"},
{"ufs", AUTO_ufs, "Entire disk as one UFS partition"},
{"dos", AUTO_dos, "Entire disk as one DOS partition"},
{"raid", AUTO_raid, "Entire disk as one 0xAC partition"},
{0,0}
{"boothfs", AUTO_boothfs, "8Mb boot plus HFS+ root partition"},
{"bootufs", AUTO_bootufs, "8Mb boot plus UFS root partition"},
{"hfs", AUTO_hfs, "Entire disk as one HFS+ partition"},
{"ufs", AUTO_ufs, "Entire disk as one UFS partition"},
{"dos", AUTO_dos, "Entire disk as one DOS partition"},
{"raid", AUTO_raid, "Entire disk as one 0xAC partition"},
{0,0}
};
void
AUTO_print_styles(FILE *f)
{
struct _auto_style *fp;
int i;
for (i=0, fp = &style_fns[0]; fp->style_name != NULL; i++, fp++) {
fprintf(f, " %-10s %s%s\n", fp->style_name, fp->description, (i==0) ? " (default)" : "");
}
struct _auto_style *fp;
int i;
for (i=0, fp = &style_fns[0]; fp->style_name != NULL; i++, fp++) {
fprintf(f, " %-10s %s%s\n", fp->style_name, fp->description, (i==0) ? " (default)" : "");
}
}
int
AUTO_init(disk_t *disk, char *style, mbr_t *mbr)
{
struct _auto_style *fp;
for (fp = &style_fns[0]; fp->style_name != NULL; fp++) {
/* If style is NULL, use the first (default) style */
if (style == NULL || strcasecmp(style, fp->style_name) == 0) {
return (*fp->style_fn)(disk, mbr);
}
}
warnx("No such auto-partition style %s", style);
return AUTO_ERR;
struct _auto_style *fp;
for (fp = &style_fns[0]; fp->style_name != NULL; fp++) {
/* If style is NULL, use the first (default) style */
if (style == NULL || strcasecmp(style, fp->style_name) == 0) {
return (*fp->style_fn)(disk, mbr);
}
}
warnx("No such auto-partition style %s", style);
return AUTO_ERR;
}
static int
use_whole_disk(disk_t *disk, unsigned char id, mbr_t *mbr)
{
MBR_clear(mbr);
mbr->part[0].id = id;
mbr->part[0].bs = 63;
mbr->part[0].ns = disk->real->size - 63;
PRT_fix_CHS(disk, &mbr->part[0], 0);
return AUTO_OK;
MBR_clear(mbr);
mbr->part[0].id = id;
mbr->part[0].bs = 63;
mbr->part[0].ns = disk->real->size - 63;
PRT_fix_CHS(disk, &mbr->part[0], 0);
return AUTO_OK;
}
/* DOS style: one partition for the whole disk */
int
AUTO_dos(disk_t *disk, mbr_t *mbr)
{
int cc;
cc = use_whole_disk(disk, 0x0C, mbr);
if (cc == AUTO_OK) {
mbr->part[0].flag = DOSACTIVE;
}
return cc;
int cc;
cc = use_whole_disk(disk, 0x0C, mbr);
if (cc == AUTO_OK) {
mbr->part[0].flag = DOSACTIVE;
}
return cc;
}
/* HFS style: one partition for the whole disk */
int
AUTO_hfs(disk_t *disk, mbr_t *mbr)
{
int cc;
cc = use_whole_disk(disk, 0xAF, mbr);
if (cc == AUTO_OK) {
mbr->part[0].flag = DOSACTIVE;
}
return cc;
int cc;
cc = use_whole_disk(disk, 0xAF, mbr);
if (cc == AUTO_OK) {
mbr->part[0].flag = DOSACTIVE;
}
return cc;
}
/* UFS style: one partition for the whole disk */
int
AUTO_ufs(disk_t *disk, mbr_t *mbr)
{
int cc;
cc = use_whole_disk(disk, 0xA8, mbr);
if (cc == AUTO_OK) {
mbr->part[0].flag = DOSACTIVE;
}
return cc;
int cc;
cc = use_whole_disk(disk, 0xA8, mbr);
if (cc == AUTO_OK) {
mbr->part[0].flag = DOSACTIVE;
}
return cc;
}
/* One boot partition, one HFS+ root partition */
int
AUTO_boothfs (disk_t *disk, mbr_t *mbr)
{
/* Check disk size. */
if (disk->real->size < 16 * 2048) {
errx(1, "Disk size must be greater than 16Mb");
return AUTO_ERR;
}
MBR_clear(mbr);
/* 8MB boot partition */
mbr->part[0].id = 0xAB;
mbr->part[0].bs = 63;
mbr->part[0].ns = 8 * 1024 * 2;
mbr->part[0].flag = DOSACTIVE;
PRT_fix_CHS(disk, &mbr->part[0], 0);
/* Rest of the disk for rooting */
mbr->part[1].id = 0xAF;
mbr->part[1].bs = (mbr->part[0].bs + mbr->part[0].ns);
mbr->part[1].ns = disk->real->size - mbr->part[0].ns - 63;
PRT_fix_CHS(disk, &mbr->part[1], 1);
return AUTO_OK;
/* Check disk size. */
if (disk->real->size < 16 * 2048) {
errx(1, "Disk size must be greater than 16Mb");
return AUTO_ERR;
}
MBR_clear(mbr);
/* 8MB boot partition */
mbr->part[0].id = 0xAB;
mbr->part[0].bs = 63;
mbr->part[0].ns = 8 * 1024 * 2;
mbr->part[0].flag = DOSACTIVE;
PRT_fix_CHS(disk, &mbr->part[0], 0);
/* Rest of the disk for rooting */
mbr->part[1].id = 0xAF;
mbr->part[1].bs = (mbr->part[0].bs + mbr->part[0].ns);
mbr->part[1].ns = disk->real->size - mbr->part[0].ns - 63;
PRT_fix_CHS(disk, &mbr->part[1], 1);
return AUTO_OK;
}
/* One boot partition, one UFS root partition */
int
AUTO_bootufs(disk_t *disk, mbr_t *mbr)
{
/* Check disk size. */
if (disk->real->size < 16 * 2048) {
errx(1, "Disk size must be greater than 16Mb");
return AUTO_ERR;
}
MBR_clear(mbr);
/* 8MB boot partition */
mbr->part[0].id = 0xAB;
mbr->part[0].bs = 63;
mbr->part[0].ns = 8 * 1024 * 2;
mbr->part[0].flag = DOSACTIVE;
PRT_fix_CHS(disk, &mbr->part[0], 0);
/* Rest of the disk for rooting */
mbr->part[1].id = 0xA8;
mbr->part[1].bs = (mbr->part[0].bs + mbr->part[0].ns);
mbr->part[1].ns = disk->real->size - mbr->part[0].ns - 63;
PRT_fix_CHS(disk, &mbr->part[1], 1);
return AUTO_OK;
/* Check disk size. */
if (disk->real->size < 16 * 2048) {
errx(1, "Disk size must be greater than 16Mb");
return AUTO_ERR;
}
MBR_clear(mbr);
/* 8MB boot partition */
mbr->part[0].id = 0xAB;
mbr->part[0].bs = 63;
mbr->part[0].ns = 8 * 1024 * 2;
mbr->part[0].flag = DOSACTIVE;
PRT_fix_CHS(disk, &mbr->part[0], 0);
/* Rest of the disk for rooting */
mbr->part[1].id = 0xA8;
mbr->part[1].bs = (mbr->part[0].bs + mbr->part[0].ns);
mbr->part[1].ns = disk->real->size - mbr->part[0].ns - 63;
PRT_fix_CHS(disk, &mbr->part[1], 1);
return AUTO_OK;
}
/* RAID style: one 0xAC partition for the whole disk */
int
AUTO_raid(disk_t *disk, mbr_t *mbr)
{
return use_whole_disk(disk, 0xAC, mbr);
return use_whole_disk(disk, 0xAC, mbr);
}
branches/cparm/i386/util/fdisk/user.c
168168
169169
170170
171
171
172172
173173
174174
......
215215
216216
217217
218
218
219219
220220
221221
if (yn) {
strlcpy(cmd.cmd, "erase", sizeof(cmd.cmd));
cmd.args[0] = '\0';
st /* false positive ?? */ = Xerase(&cmd, disk, mbr, tt, offset);
Xerase(&cmd, disk, mbr, tt, offset);
modified = 1;
}
}
/* Write out MBR */
if (modified) {
if (st /*??*/ == CMD_SAVE) {
if (st == CMD_SAVE) {
int shared = 0;
printf("Writing current MBR to disk.\n");
fd = DISK_openshared(disk->name, O_RDWR, &shared);
branches/cparm/i386/util/md.c
566566
567567
568568
569
569570
570571
571572
fprintf(stderr, "%s: file = \"%s\" ", name, real_mak_name);
perror("stat");
fflush(stdout), fflush(stderr);
fclose(mak);
return NULL;
}
if (D_open)
branches/cparm/i386/util/amlsgn.m
5353
5454
5555
56
57
5658
5759
5860
5961
60
61
62
63
6264
6365
6466
#import <Foundation/Foundation.h>
#import <IOKit/IOReturn.h>
#include <uuid/uuid.h>
#include "Intel_Acpi/acpidecode.h"
#include "Intel_Acpi/ppmsetup.h"
unsigned long uuid32;
#define UUID_LEN16
#define UUID_STR_LEN UUID_LEN*2 + 8
#define UUID_LEN sizeof(uuid_t)
#define UUID_STR_LEN sizeof(uuid_string_t)
typedef int8_t EFI_CHAR8;
unsigned long

Archive Download the corresponding diff file

Revision: 2118