Chameleon

Chameleon Commit Details

Date:2010-01-15 07:19:34 (14 years 2 months ago)
Author:Rekursor
Commit:4
Parents: 3
Message:Updated my changes from my rek v2 version to my svn branch: - Added SystemID option permitting to change the System UUID to a fixed/reproduceable value. - Added the PciRoot autodetection feature imported from pcefi10.5 - Added i386/libsaio/pciroot.{c|h} and ./CHANGES files Then Merged with my previous v2 patch on RC4. Did Asere patches review, code refactoring, and first integration: Now features: - added MALLOC replacement from mallocs with malloc-error checking - added automatic "system-id" injection from dmi bios, also compatible with SystemID boot option and former SMUUID from smbios,plist - added "system-type' automatic injection (1=Desktop) plus override possibility with the new system-type option in bootConfig - added SMserial and SMproductname new options for smbios.plist - Fixed a bug during refactoring from original Asere patch where SystemID would not be converted to hex value if overriden
Changes:
A/branches/rekursor/CHANGES
A/branches/rekursor/i386/libsaio/pci_root.c
A/branches/rekursor/i386/libsaio/pci_root.h
M/branches/rekursor/i386/boot2/graphics.c
M/branches/rekursor/i386/libsaio/smbios_patcher.h
M/branches/rekursor/i386/libsaio/memory.c
M/branches/rekursor/i386/libsaio/ati.c
M/branches/rekursor/i386/libsaio/sys.c
M/branches/rekursor/i386/libsaio/device_tree.c
M/branches/rekursor/i386/libsaio/nbp.c
M/branches/rekursor/i386/libsaio/hfs.c
M/branches/rekursor/i386/boot2/drivers.c
M/branches/rekursor/i386/libsaio/device_tree.h
M/branches/rekursor/i386/libsaio/spd.c
M/branches/rekursor/i386/libsaio/hfs_compare.c
M/branches/rekursor/i386/libsaio/fake_efi.c
M/branches/rekursor/i386/libsa/zalloc.c
M/branches/rekursor/i386/libsaio/ufs.c
M/branches/rekursor/i386/libsaio/cache.c
M/branches/rekursor/i386/boot2/boot.c
M/branches/rekursor/i386/libsa/libsa.h
M/branches/rekursor/i386/libsaio/bootstruct.c
M/branches/rekursor/i386/libsaio/nvidia.c
M/branches/rekursor/i386/libsaio/ntfs.c
M/branches/rekursor/i386/libsaio/pci.c
M/branches/rekursor/i386/libsaio/ext2fs.c
M/branches/rekursor/i386/libsaio/stringTable.c
M/branches/rekursor/i386/libsaio/msdos.c
M/branches/rekursor/i386/boot2/bmdecompress.c
M/branches/rekursor/i386/boot2/gui.c
M/branches/rekursor/i386/libsaio/disk.c
M/branches/rekursor/i386/libsaio/device_inject.c
M/branches/rekursor/i386/libsaio/Makefile
M/branches/rekursor/i386/libsaio/saio_internal.h
M/branches/rekursor/i386/boot2/ramdisk.c
M/branches/rekursor/i386/boot2/options.c
M/branches/rekursor/i386/libsaio/xml.c
M/branches/rekursor/i386/libsaio/SMBIOS.h
M/branches/rekursor/i386/boot2/picopng.c
M/branches/rekursor/i386/libsaio/smbios_patcher.c

File differences

branches/rekursor/CHANGES
1
2
3
4
5
- Added SystemID option permitting to change the System UUID to a fixed/reproduceable value.
- Added the PciRoot autodetection feature imported from pcefi10.5
- Added automatic "system-id" injection from dmi bios, also compatible with SystemID boot option and former SMUUID from smbios,plist
- Added "system-type' automatic injection (1=Desktop) plus override possibility with the new system-type option in bootConfig
- Added SMserial and SMproductname new options for smbios.plist
branches/rekursor/i386/libsaio/xml.c
509509
510510
511511
512
512
513513
514514
515515
......
590590
591591
592592
593
593
594594
595595
596596
if (gTagsFree == 0)
{
#if USEMALLOC
tag = (TagPtr)malloc(kTagsPerBlock * sizeof(Tag));
tag = (TagPtr)MALLOC(kTagsPerBlock * sizeof(Tag));
#else
tag = (TagPtr)AllocateBootXMemory(kTagsPerBlock * sizeof(Tag));
#endif
if (symbol == 0)
{
#if USEMALLOC
symbol = (SymbolPtr)malloc(sizeof(Symbol) + 1 + strlen(string));
symbol = (SymbolPtr)MALLOC(sizeof(Symbol) + 1 + strlen(string));
#else
symbol = (SymbolPtr)AllocateBootXMemory(sizeof(Symbol) + 1 + strlen(string));
#endif
branches/rekursor/i386/libsaio/bootstruct.c
4848
4949
5050
51
52
51
52
5353
5454
5555
if ( !init_done )
{
bootArgs = (boot_args *)malloc(sizeof(boot_args));
bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t));
bootArgs = (boot_args *)MALLOC(sizeof(boot_args));
bootInfo = (PrivateBootInfo_t *)MALLOC(sizeof(PrivateBootInfo_t));
if (bootArgs == 0 || bootInfo == 0)
stop("Couldn't allocate boot info\n");
branches/rekursor/i386/libsaio/ext2fs.c
1919
2020
2121
22
22
2323
2424
2525
......
3838
3939
4040
41
41
}
void EX2GetDescription(CICell ih, char *str, long strMaxLen)
{
char * buf=malloc (EX2ProbeSize);
char * buf=MALLOC (EX2ProbeSize);
str[0]=0;
if (!buf)
return;
str[strMaxLen]=0;
strncpy (str, buf+0x478, min (strMaxLen, 16));
free (buf);
}
}
branches/rekursor/i386/libsaio/device_tree.c
6262
6363
6464
65
65
6666
6767
6868
6969
7070
71
71
7272
7373
7474
......
117117
118118
119119
120
120
121121
122122
123123
......
276276
277277
278278
279
279
280280
281281
282282
......
342342
343343
344344
345
345
346346
347347
348348
static Property *freeProperties, *allocedProperties;
Property *
DT__AddProperty(Node *node, char *name, uint32_t length, void *value)
DT__AddProperty(Node *node, const char * name, uint32_t length, void *value)
{
Property *prop;
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value);
if (freeProperties == NULL) {
void *buf = malloc(kAllocSize);
void *buf = MALLOC(kAllocSize);
int i;
DPRINTF("Allocating more free properties\n");
Node *node;
if (freeNodes == NULL) {
void *buf = malloc(kAllocSize);
void *buf = MALLOC(kAllocSize);
int i;
DPRINTF("Allocating more free nodes\n");
buf = 0;
} else {
if (*buffer_p == 0) {
buf = malloc(totalSize);
buf = MALLOC(totalSize);
} else {
buf = *buffer_p;
}
}
if (child == 0 && createIfMissing) {
DPRINTF("Creating node\n");
char *str = malloc(strlen(nameBuf) + 1);
char *str = MALLOC(strlen(nameBuf) + 1);
// XXX this will leak
strcpy(str, nameBuf);
branches/rekursor/i386/libsaio/hfs.c
154154
155155
156156
157
158
159
157
158
159
160160
161
161
162162
163163
164164
165
165
166166
167167
168168
......
596596
597597
598598
599
599
600600
601601
602602
......
728728
729729
730730
731
731
732732
733733
734734
......
866866
867867
868868
869
869
870870
871871
872872
}
#ifdef __i386__
if (!gTempStr) gTempStr = (char *)malloc(4096);
if (!gLinkTemp) gLinkTemp = (char *)malloc(64);
if (!gBTreeHeaderBuffer) gBTreeHeaderBuffer = (char *)malloc(512);
if (!gTempStr) gTempStr = (char *)MALLOC(4096);
if (!gLinkTemp) gLinkTemp = (char *)MALLOC(64);
if (!gBTreeHeaderBuffer) gBTreeHeaderBuffer = (char *)MALLOC(512);
if (!gHFSMdbVib) {
gHFSMdbVib = (char *)malloc(kBlockSize);
gHFSMdbVib = (char *)MALLOC(kBlockSize);
gHFSMDB = (HFSMasterDirectoryBlock *)gHFSMdbVib;
}
if (!gHFSPlusHeader) {
gHFSPlusHeader = (char *)malloc(kBlockSize);
gHFSPlusHeader = (char *)MALLOC(kBlockSize);
gHFSPlus = (HFSPlusVolumeHeader *)gHFSPlusHeader;
}
if (!gTempStr || !gLinkTemp || !gBTreeHeaderBuffer ||
}
nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize);
nodeBuf = (char *)malloc(nodeSize);
nodeBuf = (char *)MALLOC(nodeSize);
node = (BTNodeDescriptor *)nodeBuf;
index = *dirIndex % nodeSize;
curNode = SWAP_BE32(gBTHeaders[btree]->rootNode);
nodeSize = SWAP_BE16(gBTHeaders[btree]->nodeSize);
nodeBuf = (char *)malloc(nodeSize);
nodeBuf = (char *)MALLOC(nodeSize);
node = (BTNodeDescriptor *)nodeBuf;
while (1) {
}
if (extentBuffer == 0) {
extentBuffer = malloc(sizeofExtent * extentDensity);
extentBuffer = MALLOC(sizeofExtent * extentDensity);
if (extentBuffer == 0) return -1;
}
branches/rekursor/i386/libsaio/device_tree.h
2727
2828
2929
30
30
3131
3232
3333
extern Property *
DT__AddProperty(Node *node, char *name, uint32_t length, void *value);
DT__AddProperty(Node *node, const char * name, uint32_t length, void *value);
extern Node *
DT__AddChild(Node *parent, char *name);
branches/rekursor/i386/libsaio/spd.c
9292
9393
9494
95
95
9696
9797
9898
{
slot->InUse = YES;
slot->spd = malloc(spd_size);
slot->spd = MALLOC(spd_size);
if (slot->spd)
{
bzero(slot->spd, spd_size);
branches/rekursor/i386/libsaio/hfs_compare.c
3535
3636
3737
38
38
3939
4040
4141
static unsigned short *
UncompressStructure(struct compressed_block *bp, int count, int size)
{
unsigned short *out = malloc(size);
unsigned short *out = MALLOC(size);
unsigned short *op = out;
unsigned short data;
int i, j;
branches/rekursor/i386/libsaio/Makefile
4040
4141
4242
43
43
4444
4545
4646
freq_detect.o platform.o dsdt_patcher.o \
smbios_patcher.o fake_efi.o ext2fs.o \
hpet.o spd.o usb.o pci_setup.o \
device_inject.o nvidia.o ati.o
device_inject.o nvidia.o ati.o pci_root.o
SAIO_EXTERN_OBJS = console.o
branches/rekursor/i386/libsaio/ufs.c
127127
128128
129129
130
131
132
133
134
135
130
131
132
133
134
135
136136
137137
138138
......
168168
169169
170170
171
171
172172
173173
174174
gCurrentIH = 0;
#ifdef __i386__
if (!gULBuf) gULBuf = (char *) malloc(UFS_LABEL_SIZE);
if (!gFSBuf) gFSBuf = (char *) malloc(SBSIZE);
if (!gTempName) gTempName = (char *) malloc(MAXNAMLEN + 1);
if (!gTempName2) gTempName2 = (char *) malloc(MAXNAMLEN + 1);
if (!gRootInodePtr) gRootInodePtr = (InodePtr) malloc(sizeof(Inode));
if (!gFileInodePtr) gFileInodePtr = (InodePtr) malloc(sizeof(Inode));
if (!gULBuf) gULBuf = (char *) MALLOC(UFS_LABEL_SIZE);
if (!gFSBuf) gFSBuf = (char *) MALLOC(SBSIZE);
if (!gTempName) gTempName = (char *) MALLOC(MAXNAMLEN + 1);
if (!gTempName2) gTempName2 = (char *) MALLOC(MAXNAMLEN + 1);
if (!gRootInodePtr) gRootInodePtr = (InodePtr) MALLOC(sizeof(Inode));
if (!gFileInodePtr) gFileInodePtr = (InodePtr) MALLOC(sizeof(Inode));
if (!gULBuf || !gFSBuf || !gTempName || !gTempName2 ||
!gRootInodePtr || !gFileInodePtr) return -1;
#endif
gFragSize = gFS->fs_fsize;
gFragsPerBlock = gBlockSize / gFragSize;
if (gTempBlock != 0) free(gTempBlock);
gTempBlock = malloc(gBlockSize);
gTempBlock = MALLOC(gBlockSize);
CacheInit(ih, gBlockSize);
gCurrentIH = ih;
branches/rekursor/i386/libsaio/SMBIOS.h
3939
4040
4141
42
43
44
45
46
47
4248
4349
4450
typedef UInt32 SMBDWord;
typedef UInt64 SMBQWord;
struct DMIHeader {
SMBByte type;
SMBByte length;
SMBWord handle;
} __attribute__((packed));
struct DMIEntryPoint {
SMBByte anchor[5];
SMBByte checksum;
branches/rekursor/i386/libsaio/smbios_patcher.c
227227
228228
229229
230
230
231231
232232
233233
{.type=132,.len=0x06,.numfunc=sm_one}
};
static inline struct SMBEntryPoint * getAddressOfSmbiosTable()
struct SMBEntryPoint * getAddressOfSmbiosTable()
{
/* First see if we can even find the damn SMBIOS table
* The logic here is to start at 0xf0000 and end at 0xfffff iterating 16 bytes at a time looking
branches/rekursor/i386/libsaio/smbios_patcher.h
5353
5454
5555
56
5657
5758
int (*numfunc)(int tablen);
};
struct SMBEntryPoint * getAddressOfSmbiosTable();
#endif /* !__LIBSAIO_SMBIOS_PATCHER_H */
branches/rekursor/i386/libsaio/memory.c
3939
4040
4141
42
42
4343
4444
4545
46
46
4747
4848
4949
char *nameBuf;
uint32_t *buffer;
nameBuf = malloc(strlen(rangeName) + 1);
nameBuf = MALLOC(strlen(rangeName) + 1);
if (nameBuf == 0) return -1;
strcpy(nameBuf, rangeName);
buffer = malloc(2 * sizeof(uint32_t));
buffer = MALLOC(2 * sizeof(uint32_t));
if (buffer == 0) return -1;
buffer[0] = start;
branches/rekursor/i386/libsaio/pci_root.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Copyright 2009 netkas
*/
#include "libsaio.h"
#include "bootstruct.h"
#ifndef DEBUG_PCIROOT
#define DEBUG_PCIROOT 0
#endif
#if DEBUG_PCIROOT==1
#define DBG(x...) printf(x)
#else
#define DBG(x...)
#endif
int rootuid = 10; //value means function wasnt ran yet
unsigned int findrootuid(unsigned char * dsdt)
{
int i;
for (i=0; i<64; i++) //not far than 64 symbols from pci root
{
if(dsdt[i] == '_' && dsdt[i+1] == 'U' && dsdt[i+2] == 'I' && dsdt[i+3] == 'D' && dsdt[i+5] == 0x08)
{
return dsdt[i+4];
}
}
printf("pci root uid not found\n");
return 11;
}
unsigned int findpciroot(unsigned char * dsdt,int size)
{
int i;
for (i=0; i<size; i++)
{
if(dsdt[i] == 'P' && dsdt[i+1] == 'C' && dsdt[i+2] == 'I' && (dsdt[i+3] == 0x08 || dsdt [i+4] == 0x08))
{
return findrootuid(dsdt+i);
}
}
printf("pci root not found\n");
return 10;
}
/* Setup ACPI. Replace DSDT if DSDT.aml is found */
int getPciRootUID()
{
int fd, version;
void *new_dsdt;
const char *dsdt_filename;
const char *val;
int user_uid_value;
char dirspec[512];
int len,fsize;
if(rootuid < 10) return rootuid;
if (!getValueForKey("DSDT", &dsdt_filename, &len, &bootInfo->bootConfig))
dsdt_filename="DSDT.aml";
if (getValueForKey("-pci1", &val, &len, &bootInfo->bootConfig)) //fallback
{
user_uid_value = 1;
rootuid = user_uid_value;
return rootuid;
}
else user_uid_value = 0;
// Check booting partition
sprintf(dirspec,"%s",dsdt_filename);
fd=open (dirspec,0);
if (fd<0)
{// Check Extra on booting partition
sprintf(dirspec,"/Extra/%s",dsdt_filename);
fd=open (dirspec,0);
if (fd<0)
{// Fall back to booter partition
sprintf(dirspec,"bt(0,0)/Extra/%s",dsdt_filename);
fd=open (dirspec,0);
if (fd<0)
{
verbose("No DSDT found, using 0 as uid value.\n");
rootuid = user_uid_value;
return rootuid;
}
}
}
// Load replacement DSDT
new_dsdt=(void*)MALLOC(file_size (fd));
if (!new_dsdt)
{
printf("Couldn't allocate memory for DSDT\n");
rootuid = user_uid_value;
return rootuid;
}
fsize = file_size(fd);
if (read (fd, new_dsdt, file_size (fd))!=file_size (fd))
{
printf("Couldn't read file\n");
rootuid = user_uid_value;
return rootuid;
}
close (fd);
rootuid=findpciroot(new_dsdt, fsize);
if(rootuid == 11)rootuid=0; //usualy when _UID isnt present, it means uid is zero
if(rootuid == 10) //algo failed, PCI0 wasnt found;
{
printf("pci root uid value wasnt found, using zero, if you want it to be 1, use -pci1 flag");
rootuid = user_uid_value;
}
free(new_dsdt);
return rootuid;
}
branches/rekursor/i386/libsaio/pci_root.h
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
* Copyright 2008 mackerintel
*/
#ifndef __LIBSAIO_PCI_ROOT_H
#define __LIBSAIO_PCI_ROOT_H
#include "libsaio.h"
extern int getPciRootUID();
#endif /* !__LIBSAIO_DSDT_PATCHER_H */
branches/rekursor/i386/libsaio/device_inject.c
7070
7171
7272
73
73
7474
7575
7676
......
127127
128128
129129
130
130
131131
132132
133133
......
157157
158158
159159
160
160
161161
162162
163163
......
174174
175175
176176
177
177
178178
179179
180180
......
186186
187187
188188
189
190
189191
190192
191193
......
270272
271273
272274
273
275
274276
275277
276
278
277279
278280
279281
......
286288
287289
288290
289
291
290292
291293
292294
......
316318
317319
318320
319
321
320322
321323
322324
......
330332
331333
332334
333
335
334336
335337
336338
......
342344
343345
344346
345
347
346348
347349
348350
......
423425
424426
425427
428
426429
427430
428431
......
430433
431434
432435
436
437
438
433439
434440
435441
......
437443
438444
439445
440
446
441447
442448
443449
......
449455
450456
451457
452
458
453459
454460
455461
if (len > 1)
{
// the resulting binary will be the half size of the input hex string
binStr = malloc(len / 2);
binStr = MALLOC(len / 2);
binStrIdx = 0;
hexNibbleIdx = 0;
for (hexStrIdx = 0; hexStrIdx < len; hexStrIdx++)
char *string = efi_inject_get_devprop_string(&strlength);
/* Use the static "device-properties" boot config key contents if available,
* otheriwse use the generated one.
* otherwise use the generated one.
*/
if (!getValueForKey(DEVICE_PROPERTIES_PROP, &val, &cnt, &bootInfo->bootConfig) && string)
{
struct DevPropString *devprop_create_string(void)
{
string = (struct DevPropString*)malloc(sizeof(struct DevPropString));
string = (struct DevPropString*)MALLOC(sizeof(struct DevPropString));
if(string == NULL)
return NULL;
const char *val;
int len;
struct DevPropDevice *device = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice));
struct DevPropDevice *device = (struct DevPropDevice*)MALLOC(sizeof(struct DevPropDevice));
if(!device || !string || !path) {
if(device)
free(device);
if (getValueForKey("PciRoot", &val, &len, &bootInfo->bootConfig))
PciRootID = atoi(val);
else // rekursor: if no default pciroot is set in the boot.plist file then go and get this PciRootID:
PciRootID =(uint32_t) ascii_hex_to_int(&path[strlen(pciroot_string)]);
if(strncmp(path, pciroot_string, strlen(pciroot_string)))
{
string->length += device->length;
if(!string->entries)
if((string->entries = (struct DevPropDevice**)malloc(sizeof(device)))== NULL)
if((string->entries = (struct DevPropDevice**)MALLOC(sizeof(device)))== NULL)
return 0;
string->entries[string->numentries++] = (struct DevPropDevice*)malloc(sizeof(device));
string->entries[string->numentries++] = (struct DevPropDevice*)MALLOC(sizeof(device));
string->entries[string->numentries-1] = device;
return device;
return 0;
uint32_t length = ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2);
uint8_t *data = (uint8_t*)malloc(length);
uint8_t *data = (uint8_t*)MALLOC(length);
{
if(!data)
return 0;
uint32_t offset = device->length - (24 + (6 * device->num_pci_devpaths));
uint8_t *newdata = (uint8_t*)malloc((length + offset));
uint8_t *newdata = (uint8_t*)MALLOC((length + offset));
if(!newdata)
return 0;
if(device->data)
device->numentries++;
if(!device->data)
device->data = (uint8_t*)malloc(sizeof(uint8_t));
device->data = (uint8_t*)MALLOC(sizeof(uint8_t));
else
free(device->data);
char *devprop_generate_string(struct DevPropString *string)
{
char *buffer = (char*)malloc(string->length * 2);
char *buffer = (char*)MALLOC(string->length * 2);
char *ptr = buffer;
if(!buffer)
if(!device)
return 0;
uint8_t builtin = 0x0;
char tmp[10];
if((vendor_id != 0x168c) && (builtin_set == 0))
{
builtin_set = 1;
}
if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1))
return 0;
sprintf(tmp, "Slot-%x",devices_number); // 1 - vga card. FIXME - for 2+ vgas
if(!devprop_add_value(device, "AAPL,slot-name", tmp, strlen(tmp)))
return 0;
devices_number++;
return 1;
}
void set_eth_builtin(pci_dt_t *eth_dev)
{
char *devicepath = get_pci_dev_path(eth_dev);
struct DevPropDevice *device = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice));
struct DevPropDevice *device = (struct DevPropDevice*)MALLOC(sizeof(struct DevPropDevice));
verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);
{
verbose("Setting up lan keys\n");
devprop_add_network_template(device, eth_dev->vendor_id);
stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
stringdata = (uint8_t*)MALLOC(sizeof(uint8_t) * string->length);
if(stringdata)
{
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
branches/rekursor/i386/libsaio/ntfs.c
157157
158158
159159
160
160
161161
162162
163163
size_t nameSize;
char *buf;
buf = (char *)malloc(MAX_CLUSTER_SIZE);
buf = (char *)MALLOC(MAX_CLUSTER_SIZE);
if (buf == 0) {
goto error;
}
branches/rekursor/i386/libsaio/nvidia.c
610610
611611
612612
613
613
614614
615615
616616
......
697697
698698
699699
700
700
701701
702702
703703
......
733733
734734
735735
736
736
737737
738738
739739
(REG32(0) >> 20) & 0x1ff, nvda_dev->vendor_id, nvda_dev->device_id,
devicepath);
rom = malloc(0x10000);
rom = MALLOC(0x10000);
if(!rom)
{
if (!string)
string = devprop_create_string();
struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));
struct DevPropDevice *device = MALLOC(sizeof(struct DevPropDevice));
device = devprop_add_device(string, devicepath);
if(!device)
if (set_vbios_prop)
devprop_add_value(device, "vbios", rom, (nvBiosOveride > 0) ? nvBiosOveride : (rom[2] * 512));
stringdata = malloc(sizeof(uint8_t) * string->length);
stringdata = MALLOC(sizeof(uint8_t) * string->length);
if(!stringdata)
{
printf("no stringdata press a key...\n");
branches/rekursor/i386/libsaio/ati.c
293293
294294
295295
296
296
297297
298298
299299
......
428428
429429
430430
431
431
432432
433433
434434
......
648648
649649
650650
651
651
652652
653653
654654
......
713713
714714
715715
716
716
717717
718718
719719
......
762762
763763
764764
765
765
766766
767767
768768
REG32W(0xa8, 0);
REG32R(0xac);
BIOSBase = malloc(0x10000);
BIOSBase = MALLOC(0x10000);
if(BIOSBase)
{
REG32W(0xa8, 0);
printf("dumping pci config space, 256 bytes\n");
int i;
uint8_t *config_space;
config_space = malloc(256);
config_space = MALLOC(256);
for(i=0; i<=255; i++)
config_space[i] = pci_config_read8( ati_dev->dev.addr, i);
devprop_add_value(device, "ATY,PCIConfigSpace", config_space, 256);
if (!string)
string = devprop_create_string();
struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));
struct DevPropDevice *device = MALLOC(sizeof(struct DevPropDevice));
device = devprop_add_device(string, devicepath);
if(!device)
{
sprintf(romfilename, "ati_%04x_%04x.rom", (uint16_t)ati_dev->device_id, (uint16_t)ati_dev->vendor_id);
verbose("looking for file /Extra/%s\n", romfilename);
rom = malloc(0x20000);
rom = MALLOC(0x20000);
rom_size = load_ati_bios_file((char *)romfilename, (char *)rom);
if(rom_size > 0x10000) rom_size = 0x10000; //we dont need rest anyway;
if(rom_size == 0) printf("file not found\n");
} else verbose("Bios image not found at %x, content %x %x\n", biosimage, (uint8_t)biosimage[0], (uint8_t)biosimage[1]);
if(toFree) free(biosimage);
}
stringdata = malloc(sizeof(uint8_t) * string->length);
stringdata = MALLOC(sizeof(uint8_t) * string->length);
if(!stringdata)
{
printf("no stringdata press a key...\n");
branches/rekursor/i386/libsaio/sys.c
324324
325325
326326
327
327
328328
329329
330330
......
559559
560560
561561
562
562
563563
564564
565565
......
587587
588588
589589
590
590
591591
592592
593593
const char * entryName;
if (gMakeDirSpec == 0)
gMakeDirSpec = (char *)malloc(1024);
gMakeDirSpec = (char *)MALLOC(1024);
if (!dirSpec) {
long idx, len;
{
struct dirstuff * dirp = 0;
dirp = (struct dirstuff *) malloc(sizeof(struct dirstuff));
dirp = (struct dirstuff *) MALLOC(sizeof(struct dirstuff));
if (dirp == NULL)
goto error;
if ((bvr = getBootVolumeRef(path, &dirPath)) == NULL)
goto error;
dirp = (struct dirstuff *) malloc(sizeof(struct dirstuff));
dirp = (struct dirstuff *) MALLOC(sizeof(struct dirstuff));
if (dirp == NULL)
goto error;
branches/rekursor/i386/libsaio/nbp.c
120120
121121
122122
123
123
124124
125125
126126
if ( !gNetBVR )
{
gNetBVR = malloc( sizeof(*gNetBVR) );
gNetBVR = MALLOC( sizeof(*gNetBVR) );
if ( gNetBVR )
{
bzero(gNetBVR, sizeof(*gNetBVR));
branches/rekursor/i386/libsaio/disk.c
500500
501501
502502
503
503
504504
505505
506506
......
569569
570570
571571
572
572
573573
574574
575575
......
650650
651651
652652
653
653
654654
655655
656656
......
750750
751751
752752
753
753
754754
755755
756756
......
976976
977977
978978
979
979
980980
981981
982982
......
987987
988988
989989
990
990
991991
992992
993993
......
998998
999999
10001000
1001
1001
10021002
10031003
10041004
......
10741074
10751075
10761076
1077
1077
10781078
10791079
10801080
......
11281128
11291129
11301130
1131
1131
11321132
11331133
11341134
......
12231223
12241224
12251225
1226
1226
12271227
12281228
12291229
......
12311231
12321232
12331233
1234
1234
12351235
12361236
12371237
......
15731573
15741574
15751575
1576
1576
15771577
15781578
15791579
......
17301730
17311731
17321732
1733
1733
17341734
17351735
17361736
......
17671767
17681768
17691769
1770
1770
17711771
17721772
17731773
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef) MALLOC( sizeof(*bvr) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef) MALLOC( sizeof(*bvr) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
BVRef bvr = (BVRef) MALLOC( sizeof(*bvr) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
do {
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
map = (struct DiskBVMap *) MALLOC( sizeof(*map) );
if ( map )
{
map->biosdev = biosdev;
struct Block0 *block0_p;
unsigned int blksize;
unsigned int factor;
void *buffer = malloc(BPS);
void *buffer = MALLOC(BPS);
/* Check for alternate block size */
if (readBytes( biosdev, 0, 0, BPS, buffer ) != 0) {
blksize = OSSwapBigToHostInt16(block0_p->sbBlkSize);
if (blksize != BPS) {
free(buffer);
buffer = malloc(blksize);
buffer = MALLOC(blksize);
}
factor = blksize / BPS;
} else {
do {
// Create a new mapping.
map = (struct DiskBVMap *) malloc( sizeof(*map) );
map = (struct DiskBVMap *) MALLOC( sizeof(*map) );
if ( map )
{
int error;
int fatbits;
// Allocating buffer for 4 sectors.
const void * probeBuffer = malloc(PROBEFS_SIZE);
const void * probeBuffer = MALLOC(PROBEFS_SIZE);
if (probeBuffer == NULL)
goto exit;
static BVRef diskScanGPTBootVolumes( int biosdev, int * countPtr )
{
struct DiskBVMap * map = NULL;
void *buffer = malloc(BPS);
void *buffer = MALLOC(BPS);
int error;
if ( error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer ) != 0) {
verbose("Failed to read boot sector from BIOS device %02xh. Error=%d\n", biosdev, error);
UInt32 bufferSize = IORound(gptCount * gptSize, BPS);
if(bufferSize == 0)
goto scanErr;
buffer = malloc(bufferSize);
buffer = MALLOC(bufferSize);
if(readBytes(biosdev, gptBlock, 0, bufferSize, buffer) != 0)
goto scanErr;
verbose("Read GPT\n");
// Allocate a new map for this BIOS device and insert it into the chain
map = malloc(sizeof(*map));
map = MALLOC(sizeof(*map));
map->biosdev = biosdev;
map->bvr = NULL;
map->bvrcnt = 0;
/*
* Allocate and copy the matched bvr entry into a new one.
*/
newBVR = (BVRef) malloc(sizeof(*newBVR));
newBVR = (BVRef) MALLOC(sizeof(*newBVR));
bcopy(bvr, newBVR, sizeof(*newBVR));
/*
{
if ( gBootSector == NULL )
{
gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector));
gBootSector = (struct disk_blk0 *) MALLOC(sizeof(*gBootSector));
if ( gBootSector == NULL ) return -1;
}
bootSector = gBootSector;
{
if ( gBootSector == NULL )
{
gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector));
gBootSector = (struct disk_blk0 *) MALLOC(sizeof(*gBootSector));
if ( gBootSector == NULL ) return -1;
}
bootSector = (struct disk_boot1f32_blk *) gBootSector;
branches/rekursor/i386/libsaio/cache.c
9090
9191
9292
93
94
93
94
9595
9696
9797
gCacheIH = ih;
#ifdef __i386__
if (!gCacheBuffer) gCacheBuffer = (char *) malloc(kCacheSize);
if (!gCacheEntries) gCacheEntries = (CacheEntry *) malloc(kCacheMaxEntries * sizeof(CacheEntry));
if (!gCacheBuffer) gCacheBuffer = (char *) MALLOC(kCacheSize);
if (!gCacheEntries) gCacheEntries = (CacheEntry *) MALLOC(kCacheMaxEntries * sizeof(CacheEntry));
if ( !gCacheBuffer || !gCacheEntries )
{
gCacheIH = 0; // invalidate cache
branches/rekursor/i386/libsaio/pci.c
6767
6868
6969
70
70
7171
7272
7373
......
116116
117117
118118
119
119
120120
121121
122122
......
132132
133133
134134
135
135136
136137
137138
138139
140
141
139142
140143
141144
142145
143146
144147
145
146
147
148
149
150
148151
152
153
154
155
149156
150157
151158
if (!id || id == 0xffffffff)
continue;
new = (pci_dt_t*)malloc(sizeof(pci_dt_t));
new = (pci_dt_t*)MALLOC(sizeof(pci_dt_t));
if (!new)
return;
memset(new, 0, sizeof(pci_dt_t));
void build_pci_dt(void)
{
root_pci_dev = malloc(sizeof(pci_dt_t));
root_pci_dev = MALLOC(sizeof(pci_dt_t));
if (!root_pci_dev)
return;
{
pci_dt_t *current, *end;
char tmp[30];
int uid = 0;
dev_path[0] = 0;
end = root_pci_dev;
uid = getPciRootUID();
while (end != pci_dt)
{
current = pci_dt;
while (current->parent != end)
current = current->parent;
end = current;
sprintf(tmp, "%s/Pci(0x%x,0x%x)",
(current->parent == root_pci_dev) ? "PciRoot(0x0)" : "",
if (current->parent == root_pci_dev)
{
sprintf(tmp, "PciRoot(0x%x)/Pci(0x%x,0x%x)", uid,
current->dev.bits.dev, current->dev.bits.func);
} else {
sprintf(tmp, "/Pci(0x%x,0x%x)",
current->dev.bits.dev, current->dev.bits.func);
}
strcat(dev_path, tmp);
}
branches/rekursor/i386/libsaio/stringTable.c
106106
107107
108108
109
109
110110
111111
112112
......
164164
165165
166166
167
167
168168
169169
170170
......
241241
242242
243243
244
244
245245
246246
247247
......
278278
279279
280280
281
281
282282
283283
284284
......
338338
339339
340340
341
342
343
344
345
346
347
348
349
341350
342351
343352
......
550559
551560
552561
553
562
554563
555564
556565
......
716725
717726
718727
719
728
720729
721730
722731
len = strlen(key);
tab = (char *)table;
buf = (char *)malloc(len + 3);
buf = (char *)MALLOC(len + 3);
sprintf(buf, "\"%s\"", key);
len = strlen(buf);
if (begin == end)
return 0;
bufsize = end - begin + 1;
newstr = malloc(bufsize);
newstr = MALLOC(bufsize);
strlcpy(newstr, begin, bufsize);
*list = end;
*size = newsize;
int size;
if (getValueForConfigTableKey(config, key, &val, &size)) {
newstr = (char *)malloc(size+1);
newstr = (char *)MALLOC(size+1);
for (p = newstr; size; size--, p++, val++) {
if ((*p = *val) == '\\') {
switch (*++val) {
int size;
if (getValueForKey(key, &val, &size, config) && size) {
newstr = (char *)malloc(size + 1);
newstr = (char *)MALLOC(size + 1);
strlcpy(newstr, val, size + 1);
return newstr;
} else {
return retval;
}
/* Return NULL if no option has been successfully retrieved, or the string otherwise */
const char * getStringForKey(const char * key, config_file_t *config)
{
static const char* value =0;
int len=0;
if(getValueForKey(key, &value, &len, config)!=YES) value = 0;
return value;
}
/* Returns TRUE if a value was found, FALSE otherwise.
* The boolean value of the key is stored in 'val'.
*/
pos = 0;
char *configBuffer;
configBuffer = malloc(strlen(buffer)+1);
configBuffer = MALLOC(strlen(buffer)+1);
strcpy(configBuffer, buffer);
while (1)
char * newString(const char * oldString)
{
if ( oldString )
return strcpy(malloc(strlen(oldString)+1), oldString);
return strcpy(MALLOC(strlen(oldString)+1), oldString);
else
return NULL;
}
branches/rekursor/i386/libsaio/msdos.c
156156
157157
158158
159
159
160160
161161
162162
......
630630
631631
632632
633
633
634634
635635
636
636
637637
638638
639639
......
665665
666666
667667
668
668
669669
670670
671671
672672
673673
674674
675
675
676676
677677
678678
......
725725
726726
727727
728
728
729729
730730
731731
......
774774
775775
776776
777
777
778778
779779
780780
......
866866
867867
868868
869
869
870870
871871
872872
......
887887
888888
889889
890
890
891891
892892
893893
......
907907
908908
909909
910
910
911911
912912
913913
return 0;
}
buf=malloc (512);
buf=MALLOC (512);
/*
* Read the boot sector of the filesystem, and then check the
* boot signature. If not a dos boot sector then error out.
st = (struct msdosdirstate *)*dirIndex;
if (!st)
{
st=malloc (sizeof (*st));
st=MALLOC (sizeof (*st));
if (dirPath[0])
{
uint8_t *buf=malloc(msdosclustersize);
uint8_t *buf=MALLOC(msdosclustersize);
dirp = getdirpfrompath (ih, dirPath, buf);
if (!dirp || !(dirp->deAttributes & ATTR_DIRECTORY))
{
{
int i;
for (i=0;vfatname[i];i++);
*name = malloc (256);
*name = MALLOC (256);
utf_encodestr(vfatname, i, (u_int8_t *)*name, 255, OSLittleEndian );
}
else
{
int i, j, k;
uint16_t tmp[13];
*name = malloc (26);
*name = MALLOC (26);
for (i=7;i>=0;i--)
if (dirp->deName[i]!=' ')
break;
return -1;
if (filePath[0] == '/')
filePath++;
buf = malloc(msdosclustersize);
buf = MALLOC(msdosclustersize);
dirp = getdirpfrompath (ih, filePath, buf);
if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY))
return -1;
if (filePath[0] == '/')
filePath++;
buf = malloc(msdosclustersize);
buf = MALLOC(msdosclustersize);
dirp = getdirpfrompath (ih, filePath, buf);
if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY))
{
label[0] = '\0';
initRoot (&st);
st.buf = malloc(msdosclustersize);
st.buf = MALLOC(msdosclustersize);
while ((dirp = getnextdirent (ih, vfatlabel, &st)))
if (dirp->deAttributes & ATTR_VOLUME) {
strncpy((char *)label, (char *)dirp->deName, LABEL_LENGTH);
/* else look in the boot blocks */
if (!labelfound || str[0] == '\0') {
char *buf = malloc (512);
char *buf = MALLOC (512);
union bootsector *bsp = (union bootsector *)buf;
Seek(ih, 0);
Read(ih, (long)buf, 512);
long
MSDOSGetUUID(CICell ih, char *uuidStr)
{
char *buf = malloc (512);
char *buf = MALLOC (512);
union bootsector *bsp = (union bootsector *)buf;
if (MSDOSInitPartition (ih)<0)
branches/rekursor/i386/libsaio/fake_efi.c
1
12
23
34
......
1415
1516
1617
18
1719
1820
1921
......
5557
5658
5759
58
60
5961
6062
6163
......
7981
8082
8183
82
84
8385
8486
8587
......
273275
274276
275277
276
277
278
278
279
280
279281
280282
281283
......
316318
317319
318320
319
320
321
322
323
321
322
323
324
325
326
327
328
324329
325
326
330
331
332
333
327334
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
328485
486
487
488
329489
490
330491
331492
332493
......
348509
349510
350511
351
512
352513
353514
354515
......
369530
370531
371532
372
373
374
375
533
376534
377535
378536
537
379538
380539
381540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
382562
383563
384564
......
417597
418598
419599
600
/*
* Copyright 2007 David F. Elliott. All rights reserved.
*/
#include "device_inject.h"
#include "pci.h"
#include "sl.h"
#include "SMBIOS.h"
extern struct SMBEntryPoint * getSmbios();
extern void setup_pci_devs(pci_dt_t *pci_dt);
static inline char * mallocStringForGuid(EFI_GUID const *pGuid)
{
char *string = malloc(37);
char *string = MALLOC(37);
efi_guid_unparse_upper(pGuid, string);
return string;
}
static EFI_UINT32 const FIRMWARE_REVISION = 132; /* FIXME: Find a constant for this. */
/* Default platform system_id (fix by IntVar) */
static EFI_CHAR8 const SYSTEM_ID[] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10};//random value gen by uuidgen
static EFI_CHAR8 const SYSTEM_ID[] = "0123456789ABCDEF";//random value gen by uuidgen
/* Just a ret instruction */
static uint8_t const VOIDRET_INSTRUCTIONS[] = {0xc3};
*/
/* These should be const but DT__AddProperty takes char* */
static char TSC_Frequency_prop[] = "TSCFrequency";
static char FSB_Frequency_prop[] = "FSBFrequency";
static char CPU_Frequency_prop[] = "CPUFrequency";
static const char const TSC_Frequency_prop[] = "TSCFrequency";
static const char const FSB_Frequency_prop[] = "FSBFrequency";
static const char const CPU_Frequency_prop[] = "CPUFrequency";
/*==========================================================================
* SMBIOS
*/
/* These should be const but DT__AddProperty takes char* */
static char FIRMWARE_REVISION_PROP[] = "firmware-revision";
static char FIRMWARE_ABI_PROP[] = "firmware-abi";
static char FIRMWARE_VENDOR_PROP[] = "firmware-vendor";
static char FIRMWARE_ABI_PROP_VALUE[] = "EFI64";
static char SYSTEM_ID_PROP[] = "system-id";
static const char const FIRMWARE_REVISION_PROP[] = "firmware-revision";
static const char const FIRMWARE_ABI_PROP[] = "firmware-abi";
static const char const FIRMWARE_VENDOR_PROP[] = "firmware-vendor";
static const char const FIRMWARE_ABI_PROP_VALUE[] = "EFI64";
static const char const SYSTEM_ID_PROP[] = "system-id";
static const char const SYSTEM_SERIAL_PROP[] = "SystemSerialNumber";
static const char const SYSTEM_TYPE_PROP[] = "system-type";
static const char const MODEL_PROP[] = "Model";
void
setupEfiDeviceTree(void)
#define UUID_LEN16
/* Get an smbios option string option to convert to EFI_CHAR16 string */
static EFI_CHAR16* getSmbiosChar16(const char * key, size_t* len)
{
const char * src=0;
EFI_CHAR16* dst = 0;
size_t i;
if (!key || !(*key) || !len || !(src = getStringForKey(key, &bootInfo->smbiosConfig)))
return 0;
*len = strlen(src);
dst = (EFI_CHAR16*) MALLOC(((*len)+1)*2);
for (i=0; i<*len; i++) dst[i] = src[i];
dst[*len] = '\0';
return dst;
}
#define DEBUG_SMBIOS 1
/* Get the SystemID from the bios dmi info */
static EFI_CHAR8* getSmbiosUUID()
{
struct SMBEntryPoint*smbios;
struct DMIHeader*dmihdr;
SMBByte*p;
inti, found, isZero, isOnes;
static EFI_CHAR8 uuid[UUID_LEN+1]="";
smbios = getAddressOfSmbiosTable();/* checks for _SM_ anchor and table header checksum */
if (memcmp( &smbios->dmi.anchor[0], "_DMI_", 5) != 0) {
return 0;
}
verbose(">>> SMBIOSAddr=0x%08x\n", smbios);
verbose(">>> DMI: addr=0x%08x, len=0x%d, count=%d\n", smbios->dmi.tableAddress,
smbios->dmi.tableLength, smbios->dmi.structureCount);
i = 0;
found = 0;
p = (SMBByte *) smbios->dmi.tableAddress;
while (i < smbios->dmi.structureCount && p + 4 <= (SMBByte *)smbios->dmi.tableAddress + smbios->dmi.tableLength) {
dmihdr = (struct DMIHeader *) p;
verbose(">>>>>> DMI(%d): type=0x%02x, len=0x%d\n",i,dmihdr->type,dmihdr->length);
if (dmihdr->length < 4 || dmihdr->type == 127 /* EOT */) break;
if (dmihdr->type == 1) {/* 3.3.2 System Information */
if (dmihdr->length >= 0x19) found = 1;
break;
}
p = p + dmihdr->length;
while ((p - (SMBByte *)smbios->dmi.tableAddress + 1 < smbios->dmi.tableLength) && (p[0] != 0x00 || p[1] != 0x00))
p++;
p += 2;
i++;
}
if (!found) return 0;
verbose("Found SMBIOS System Information Table 1\n");
p += 8;
for (i=0, isZero=1, isOnes=1; i<UUID_LEN; i++) {
if (p[i] != 0x00) isZero = 0;
if (p[i] != 0xff) isOnes = 0;
}
if (isZero || isOnes) {/* empty or setable means: no uuid present */
verbose("No UUID present in SMBIOS System Information Table\n");
return 0;
}
memcpy(uuid, p, UUID_LEN+1);
return uuid;
}
static EFI_CHAR8* getUUIDFromString(const char *source)
{
if (!source) return 0;
char*p = (char *)source;
inti;
charbuf[3];
static EFI_CHAR8 uuid[UUID_LEN+1]="";
buf[2] = '\0';
for (i=0; i<UUID_LEN; i++) {
if (p[0] == '\0' || p[1] == '\0' || !isxdigit(p[0]) || !isxdigit(p[1])) {
verbose("[ERROR] UUID='%s' syntax error\n", source);
return 0;
}
buf[0] = *p++;
buf[1] = *p++;
uuid[i] = (unsigned char) strtoul(buf, NULL, 16);
if (*p == '-' && (i % 2) == 1 && i < UUID_LEN - 1) {
p++;
}
}
uuid[UUID_LEN]='\0';
if (*p != '\0') {
verbose("[ERROR] UUID='%s' syntax error\n", source);
return 0;
}
return uuid;
}
/* Parse an UUID string into an (EFI_CHAR8*) buffer */
// FIXME: can't use my original code here,
// Ironically, trying to reuse convertHexStr2Binary() would RESET the system!
/*
static EFI_CHAR8* getUUIDFromString2(const char * szInUUID)
{
char szUUID[UUID_LEN+1], *p=szUUID;
int size=0;
void* ret;
if (!szInUUID || strlen(szInUUID)<UUID_LEN) return (EFI_CHAR8*) 0;
while(*szInUUID) if (*szInUUID!='-') *p++=*szInUUID++; else szInUUID++;
*p='\0';
ret = convertHexStr2Binary(szUUID, &size);
if (!ret || size!=UUID_LEN)
{
verbose("UUID: cannot convert string <%s> to valid UUID.\n", szUUID);
return (EFI_CHAR8*) 0;
}
return (EFI_CHAR8*) ret; // new allocated buffer containing the converted string to bin
}
*/
/* return a binary UUID value from the overriden SystemID and SMUUID if ound,
* or from the bios if not, or from a fixed value if no bios value is found
*/
static EFI_CHAR8* getSystemID()
{// unable to determine UUID for host. Error: 35 fix
const char * sysId = getStringForKey("SystemID", &bootInfo->bootConfig);
EFI_CHAR8* ret = getUUIDFromString(sysId);
if(!sysId || !ret) // try smbios.plist SMUUID override
ret=getUUIDFromString((sysId = getStringForKey("SMUUID",&bootInfo->smbiosConfig)));
if(!sysId || !ret) { // try bios dmi info UUID extraction
ret = getSmbiosUUID();
sysId=0;
}
if(!ret) // no bios dmi UUID available, set a fixed value for system-id
ret=getUUIDFromString((sysId = (const char*) SYSTEM_ID));
verbose("Customizing SystemID with : %s\n", sysId ? sysId :"BIOS internal UUID");
return ret;
}
void setupEfiDeviceTree(void)
{
EFI_CHAR16* ret16=0;
EFI_CHAR8* ret=0;
size_t len=0;
Node *node;
EFI_CHAR8 SystemType=1;
const char *value;
node = DT__FindNode("/", false);
if (node == 0) {
stop("Couldn't get root node");
}
Node *runtimeServicesNode = DT__AddChild(node, "runtime-services");
/* The value of the table property is the 32-bit physical address for the RuntimeServices table.
* Sice the EFI system table already has a pointer to it, we simply use the address of that pointer
* Since the EFI system table already has a pointer to it, we simply use the address of that pointer
* for the pointer to the property data. Warning.. DT finalization calls free on that but we're not
* the only thing to use a non-malloc'd pointer for something in the DT
*/
if(fsbFrequency != 0)
DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &fsbFrequency);
// unable to determine UUID for host. Error: 35 fix
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, sizeof(SYSTEM_ID), (EFI_UINT32*)&SYSTEM_ID);
/* Export TSC and CPU frequencies for use by the kernel or KEXTs
/* Export TSC and CPU frequencies for use by the kernel or KEXTs
*/
if(tscFrequency != 0)
DT__AddProperty(efiPlatformNode, TSC_Frequency_prop, sizeof(uint64_t), &tscFrequency);
if(cpuFrequency != 0)
DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &cpuFrequency);
/* Export system-id. Can be disabled with system-id=No in com.apple.Boot.plist */
if((ret=getSystemID()))
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) ret);
/* Export system-type. Allowed values are: 0x01 for desktop computer (default), 0x02 for portable computers */
if (getValueForKey("system-type", &value, (int*) &len, &bootInfo->bootConfig) && value != NULL) {
if (*value != '1' && *value != '2')
verbose("Error: system-type must be 1 (desktop) or 2 (portable). Defaulting to 1!\n");
else
SystemType = (unsigned char) (*value-'0');
}
DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(EFI_CHAR8), &SystemType);
/* Export SystemSerialNumber if present */
if ((ret16=getSmbiosChar16("SMserial", &len)))
DT__AddProperty(efiPlatformNode, SYSTEM_SERIAL_PROP, len, ret16);
/* Export Model if present */
if ((ret16=getSmbiosChar16("SMproductname", &len)))
DT__AddProperty(efiPlatformNode, MODEL_PROP, len, ret16);
/* Fill /efi/device-properties node.
*/
setupDeviceProperties(node);
// Add configuration table entries to both the services table and the device tree
setupEfiConfigurationTable();
}
branches/rekursor/i386/libsaio/saio_internal.h
150150
151151
152152
153
153154
154155
155156
extern char * newStringForKey(char *key, config_file_t *configBuff);
extern BOOL getValueForBootKey(const char *line, const char *match, const char **matchval, int *len);
extern BOOL getValueForKey(const char *key, const char **val, int *size, config_file_t *configBuff);
extern const char * getStringForKey(const char * key, config_file_t *config);
extern BOOL getBoolForKey(const char *key, BOOL *val, config_file_t *configBuff);
extern BOOL getIntForKey(const char *key, int *val, config_file_t *configBuff);
extern BOOL getColorForKey(const char *key, unsigned int *val, config_file_t *configBuff);
branches/rekursor/i386/boot2/picopng.c
4545
4646
4747
48
48
4949
5050
5151
......
7373
7474
7575
76
76
7777
7878
7979
......
10971097
10981098
10991099
1100
1100
11011101
11021102
11031103
png_alloc_node_t *node;
if (png_alloc_find_node(addr))
return;
node = malloc(sizeof (png_alloc_node_t));
node = MALLOC(sizeof (png_alloc_node_t));
node->addr = addr;
node->size = size;
node->prev = png_alloc_tail;
void *png_alloc_malloc(size_t size)
{
void *addr = malloc(size);
void *addr = MALLOC(size);
png_alloc_add_node(addr, size);
return addr;
}
return 1;
}
insize = (uint32_t) statbuf.st_size;
inbuf = malloc(insize);
inbuf = MALLOC(insize);
infp = fopen(fname, "rb");
if (!infp) {
perror("fopen");
branches/rekursor/i386/boot2/graphics.c
5252
5353
5454
55
55
5656
5757
5858
......
151151
152152
153153
154
154
155155
156156
157157
......
349349
350350
351351
352
352
353353
354354
355355
......
483483
484484
485485
486
486
487487
488488
489489
......
491491
492492
493493
494
494
495495
496496
497497
......
499499
500500
501501
502
502
503503
504504
505505
......
525525
526526
527527
528
528
529529
530530
531531
......
543543
544544
545545
546
546
547547
548548
549549
......
575575
576576
577577
578
578
579579
580580
581581
......
592592
593593
594594
595
595
596596
597597
598598
......
610610
611611
612612
613
613
614614
615615
616616
{
VBEInfoBlock vbeInfo;
int err, small;
char *buff = malloc(sizeof(char)*256);
char *buff = MALLOC(sizeof(char)*256);
if(!buff) return 0;
bzero( &vbeInfo, sizeof(vbeInfo) );
if ( err != errSuccess )
return 0;
char *buff=malloc(sizeof(char)*3072);
char *buff=MALLOC(sizeof(char)*3072);
if(!buff) return 0;
// Loop through the mode list, and find the matching mode.
unsigned char value;
} * bp = (struct RLEBlock *) rleData;
out = cp = (char *) malloc( outBytes );
out = cp = (char *) MALLOC( outBytes );
if ( out == NULL ) return NULL;
while ( rleBlocks-- )
switch ( VIDEO(depth) ) {
case 16 :
img16 = malloc(width * height * 2);
img16 = MALLOC(width * height * 2);
if ( !img16 ) break;
for (cnt = 0; cnt < (width * height); cnt++)
img16[cnt] = lookUpCLUTIndex(imageData[cnt], 16);
break;
case 32 :
img32 = malloc(width * height * 4);
img32 = MALLOC(width * height * 4);
if ( !img32 ) break;
for (cnt = 0; cnt < (width * height); cnt++)
img32[cnt] = lookUpCLUTIndex(imageData[cnt], 32);
break;
default :
img = malloc(width * height);
img = MALLOC(width * height);
bcopy(imageData, img, width * height);
break;
}
error = -1;
goto failed;
}
pngData = malloc(pngSize);
pngData = MALLOC(pngSize);
if (read(pngFile, (char *) pngData, pngSize) != pngSize) {
error = -1;
goto failed;
error = -1;
goto failed;
}
uint8_t *result = malloc(info->width*4*info->height);
uint8_t *result = MALLOC(info->width*4*info->height);
*width = info->width;
*height = info->height;
memcpy(result, info->image->data, info->width*4*info->height);
error = -1;
goto failed;
}
uint8_t *result = malloc(info->width*4*info->height);
uint8_t *result = MALLOC(info->width*4*info->height);
*width = info->width;
*height = info->height;
memcpy(result, info->image->data, info->width*4*info->height);
uint16_t width=0,height=0;
uint8_t *imagedata = 0;
pixmap_t *pm=malloc(sizeof(pixmap_t));
pixmap_t *pm=MALLOC(sizeof(pixmap_t));
if(!pm) return 0;
if((loadPngImage(filename, &width, &height, &imagedata))!=0) return 0;
pm->width = width;
uint16_t width=0,height=0;
uint8_t *imagedata = 0;
pixmap_t *pm=malloc(sizeof(pixmap_t));
pixmap_t *pm=MALLOC(sizeof(pixmap_t));
if(!pm) return 0;
if((loadEmbeddedPngImage(pngData, pngSize, &width, &height, &imagedata))!=0) return 0;
pm->width = width;
branches/rekursor/i386/boot2/boot.c
115115
116116
117117
118
118
119
120
121
119122
120
121
122
123
123124
124125
125126
//==========================================================================
// Malloc error function
static void malloc_error(char *addr, size_t size)
//==========================================================================
// Malloc error function
static void malloc_error(char *addr, size_t size, const char *file, int line)
{
printf("\nMemory allocation error (0x%x, 0x%x)\n",
(unsigned)addr, (unsigned)size);
asm volatile ("hlt");
stop("\nMemory allocation error! Addr=0x%x, Size=0x%x, File=%s, Line=%d\n", (unsigned)addr, (unsigned)size, file, line);
}
/*!
branches/rekursor/i386/boot2/drivers.c
145145
146146
147147
148
149
150
151
152
148
149
150
151
152
153153
154154
155155
......
434434
435435
436436
437
437
438438
439439
440440
......
442442
443443
444444
445
445
446446
447447
448448
......
456456
457457
458458
459
459
460460
461461
462462
......
471471
472472
473473
474
474
475475
476476
477477
......
727727
728728
729729
730
730
731731
732732
733733
......
784784
785785
786786
787
787
788788
789789
790790
static long
InitDriverSupport( void )
{
gExtensionsSpec = (char *) malloc( 4096 );
gDriverSpec = (char *) malloc( 4096 );
gFileSpec = (char *) malloc( 4096 );
gTempSpec = (char *) malloc( 4096 );
gFileName = (char *) malloc( 4096 );
gExtensionsSpec = (char *) MALLOC( 4096 );
gDriverSpec = (char *) MALLOC( 4096 );
gFileSpec = (char *) MALLOC( 4096 );
gTempSpec = (char *) MALLOC( 4096 );
gFileName = (char *) MALLOC( 4096 );
if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName )
stop("InitDriverSupport error");
(bundleType == kCFBundleType2) ? "Contents/MacOS/" : "");
executablePathLength = strlen(gFileSpec) + 1;
tmpExecutablePath = malloc(executablePathLength);
tmpExecutablePath = MALLOC(executablePathLength);
if (tmpExecutablePath == 0) break;
strcpy(tmpExecutablePath, gFileSpec);
sprintf(gFileSpec, "%s/%s", dirSpec, name);
bundlePathLength = strlen(gFileSpec) + 1;
tmpBundlePath = malloc(bundlePathLength);
tmpBundlePath = MALLOC(bundlePathLength);
if (tmpBundlePath == 0) break;
strcpy(tmpBundlePath, gFileSpec);
if (length == -1) break;
length = length + 1;
buffer = malloc(length);
buffer = MALLOC(length);
if (buffer == 0) break;
strlcpy(buffer, (char *)kLoadAddr, length);
module->executablePath = tmpExecutablePath;
module->bundlePath = tmpBundlePath;
module->bundlePathLength = bundlePathLength;
module->plistAddr = (void *)malloc(length);
module->plistAddr = (void *)MALLOC(length);
if ((module->executablePath == 0) || (module->bundlePath == 0) || (module->plistAddr == 0))
break;
return -2;
}
tmpModule = (ModulePtr)malloc(sizeof(Module));
tmpModule = (ModulePtr)MALLOC(sizeof(Module));
if (tmpModule == 0)
{
XMLFreeTag(moduleDict);
#endif
uncompressed_size = OSSwapBigToHostInt32(kernel_header->uncompressed_size);
binary = buffer = malloc(uncompressed_size);
binary = buffer = MALLOC(uncompressed_size);
size = decompress_lzss((u_int8_t *) binary, &kernel_header->data[0],
OSSwapBigToHostInt32(kernel_header->compressed_size));
branches/rekursor/i386/boot2/bmdecompress.c
3434
3535
3636
37
38
39
40
37
38
39
40
4141
4242
4343
......
135135
136136
137137
138
139
140
141
138
139
140
141
142142
143143
144144
......
238238
239239
240240
241
241
242242
243243
244244
int i, j;
uint32_t * input;
uint16_t * sc0 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc1 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc0 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc1 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc2 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc3 = MALLOC((width+2) * sizeof(uint16_t));
uint32_t sr0, sr1, sr2, sr3;
bzero(sc0, (width+2) * sizeof(uint16_t));
int i, j;
uint32_t * input;
uint16_t * sc0 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc1 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc0 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc1 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc2 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc3 = MALLOC((width+2) * sizeof(uint16_t));
uint32_t sr0, sr1, sr2, sr3;
bzero(sc0, (width+2) * sizeof(uint16_t));
*dw = (int) src[1];
*dh = (int) src[2];
ret = malloc ((*dw * *dh * *bitsPerPixel)/ 8);
ret = MALLOC ((*dw * *dh * *bitsPerPixel)/ 8);
switch(*bitsPerPixel)
{
branches/rekursor/i386/boot2/gui.c
155155
156156
157157
158
158
159159
160160
161
161
162162
163163
164164
......
180180
181181
182182
183
183
184184
185185
186186
187
187
188188
189189
190190
......
200200
201201
202202
203
203
204204
205205
206206
207
207
208208
209209
210210
......
879879
880880
881881
882
882
883883
884884
885885
......
965965
966966
967967
968
968
969969
970970
971971
......
10531053
10541054
10551055
1056
1056
10571057
10581058
10591059
......
12041204
12051205
12061206
1207
1207
12081208
12091209
12101210
12111211
1212
1212
12131213
12141214
12151215
......
12861286
12871287
12881288
1289
1289
12901290
12911291
12921292
......
15261526
15271527
15281528
1529
1529
15301530
15311531
15321532
pixmap_t *getCroppedPixmapAtPosition( pixmap_t *from, position_t pos, uint16_t width, uint16_t height )
{
pixmap_t *cropped = malloc( sizeof( pixmap_t ) );
pixmap_t *cropped = MALLOC( sizeof( pixmap_t ) );
if( !cropped )
return 0;
cropped->pixels = malloc( width * height * 4 );
cropped->pixels = MALLOC( width * height * 4 );
if ( !cropped->pixels )
return 0;
int createBackBuffer( window_t *window )
{
gui.backbuffer = malloc(sizeof(pixmap_t));
gui.backbuffer = MALLOC(sizeof(pixmap_t));
if(!gui.backbuffer)
return 1;
gui.backbuffer->pixels = malloc( window->width * window->height * 4 );
gui.backbuffer->pixels = MALLOC( window->width * window->height * 4 );
if(!gui.backbuffer->pixels)
{
free(gui.backbuffer);
int createWindowBuffer( window_t *window )
{
window->pixmap = malloc(sizeof(pixmap_t));
window->pixmap = MALLOC(sizeof(pixmap_t));
if(!window->pixmap)
return 1;
window->pixmap->pixels = malloc( window->width * window->height * 4 );
window->pixmap->pixels = MALLOC( window->width * window->height * 4 );
if(!window->pixmap->pixels)
{
free(window->pixmap);
struct putc_info pi;
if( formattedtext = (char *) malloc(1024) )
if( formattedtext = (char *) MALLOC(1024) )
{
// format the text
va_start(ap, fmt);
struct putc_info pi;
if( formattedtext = (char *) malloc(1024) )
if( formattedtext = (char *) MALLOC(1024) )
{
// format the text
va_start(ap, fmt);
position_torigin, cursor, bounds;
font_t *font = &font_console;
if( formattedtext = (char *) malloc(1024) )
if( formattedtext = (char *) MALLOC(1024) )
{
// format the text
pi.str = formattedtext;
{
end = x + 1;
if( (font->chars[count] = malloc(sizeof(pixmap_t)) ) )
if( (font->chars[count] = MALLOC(sizeof(pixmap_t)) ) )
{
font->chars[count]->width = ( end - start) - 1;
font->chars[count]->height = font->height;
if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) )
if ( ( font->chars[count]->pixels = MALLOC( font->chars[count]->width * data->image->height * 4) ) )
{
space += ( font->chars[count]->width * data->image->height * 4 );
// we skip the first line because there are just the red pixels for the char width
for( i=0; i < sizeof(images) / sizeof(images[0]); i++)
{
// create pixmap_t buffer for each image
images[i].image = malloc(sizeof(pixmap_t));
images[i].image = MALLOC(sizeof(pixmap_t));
}
LOADPNG(background);
return;
pixmap_t progressbar;
progressbar.pixels=malloc(width * 4 * buff->height);
progressbar.pixels=MALLOC(width * 4 * buff->height);
if(!progressbar.pixels)
return;
branches/rekursor/i386/boot2/ramdisk.c
7373
7474
7575
76
77
76
77
7878
7979
8080
......
224224
225225
226226
227
227
strcpy(gRAMDiskFile, param);
// Set gMI as well for the multiboot ramdisk driver hook.
gMI = gRAMDiskMI = malloc(sizeof(multiboot_info));
struct multiboot_module * ramdisk_module = malloc(sizeof(multiboot_module));
gMI = gRAMDiskMI = MALLOC(sizeof(multiboot_info));
struct multiboot_module * ramdisk_module = MALLOC(sizeof(multiboot_module));
// Fill in multiboot info and module structures.
if (gRAMDiskMI != NULL && ramdisk_module != NULL)
getc();
setActiveDisplayPage(0);
}
}
}
branches/rekursor/i386/boot2/options.c
634634
635635
636636
637
637
638638
639639
640640
......
771771
772772
773773
774
774
775775
776776
777
777
778778
779
779
780780
781781
782782
......
851851
852852
853853
854
854
855855
856856
857857
......
11871187
11881188
11891189
1190
1190
11911191
11921192
11931193
......
12631263
12641264
12651265
1266
1266
12671267
12681268
12691269
......
14171417
14181418
14191419
1420
1420
14211421
14221422
14231423
......
15871587
15881588
15891589
1590
1590
{
int i;
MemoryRange *mp = bootInfo->memoryMap;
char *buff = malloc(sizeof(char)*1024);
char *buff = MALLOC(sizeof(char)*1024);
if(!buff) return 0;
char info[] = "BIOS reported memory ranges:\n";
if (getValueForKey( kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig )) {
cnt += 1;
prompt = malloc(cnt);
prompt = MALLOC(cnt);
strlcpy(prompt, val, cnt);
} else {
name = malloc(80);
name = MALLOC(80);
getBootVolumeDescription( gBootVolume, name, 80, NO );
prompt = malloc(256);
prompt = MALLOC(256);
sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);
free(name);
cnt = 0;
if ( gDeviceCount )
{
// Allocate memory for an array of menu items.
menuItems = (MenuItem *) malloc( sizeof(MenuItem) * gDeviceCount );
menuItems = (MenuItem *) MALLOC( sizeof(MenuItem) * gDeviceCount );
if ( menuItems == NULL ) goto done;
// Associate a menu item for each BVRef.
char * configKernelFlags;
char * valueBuffer;
valueBuffer = (char *)malloc(VALUE_SIZE);
valueBuffer = (char *)MALLOC(VALUE_SIZE);
skipblanks( &cp );
val = "";
cnt = 0;
}
configKernelFlags = (char *)malloc(cnt + 1);
configKernelFlags = (char *)MALLOC(cnt + 1);
strlcpy(configKernelFlags, val, cnt + 1);
if (processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, 0)) {
size = file_size(fd);
if (size > MAX_TEXT_FILE_SIZE)
size = MAX_TEXT_FILE_SIZE;
buffer = malloc( size + 1 );
buffer = MALLOC( size + 1 );
read(fd, buffer, size);
close(fd);
}
return result;
}
}
branches/rekursor/i386/libsa/libsa.h
3030
3131
3232
33
3334
3435
3536
3637
38
39
40
41
42
3743
3844
3945
......
9197
9298
9399
94
95
100
101
102
96103
97104
98105
#include <mach-o/loader.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>
/*
* string.c
*/
static inline int isxdigit(char c)
{
return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
}
#ifndef bcopy
extern void bcopy(const void * src, void * dst, size_t len);
#endif
/*
* zalloc.c
*/
extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t));
extern void * malloc(size_t size);
#define MALLOC(size)malloc(size, __FILE__, __LINE__)
extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
extern void * malloc(size_t size,const char *file, int line);
extern void free(void * start);
extern void * realloc(void * ptr, size_t size);
branches/rekursor/i386/libsa/zalloc.c
4848
4949
5050
51
51
5252
5353
5454
......
6161
6262
6363
64
64
6565
6666
6767
......
6969
7070
7171
72
72
7373
7474
7575
......
8686
8787
8888
89
89
9090
9191
9292
......
104104
105105
106106
107
107
108108
109109
110110
......
155155
156156
157157
158
158
159159
160160
161161
......
204204
205205
206206
207
207
208208
209209
210210
......
232232
233233
234234
235
235
236236
237237
238238
......
242242
243243
244244
245
245
246246
247247
248248
......
260260
261261
262262
263
263
264264
265265
266266
......
315315
316316
317317
318
318
319319
320320
321321
static short availableNodes, allocedNodes, totalNodes;
static char * zalloc_base;
static char * zalloc_end;
static void (*zerror)(char *, size_t);
static void (*zerror)(char *, size_t, const char *, int);
static void zallocate(char * start,int size);
static void zinsert(zmem * zp, int ndx);
#define ZALLOC_NODES16384
static void malloc_error(char *addr, size_t size)
static void malloc_error(char *addr, size_t size, const char *file, int line)
{
#ifdef i386
asm volatile ("hlt");
}
// define the block of memory that the allocator will use
void malloc_init(char * start, int size, int nodes, void (*malloc_err_fn)(char *, size_t))
void malloc_init(char * start, int size, int nodes, void (*malloc_err_fn)(char *, size_t, const char *, int))
{
zalloc_base = start ? start : (char *)ZALLOC_ADDR;
totalNodes = nodes ? nodes : ZALLOC_NODES;
#define BEST_FIT 1
void * malloc(size_t size)
void * malloc(size_t size, const char *file, int line)
{
int i;
#if BEST_FIT
size = ((size + 0xf) & ~0xf);
if (size == 0) {
if (zerror) (*zerror)((char *)0xdeadbeef, 0);
if (zerror) (*zerror)((char *)0xdeadbeef, 0, file, line);
}
#if BEST_FIT
smallestSize = 0;
done:
if ((ret == 0) || (ret + size >= zalloc_end))
{
if (zerror) (*zerror)(ret, size);
if (zerror) (*zerror)(ret, size, file, line);
}
if (ret != 0)
{
}
}
if ( !found ) {
if (zerror) (*zerror)(pointer, rp);
if (zerror) (*zerror)(pointer, rp, "free", 0);
else return;
}
#if ZDEBUG
if ((start + tsize) < zavailable[i].start)
{
if (++availableNodes > totalNodes) {
if (zerror) (*zerror)((char *)0xf000f000, 0);
if (zerror) (*zerror)((char *)0xf000f000, 0, "free", 0);
}
zinsert(zavailable, i);
zavailable[i].start = start;
}
if (++availableNodes > totalNodes) {
if (zerror) (*zerror)((char *)0xf000f000, 1);
if (zerror) (*zerror)((char *)0xf000f000, 1, "free", 0);
}
zavailable[i].start = start;
zavailable[i].size = tsize;
zalloced[allocedNodes].start = start;
zalloced[allocedNodes].size = size;
if (++allocedNodes > totalNodes) {
if (zerror) (*zerror)((char *)0xf000f000, 2);
if (zerror) (*zerror)((char *)0xf000f000, 2, "zallocate", 0);
};
}
/* This is the simplest way possible. Should fix this. */
void * realloc(void * start, size_t newsize)
{
void * newstart = malloc(newsize);
void * newstart = malloc(newsize, __FILE__, __LINE__);
bcopy(start, newstart, newsize);
free(start);
return newstart;

Archive Download the corresponding diff file

Revision: 4