Chameleon

Chameleon Commit Details

Date:2011-12-12 14:05:17 (7 years 10 months ago)
Author:armel cadet-petit
Commit:1724
Parents: 1723
Message:added exfat and haiku support, fixes and updates for Gui, and much more ...
Changes:
A/branches/cparm/i386/libsaio/befs.c
A/branches/cparm/i386/libsaio/befs.h
A/branches/cparm/i386/libsaio/exfat.c
A/branches/cparm/i386/libsaio/exfat.h
M/branches/cparm/i386/libsaio/bootstruct.h
M/branches/cparm/i386/boot2/drivers.c
M/branches/cparm/i386/boot2/mboot.c
M/branches/cparm/i386/libsaio/saio_types.h
M/branches/cparm/i386/libsaio/fake_efi.c
M/branches/cparm/i386/libsaio/bootLion.h
M/branches/cparm/i386/libsaio/disk.c
M/branches/cparm/i386/libsaio/saio_internal.h
M/branches/cparm/i386/libsaio/Makefile
M/branches/cparm/i386/modules/GUI/gui.c
M/branches/cparm/i386/boot2/options.c
M/branches/cparm/README
M/branches/cparm/i386/modules/GUI/gui.h
M/branches/cparm/i386/libsaio/fdisk.h
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/i386/libsaio/bootstruct.c
M/branches/cparm/i386/libsaio/ntfs.c
M/branches/cparm/CHANGES

File differences

branches/cparm/CHANGES
1
1
2
3
4
5
6
7
28
39
410
5
11
612
713
814
- Added an option to the check Oem revision of aml files (by adler32 of unique machine id or adler32 of motherboard model), can be useful with multiple machines (a command line tool able to patch the aml files will be available soon)
- Added Haiku support (credit to scorpius)
- Added EXFAT (FAT64) support (credit to dmazar)
- Added JrCs fixes (see trunk v1716 v1719)
- Gui can now detect the darwin version of each volumes
- Applied some underthehood fixes and enhancements
- Added an option to the check Oem revision of aml files, can be useful with multiple machines (a command line tool able to patch the aml files will be available soon)
- Improved smbios support for some Intel Xeon models
- BETA : Sync'd ati engine with the trunk
- Small security fix
- Small security fixes
- Added a mechanism to strip the madt table
- Ported the serial number randomizer to smbiosgetters,
Warning: smbiosgetters (and also the Gui module) still don't work when built with Xcode4.
branches/cparm/i386/libsaio/exfat.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
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
/*
* Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2004 Apple Computer, Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* dmazar, 14/7/2011
* support for EXFAT volume label reading
* EXFAT info from: http://www.ntfs.com/exfat-overview.htm
*
* EXFAT shares partition type with NTFS (0x7) and easiest way of
* adding it was through ntfs.c module. All functions here are called
* from similar ntfs.c funcs as fallback (if not NTFS, maybe it's EXFAT).
*/
#include "libsaio.h"
#include "sl.h"
#ifndef DEBUG_EXFAT
#define DEBUG_EXFAT 0
#endif
#if DEBUG_EXFAT
#define DBG(x...)printf(x)
#define PAUSE()getc()
#else
#define DBG(x...)
#define PAUSE()
#endif
#defineEXFAT_BBID"EXFAT "
#defineEXFAT_BBIDLEN8
#define MAX_BLOCK_SIZE4096
#define MAX_CLUSTER_SIZE32 * 1024 * 1024
#define ERROR -1
/*
* boot sector of the partition
* http://www.ntfs.com/exfat-boot-sector.htm
*/
struct exfatbootfile {
u_int8_t reserved1[3];/* JumpBoot: 0xEB7690 */
u_int8_t bf_sysid[8];/* FileSystemName: 'EXFAT ' */
u_int8_t reserved2[53];/* MustBeZero */
u_int64_t bf_prtoff;/* PartitionOffset: In sectors; if 0, shall be ignored */
u_int64_t bf_vollen;/* VolumeLength: Size of exFAT volume in sectors */
u_int32_t bf_fatoff;/* FatOffset: In sectors */
u_int32_t bf_fatlen;/* FatLength: In sectors. May exceed the required space in order to align the second FAT */
u_int32_t bf_cloff;/* ClusterHeapOffset: In sectors. */
u_int32_t bf_clcnt;/* ClusterCount: 2^32-11 is the maximum number of clusters could be described. */
u_int32_t bf_rdircl;/* RootDirectoryCluster. */
u_int32_t bf_volsn;/* VolumeSerialNumber. */
u_int16_t bf_fsrev;/* FileSystemRevision: as MAJOR.minor, major revision is high byte, minor is low byte; currently 01.00. */
u_int16_t bf_volflags;/* VolumeFlags. */
u_int8_t bf_bpss;/* BytesPerSectorShift: Power of 2. Minimum 9 (512 bytes per sector), maximum 12 (4096 bytes per sector) */
u_int8_t bf_spcs;/* SectorsPerClusterShift: Power of 2. Minimum 0 (1 sector per cluster), maximum 25 – BytesPerSectorShift, so max cluster size is 32 MB */
u_int8_t bf_nfats;/* NumberOfFats: 2 is for TexFAT only */
u_int8_t bf_drvs;/* DriveSelect: Extended INT 13h drive number; typically 0x80 */
u_int8_t bf_pused;/* PercentInUse: 0..100 – percentage of allocated clusters rounded down to the integer 0xFF – percentage is not available */
u_int8_t reserved3[7];/* Reserved */
u_int8_t bootcode[390];/* BootCode */
u_int16_t bf_bsig;/* BootSignature: 0xAA55 */
};
struct direntry_label {
u_int8_t type;/* EntryType: 0x83 (or 0x03 if label is empty) */
u_int8_t llen;/* CharacterCount: Length in Unicode characters (max 11) */
u_int16_t label[11];/* VolumeLabel: Unicode characters (max 11) */
u_int8_t reserved1[8];/* Reserved */
};
/**
* Reads volume label into str.
* Reads boot sector, performs dome checking, loads root dir
* and parses volume label.
*/
void
EXFATGetDescription(CICell ih, char *str, long strMaxLen)
{
struct exfatbootfile *boot;
u_int32_t bytesPerSector = 0;
u_int32_t sectorsPerCluster = 0;
long long rdirOffset = 0;
char *buf = NULL;
struct direntry_label *dire = NULL;
int loopControl = 0;
DBG("EXFAT: start %x:%x\n", ih->biosdev, ih->part_no);
buf = (char *)malloc(MAX_BLOCK_SIZE);
if (buf == 0)
{
goto error;
}
/*
* Read the boot sector, check signatures, and do some minimal
* sanity checking. NOTE: the size of the read below is intended
* to be a multiple of all supported block sizes, so we don't
* have to determine or change the device's block size.
*/
Seek(ih, 0);
Read(ih, (long)buf, MAX_BLOCK_SIZE);
// take our boot structure
boot = (struct exfatbootfile *) buf;
/*
* The first three bytes are an Intel x86 jump instruction. I assume it
* can be the same forms as DOS FAT:
* 0xE9 0x?? 0x??
* 0xEC 0x?? 0x90
* where 0x?? means any byte value is OK.
*/
if (boot->reserved1[0] != 0xE9
&& (boot->reserved1[0] != 0xEB || boot->reserved1[2] != 0x90))
{
goto error;
}
// Check the "EXFAT " signature.
if (memcmp((const char *)boot->bf_sysid, EXFAT_BBID, EXFAT_BBIDLEN) != 0)
{
goto error;
}
/*
* Make sure the bytes per sector and sectors per cluster are
* powers of two, and within reasonable ranges.
*/
bytesPerSector = 1 << boot->bf_bpss;/* Just one byte; no swapping needed */
DBG("EXFAT: bpss=%d, bytesPerSector=%d\n", boot->bf_bpss, bytesPerSector);
if (boot->bf_bpss < 9 || boot->bf_bpss > 12)
{
DBG("EXFAT: invalid bytes per sector shift(%d)\n", boot->bf_bpss);
goto error;
}
sectorsPerCluster = 1 << boot->bf_spcs;/* Just one byte; no swapping needed */
DBG("EXFAT: spcs=%d, sectorsPerCluster=%d\n", boot->bf_spcs, sectorsPerCluster);
if (boot->bf_spcs > (25 - boot->bf_bpss))
{
DBG("EXFAT: invalid sectors per cluster shift (%d)\n", boot->bf_spcs);
goto error;
}
// calculate root dir cluster offset
rdirOffset = boot->bf_cloff + (boot->bf_rdircl - 2) * sectorsPerCluster;
DBG("EXFAT: rdirOffset=%d\n", rdirOffset);
// load MAX_BLOCK_SIZE bytes of root dir
Seek(ih, rdirOffset * bytesPerSector);
Read(ih, (long)buf, MAX_BLOCK_SIZE);
DBG("buf 0 1 2 = %x %x %x\n", 0x00ff & buf[0], 0x00ff & buf[1], 0x00ff & buf[2]);
str[0] = '\0';
/*
* Search for volume label dir entry (type 0x83), convert from unicode and put to str.
* Set loopControl var to avoid searching outside of buf.
*/
loopControl = MAX_BLOCK_SIZE / sizeof(struct direntry_label);
dire = (struct direntry_label *)buf;
while (loopControl && dire->type && dire->type != 0x83)
{
dire++;
loopControl--;
}
if (dire->type == 0x83 && dire->llen > 0 && dire->llen <= 11)
{
utf_encodestr( dire->label, (int)dire->llen, (u_int8_t *)str, strMaxLen, OSLittleEndian );
}
DBG("EXFAT: label=%s\n", str);
free(buf);
PAUSE();
return;
error:
if (buf) free(buf);
DBG("EXFAT: error\n");
PAUSE();
return;
}
/**
* Sets UUID to uuidStr.
* Reads the boot sector, does some checking, generates UUID
* (like the one you get on Windows???)
*/
long EXFATGetUUID(CICell ih, char *uuidStr)
{
struct exfatbootfile *boot;
void *buf = malloc(MAX_BLOCK_SIZE);
if ( !buf )
return -1;
/*
* Read the boot sector, check signatures, and do some minimal
* sanity checking. NOTE: the size of the read below is intended
* to be a multiple of all supported block sizes, so we don't
* have to determine or change the device's block size.
*/
Seek(ih, 0);
Read(ih, (long)buf, MAX_BLOCK_SIZE);
boot = (struct exfatbootfile *) buf;
/*
* Check the "EXFAT " signature.
*/
if (memcmp((const char *)boot->bf_sysid, EXFAT_BBID, EXFAT_BBIDLEN) != 0)
return -1;
// Check for non-null volume serial number
if( !boot->bf_volsn )
return -1;
// Use UUID like the one you get on Windows
sprintf(uuidStr, "%04X-%04X", (unsigned short)(boot->bf_volsn >> 16) & 0xFFFF,
(unsigned short)boot->bf_volsn & 0xFFFF);
DBG("EXFATGetUUID: %x:%x = %s\n", ih->biosdev, ih->part_no, uuidStr);
return 0;
}
/**
* Returns true if given buffer is the boot rec of the EXFAT volume.
*/
bool EXFATProbe(const void * buffer)
{
bool result = false;
// boot sector structure
const struct exfatbootfile* boot = buffer;
// Looking for EXFAT signature.
if (memcmp((const char *)boot->bf_sysid, EXFAT_BBID, EXFAT_BBIDLEN) == 0)
result = true;
DBG("EXFATProbe: %d\n", result ? 1 : 0);
return result;
}
branches/cparm/i386/libsaio/bootstruct.c
3434
3535
3636
37
38
37
38
39
40
41
3942
4043
4144
......
4750
4851
4952
50
53
5154
5255
5356
5457
55
58
5659
5760
5861
......
106109
107110
108111
112
113
114
115
109116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
110152
111153
112154
113
155
114156
115
157
116158
117
118
119
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
120193
121194
122195
123196
124197
125
126
127
128
198
199
200
201
129202
130203
131204
......
143216
144217
145218
146
219
147220
221
148222
149223
150224
......
265339
266340
267341
268
342
269343
270
271
272344
* Initialize the structure of parameters passed to
* the kernel by the booter.
*/
boot_args_legacy *bootArgsLegacy;
boot_args *bootArgs;
boot_args_Legacy *bootArgsLegacy;
boot_args_common *bootArgs;
boot_args_107 *bootArgs107;
/* ... */
PrivateBootInfo_t *bootInfo;
Node *gMemoryMapNode;
if ( !init_done )
{
bootArgs = (boot_args *)malloc(sizeof(boot_args));
bootArgs = (boot_args_common *)malloc(sizeof(boot_args_common));
bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t));
if (bootArgs == 0 || bootInfo == 0)
stop("Couldn't allocate boot info\n");
bzero(bootArgs, sizeof(boot_args));
bzero(bootArgs, sizeof(boot_args_common));
bzero(bootInfo, sizeof(PrivateBootInfo_t));
// Get system memory map. Also update the size of the
}
#define AllocateKernelMemoryForBootArgs(Ver) \
{ \
bootArgs##Ver = (boot_args_##Ver *)AllocateKernelMemory(sizeof(boot_args_##Ver));\
}
#define CopyCommonBootArgsHeader(Ver) \
{ \
bootArgs##Ver->Revision = bootArgs->Header.Revision ;\
bootArgs##Ver->Version = bootArgs->Header.Version ;\
}
// For 10.6, 10.5 and 10.4 please use :Legacy:, for 10.7 use :107:
#define CopyCommonBootArgs(Ver) \
{ \
bcopy(bootArgs->CommandLine, bootArgs##Ver->CommandLine, BOOT_LINE_LENGTH);\
bootArgs##Ver->MemoryMap = bootArgs->MemoryMap ;\
bootArgs##Ver->MemoryMapSize = bootArgs->MemoryMapSize ;\
bootArgs##Ver->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize ;\
bootArgs##Ver->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion ;\
bootArgs##Ver->Video = bootArgs->Video ;\
bootArgs##Ver->deviceTreeP = bootArgs->deviceTreeP ;\
bootArgs##Ver->deviceTreeLength = bootArgs->deviceTreeLength ;\
bootArgs##Ver->kaddr = bootArgs->kaddr ;\
bootArgs##Ver->ksize = bootArgs->ksize ;\
bootArgs##Ver->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart ;\
bootArgs##Ver->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount ;\
bootArgs##Ver->efiSystemTable = bootArgs->efiSystemTable ;\
bootArgs##Ver->efiMode = bootArgs->efiMode ;\
bootArgs##Ver->performanceDataStart = bootArgs->performanceDataStart ;\
bootArgs##Ver->performanceDataSize = bootArgs->performanceDataSize ;\
bootArgs##Ver->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart ;\
}
#define init_boot_args(Ver) \
{ \
AllocateKernelMemoryForBootArgs(Ver);\
CopyCommonBootArgsHeader(Ver);\
CopyCommonBootArgs(Ver);\
}
/* Copy boot args after kernel and record address. */
void
reserveKernBootStruct(void)
reserveKern107BootStruct(void)
{
void *oldAddr = bootArgs;
//bootArgs107 = (boot_args_107 *)AllocateKernelMemory(sizeof(boot_args_107));
bootArgs = (boot_args *)AllocateKernelMemory(sizeof(boot_args));
bcopy(oldAddr, bootArgs, sizeof(boot_args));
/* Common Darwin boot arguments */
/*
bootArgs107->Revision = bootArgs->Header.Revision ;
bootArgs107->Version = bootArgs->Header.Version ;
bcopy(bootArgs->CommandLine, bootArgs107->CommandLine, BOOT_LINE_LENGTH);
bootArgs107->MemoryMap = bootArgs->MemoryMap ;
bootArgs107->MemoryMapSize = bootArgs->MemoryMapSize ;
bootArgs107->MemoryMapDescriptorSize = bootArgs->MemoryMapDescriptorSize ;
bootArgs107->MemoryMapDescriptorVersion = bootArgs->MemoryMapDescriptorVersion ;
bootArgs107->Video = bootArgs->Video ;
bootArgs107->deviceTreeP = bootArgs->deviceTreeP ;
bootArgs107->deviceTreeLength = bootArgs->deviceTreeLength ;
bootArgs107->kaddr = bootArgs->kaddr ;
bootArgs107->ksize = bootArgs->ksize ;
bootArgs107->efiRuntimeServicesPageStart = bootArgs->efiRuntimeServicesPageStart ;
bootArgs107->efiRuntimeServicesPageCount = bootArgs->efiRuntimeServicesPageCount ;
bootArgs107->efiSystemTable = bootArgs->efiSystemTable ;
bootArgs107->efiMode = bootArgs->efiMode ;
bootArgs107->performanceDataStart = bootArgs->performanceDataStart ;
bootArgs107->performanceDataSize = bootArgs->performanceDataSize ;
bootArgs107->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart ;
*/
init_boot_args(107);
/* Darwin 10.7 specific boot arguments */
bootArgs107->keyStoreDataStart = bootArgs->keyStoreDataStart ;
bootArgs107->keyStoreDataSize = bootArgs->keyStoreDataSize ;
bootArgs107->bootMemStart = bootArgs->bootMemStart ;
bootArgs107->bootMemSize = bootArgs->bootMemSize ;
bootArgs107->PhysicalMemorySize = bootArgs->PhysicalMemorySize ;
bootArgs107->FSBFrequency = bootArgs->FSBFrequency ;
bootArgs107->debugMode = bootArgs->debugMode;
}
void
reserveKernLegacyBootStruct(void)
{
bootArgsLegacy = (boot_args_legacy *)AllocateKernelMemory(sizeof(boot_args_legacy));
bootArgsLegacy->Revision = bootArgs->Revision ;
bootArgsLegacy->Version = bootArgs->Version ;
//bootArgsLegacy = (boot_args_legacy *)AllocateKernelMemory(sizeof(boot_args_legacy));
/*
bootArgsLegacy->Revision = bootArgs->Header.Revision ;
bootArgsLegacy->Version = bootArgs->Header.Version ;
bcopy(bootArgs->CommandLine, bootArgsLegacy->CommandLine, BOOT_LINE_LENGTH);
bootArgsLegacy->MemoryMap = bootArgs->MemoryMap ;
bootArgsLegacy->MemoryMapSize = bootArgs->MemoryMapSize ;
bootArgsLegacy->performanceDataStart = bootArgs->performanceDataStart ;
bootArgsLegacy->performanceDataSize = bootArgs->performanceDataSize ;
bootArgsLegacy->efiRuntimeServicesVirtualPageStart = bootArgs->efiRuntimeServicesVirtualPageStart ;
*/
init_boot_args(Legacy);
}
void
DT__FlattenDeviceTree((void **)&addr, &size);
bootArgs->deviceTreeP = (uint32_t)addr;
bootArgs->deviceTreeLength = size;
}
}
}
branches/cparm/i386/libsaio/exfat.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
/*
* Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 2.0 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
*
* This Original Code and all software distributed under the License are
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
* License for the specific language governing rights and limitations
* under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* dmazar, 14/7/2011
* support for EXFAT volume label reading
*
*/
extern void EXFATGetDescription(CICell ih, char *str, long strMaxLen);
extern bool EXFATProbe (const void *buf);
extern long EXFATGetUUID(CICell ih, char *uuidStr);
branches/cparm/i386/libsaio/bootstruct.h
3232
3333
3434
35
35
36
37
38
39
40
41
42
3643
37
3844
3945
4046
/*!
Kernel boot args global also used by booter for its own data.
*/
extern boot_args *bootArgs;
extern boot_args_common *bootArgs;
/*!
Boot args passed to the kernel.
*/
extern boot_args_Legacy *bootArgsLegacy;
extern boot_args_107 *bootArgs107;
extern Node *gMemoryMapNode;
extern boot_args_legacy *bootArgsLegacy;
#define VGA_TEXT_MODE 0
branches/cparm/i386/libsaio/bootLion.h
110110
111111
112112
113
113
114114
115115
116116
......
141141
142142
143143
144
144
145145
146146
147147
......
184184
185185
186186
187
187
188188
189
189
190
191
192
190193
194
195
196
197
198
199
200
201
202
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
191239
192240
#define kBootArgsEfiMode32 32
#define kBootArgsEfiMode64 64
typedef struct boot_args_legacy {
typedef struct boot_args_Legacy {
uint16_t Revision;/* Revision of boot_args structure */
uint16_t Version;/* Version of boot_args structure */
uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */
uint32_t __reserved3[2];
} boot_args_legacy;
} boot_args_Legacy;
typedef struct boot_args {
uint16_t Revision;/* Revision of boot_args structure */
uint64_t FSBFrequency;
uint32_t __reserved4[734];
} boot_args;
} boot_args_107;
extern char assert_boot_args_size_is_4096[sizeof(boot_args) == 4096 ? 1 : -1];
typedef struct boot_args_header {
uint16_t Revision;/* Revision of boot_args structure */
uint16_t Version;/* Version of boot_args structure */
} boot_args_header;
typedef struct boot_args_10x {
boot_args_header Header;
Boot_VideoVideo;/* Video Information */
uint32_t MemoryMap; /* Physical address of memory map */
uint32_t MemoryMapSize;
uint32_t MemoryMapDescriptorSize;
uint32_t MemoryMapDescriptorVersion;
uint8_t debugMode; /* Bit field with behavior changes */
uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */
uint32_t deviceTreeP; /* Physical address of flattened device tree */
uint32_t deviceTreeLength; /* Length of flattened tree */
char CommandLine[BOOT_LINE_LENGTH];/* Passed in command line */
uint32_t keyStoreDataStart; /* physical address of key store data */
uint32_t keyStoreDataSize;
uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */
uint32_t efiRuntimeServicesPageCount;
uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */
uint32_t efiSystemTable; /* physical address of system table in runtime area */
uint64_t FSBFrequency;
uint32_t performanceDataSize;
uint32_t performanceDataStart; /* physical address of log */
uint32_t kaddr; /* Physical address of beginning of kernel text */
uint32_t ksize; /* Size of combined kernel text+data+efi */
uint64_tbootMemStart;
uint64_tbootMemSize;
uint64_t PhysicalMemorySize;
} boot_args_10x;
typedef struct boot_args_10x boot_args_common;
extern char assert_boot_args_107_size_is_4096[sizeof(boot_args_107) == 4096 ? 1 : -1];
#endif /* _PEXPERT_I386_BOOT_H */
branches/cparm/i386/libsaio/Makefile
4141
4242
4343
44
44
4545
4646
4747
......
5959
6060
6161
62
63
62
63
6464
6565
6666
......
6868
6969
7070
71
72
73
7174
7275
7376
cpu.o platform.o \
fake_efi.o \
device_inject.o pci_root.o \
convert.o acpi_tools.o smbios.o smp-imps.o
convert.o acpi_tools.o smbios.o smp-imps.o
# example for AcpiCodec
#SAIO_OBJS += acpi_codec.o acpicode.o ACPICodec.o acpidecode.o
#SAIO_OBJS += graphic_utils.o gui.o picopng.o GUI_module.o
# Options enabled by default:
#CFLAGS += -DNO_WIN_SUPPORT # -7200 bytes
SAIO_OBJS += ntfs.o msdos.o
#CFLAGS += -DNO_WIN_SUPPORT # -7744 bytes
SAIO_OBJS += ntfs.o msdos.o exfat.o
#CFLAGS += -DNO_LINUX_SUPPORT # -256 bytes
SAIO_OBJS += ext2fs.o
#CFLAGS += -DNO_OTHERS_BSD_SUPPORT # -512 bytes
SAIO_OBJS += freebsd.o openbsd.o
#CFLAGS += -DNO_HAIKU_SUPPORT # -256 bytes
SAIO_OBJS += befs.o
# Options disabled by default:
#CFLAGS += -DUFS_SUPPORT # +3616 bytes
branches/cparm/i386/libsaio/befs.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
/*
* befs.c
*
*
* Created by scorpius
* Copyright 2010
*
*/
#include "libsaio.h"
#include "sl.h"
#include "befs.h"
#define BeFSProbeSize2048
#define SUPER_BLOCK_MAGIC1 0x42465331 /* BFS1 */
#define SUPER_BLOCK_MAGIC2 0xdd121031
#define SUPER_BLOCK_MAGIC3 0x15b6830e
/* Find BeFS signature */
bool BeFSProbe (const void *buf)
{
return (OSReadLittleInt32(buf+0x220,0)==SUPER_BLOCK_MAGIC1);
}
/* Find BeFS volume label */
void BeFSGetDescription(CICell ih, char *str, long strMaxLen)
{
char * buf=malloc (BeFSProbeSize);
str[0]=0;
if (!buf)
return;
Seek(ih, 0);
Read(ih, (long)buf, BeFSProbeSize);
if (!BeFSProbe (buf))
{
free (buf);
return;
}
str[strMaxLen]=0;
strncpy (str, buf+0x200, MIN (strMaxLen, 32));
free (buf);
}
branches/cparm/i386/libsaio/befs.h
1
2
3
4
5
6
7
8
9
10
11
/*
* befs.h
*
*
* Created by scorpius
* Copyright 2010
*
*/
extern bool BeFSProbe (const void *buf);
extern void BeFSGetDescription(CICell ih, char *str, long strMaxLen);
branches/cparm/i386/libsaio/fdisk.h
5656
5757
5858
59
60
5961
6062
6163
#define FDISK_BOOTER 0xab /* Apple booter partition */
#define FDISK_OPENBSD 0xa6 /* OpenBSD FFS partition */
#define FDISK_FREEBSD 0xa5 /* FreeBSD UFS2 partition */
#define FDISK_BEFS0xeb /* Haiku BeFS partition */
/*
* Format of fdisk partion entry (if present).
*/
branches/cparm/i386/libsaio/ntfs.c
2525
2626
2727
28
29
30
31
32
33
2834
2935
3036
......
201207
202208
203209
204
210
211
212
213
214
215
216
217
205218
206219
207220
......
326339
327340
328341
329
330
342
343
344
345
331346
332347
333348
......
350365
351366
352367
368
369
370
371
353372
354373
#include "libsaio.h"
#include "sl.h"
/*
* dmazar, 14/7/2011 - support for EXFAT volume label reading
*/
#include "exfat.h"
//#define BYTE_ORDER_MARK0xFEFF
#include "ntfs_private.h"
*/
if (memcmp((const char *)boot->bf_sysid, "NTFS ", 8) != 0)
{
goto error;
/*
* Check for EXFAT. Finish by jumping to error to free buf,
* although if it is EXFAT then it's no an error.
*/
EXFATGetDescription(ih, str, strMaxLen);
goto error;
}
/*
boot = (struct bootfile *) buf;
// Check for NTFS signature
if ( memcmp((void*)boot->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) != 0 )
return -1;
if ( memcmp((void*)boot->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) != 0 ) {
// If not NTFS, maybe it is EXFAT
return EXFATGetUUID(ih, uuidStr);
}
// Check for non-null volume serial number
if( !boot->bf_volsn )
if (strncmp((const char *)part_bootfile->bf_sysid, NTFS_BBID, NTFS_BBIDLEN) == 0)
result = true;
// If not NTFS, maybe it is EXFAT
if (!result == false)
result = EXFATProbe(buffer);
return result;
}
branches/cparm/i386/libsaio/disk.c
7171
7272
7373
74
75
76
77
7478
7579
7680
......
951955
952956
953957
958
959
960
961
962
963
964
965
966
967
968
969
954970
955971
956972
......
11861202
11871203
11881204
1205
1206
1207
1208
11891209
11901210
11911211
......
18141834
18151835
18161836
1837
1838
1839
18171840
18181841
18191842
#include "freebsd.h"
#include "openbsd.h"
#endif
#ifndef NO_HAIKU_SUPPORT
#include "befs.h"
#endif
#include "xml.h"
#include "disk.h"
#include "modules.h"
0, kBIOSDevTypeHardDrive, 0);
break;
#endif
#ifndef NO_HAIKU_SUPPORT
case FDISK_BEFS:
bvr = newFDiskBVRef(
biosdev, partno,
part->relsect,
part,
0, 0, 0, 0, 0, 0,
BeFSGetDescription,
(BVFree)free,
0, kBIOSDevTypeHardDrive, 0);
break;
#endif
#ifndef NO_OTHERS_BSD_SUPPORT
case FDISK_FREEBSD:
bvr = newFDiskBVRef(
else if (OpenBSDProbe(probeBuffer))
result = FDISK_OPENBSD;
#endif
#ifndef NO_HAIKU_SUPPORT
else if (BeFSProbe(probeBuffer))
result = FDISK_BEFS;
#endif
#ifndef NO_WIN_SUPPORT
else if (NTFSProbe(probeBuffer))
result = FDISK_NTFS;
#endif
{ FDISK_HFS, "Apple HFS" },
{ FDISK_BOOTER, "Apple Boot/UFS" },
#ifndef NO_HAIKU_SUPPORT
{ FDISK_BEFS, "Haiku" },
#endif
{ 0xCD, "CD-ROM" },
{ 0x00, 0 } /* must be last */
};
branches/cparm/i386/libsaio/saio_types.h
239239
240240
241241
242
242243
243244
244245
kPartitionTypeEXT3 = 0x83,
kPartitionTypeFreeBSD = 0xa5,
kPartitionTypeOpenBSD = 0xa6,
kPartitionTypeBEFS = 0xEB
};
//#define BIOS_DEV_TYPE(d) ((d) & kBIOSDevTypeMask)
branches/cparm/i386/libsaio/fake_efi.c
170170
171171
172172
173
173
174174
175
176
177175
178176
179177
......
188186
189187
190188
191
192
189
193190
194191
195192
......
221218
222219
223220
224
225
221
226222
227223
228224
......
236232
237233
238234
239
235
240236
241
242237
243238
244239
......
450445
451446
452447
453
454
448
455449
456450
457451
......
473467
474468
475469
476
477
478
479
480
481
482
483
484
485
486
487
470
471
472
473
474
475
476
477
478
488479
489
490
491
492
480
481
482
483
484
485
486
487
488
493489
494
495
490
491
492
496493
497494
498495
......
602599
603600
604601
605
606
602
607603
608604
609605
......
708704
709705
710706
711
712
707
713708
714709
715710
......
732727
733728
734729
735
736730
737731
738732
739
740
733
741734
742735
743736
......
757750
758751
759752
760
753
761754
762755
763756
......
818811
819812
820813
821
814
822815
823
824816
825817
826818
......
830822
831823
832824
833
834
825
835826
836827
837828
......
854845
855846
856847
857
848
858849
859
850
851
860852
861
853
862854
863855
864856
......
886878
887879
888880
889
881
890882
891883
892884
......
906898
907899
908900
909
910
911
912
913
914
915
901
902
903
904
905
906
907
908
909
910
916911
917
918
919
912
913
914
915
916
917
920918
921
922
923
924
925
919
920
921
922
923
924
926925
927
928
929
930
931
932
933
934926
935927
936928
printf("Ran out of space for configuration tables (max = %d). Please, increase the reserved size in the code.\n", (int)MAX_CONFIGURATION_TABLE_ENTRIES);
return EFI_ABORTED;
}
}
if (archCpuType == CPU_TYPE_I386)
{
gEfiConfigurationTable64[i].VendorTable = (EFI_PTR32)table;
gNumTables64++ ;
}
Node *tableNode = DT__AddChild(gEfiConfigurationTableNode, mallocStringForGuid(pGuid));
// Use the pointer to the GUID we just stuffed into the system table
}
void finalizeEFIConfigTable(void )
{
{
if (archCpuType == CPU_TYPE_I386)
{
EFI_SYSTEM_TABLE_32 *efiSystemTable = gST32;
EFI_SYSTEM_TABLE_64 *efiSystemTable = gST64;
efiSystemTable->NumberOfTableEntries = gNumTables64;
efiSystemTable->ConfigurationTable = ptov64((EFI_PTR32)gEfiConfigurationTable64);
efiSystemTable->ConfigurationTable = ptov64((EFI_PTR32)gEfiConfigurationTable64);
}
EFI_ST_FIX_CRC32();
/* Setup ACPI without any patch. */
static EFI_STATUS setupAcpiNoMod()
{
{
EFI_STATUS ret = EFI_UNSUPPORTED;
ACPI_TABLE_RSDP* rsdp = (ACPI_TABLE_RSDP*)((uint32_t)local_rsd_p);
execute_hook("setupAcpiEfi", &ret, NULL, NULL, NULL, NULL, NULL);
if (ret != EFI_SUCCESS)
{
if (!FindAcpiTables(&acpi_tables))
{
printf("Failed to detect ACPI tables.\n");
return EFI_NOT_FOUND;
}
local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer));
{
ACPI_TABLE_FADT *FacpPointer = (acpi_tables.FacpPointer64 != (void*)0ul) ? (ACPI_TABLE_FADT *)acpi_tables.FacpPointer64 : (ACPI_TABLE_FADT *)acpi_tables.FacpPointer;
do {
if (ret != EFI_SUCCESS)
{
if (!FindAcpiTables(&acpi_tables))
{
printf("Failed to detect ACPI tables.\n");
ret = EFI_NOT_FOUND;
break;
}
uint8_t type = FacpPointer->PreferredProfile;
if (type <= MaxSupportedPMProfile)
Platform->Type = type;
}
local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer));
{
ACPI_TABLE_FADT *FacpPointer = (acpi_tables.FacpPointer64 != (void*)0ul) ? (ACPI_TABLE_FADT *)acpi_tables.FacpPointer64 : (ACPI_TABLE_FADT *)acpi_tables.FacpPointer;
uint8_t type = FacpPointer->PreferredProfile;
if (type <= MaxSupportedPMProfile)
Platform->Type = type;
}
ret = setupAcpiNoMod();
}
ret = setupAcpiNoMod();
}
} while (0);
return ret;
EFI_CHAR8*ret = getUUIDFromString(getStringForKey(kSystemID, &bootInfo->bootConfig));
if (!ret) // try bios dmi info UUID extraction
ret = getSmbiosUUID();
ret = getSmbiosUUID();
if (!ret)
{
{
Node *chosenNode = DT__FindNode("/chosen", true);
if (chosenNode)
{
{
DT__AddProperty(chosenNode, "boot-args", strlen(bootArgs->CommandLine)+1, (EFI_CHAR16*)bootArgs->CommandLine);
// "boot-uuid" MAIN GOAL IS SYMPLY TO BOOT FROM THE UUID SET IN THE DT AND DECREASE BOOT TIME, SEE IOKitBSDInit.cpp
}
// "boot-file" is not used by kextcache if there is no "boot-device-path" or if there is a valid "rootpath" ,
// but i let it by default since it may be used by another service
DT__AddProperty(chosenNode, "boot-file", strlen(bootInfo->bootFile)+1, (EFI_CHAR16*)bootInfo->bootFile);
if (bootInfo->adler32)
DT__AddProperty(chosenNode, "boot-kernelcache-adler32", sizeof(unsigned long), &bootInfo->adler32);
Node *runtimeServicesNode = DT__AddChild(efiNode, "runtime-services");
Node *kernelCompatibilityNode = 0; // ??? not sure that it should be used like that (because it's maybe the kernel capability and not the cpu capability)
if (gMacOSVersion[3] == '7')
if (gMacOSVersion[3] > '6')
{
kernelCompatibilityNode = DT__AddChild(efiNode, "kernel-compatibility");
DT__AddProperty(kernelCompatibilityNode, "i386", sizeof(uint32_t), (EFI_UINT32*)&DEVICE_SUPPORTED);
// because the DT_AddProperty function does not copy its args.
if (Platform->CPU.FSBFrequency != 0)
DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform->CPU.FSBFrequency);
DT__AddProperty(efiPlatformNode, FSB_Frequency_prop, sizeof(uint64_t), &Platform->CPU.FSBFrequency);
#if UNUSED
// Export TSC and CPU frequencies for use by the kernel or KEXTs
if (Platform->CPU.TSCFrequency != 0)
DT__AddProperty(efiPlatformNode, CPU_Frequency_prop, sizeof(uint64_t), &Platform->CPU.CPUFrequency);
#endif
// Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist
// Export system-id. Can be disabled with SystemId=No in com.apple.Boot.plist
if (getSystemID() == EFI_SUCCESS)
DT__AddProperty(efiPlatformNode, SYSTEM_ID_PROP, UUID_LEN, (EFI_UINT32*) Platform->sysid);
void setupSmbiosConfigFile(const char *filename)
{
static bool readSmbConfigFile = true;
//static bool readSmbConfigFile = true;
if (readSmbConfigFile == true)
if (&bootInfo->bootConfig == 0)
//if (readSmbConfigFile == true)
{
verbose("loading smbios plist\n");
chardirSpecSMBIOS[128] = "";
const char *override_pathname = NULL;
intlen = 0, err = 0;
{
verbose("No SMBIOS config file found.\n");
}
readSmbConfigFile = false;
//readSmbConfigFile = false;
}
}
if (chosenNode)
{
if (Platform->hardware_signature == 0xFFFFFFFF)
{
if (!local_rsd_p)
{
if (!FindAcpiTables(&acpi_tables)){
printf("Failed to detect ACPI tables.\n");
goto out;
{
do {
if (!local_rsd_p)
{
if (!FindAcpiTables(&acpi_tables)){
printf("Failed to detect ACPI tables.\n");
break;
}
local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer));
}
local_rsd_p = ((uint64_t)((uint32_t)acpi_tables.RsdPointer));
}
ACPI_TABLE_FACS *FacsPointer = (acpi_tables.FacsPointer64 != (void*)0ul) ? (ACPI_TABLE_FACS *)acpi_tables.FacsPointer64:(ACPI_TABLE_FACS *)acpi_tables.FacsPointer;
Platform->hardware_signature = FacsPointer->HardwareSignature;
} while (0);
ACPI_TABLE_FACS *FacsPointer = (acpi_tables.FacsPointer64 != (void*)0ul) ? (ACPI_TABLE_FACS *)acpi_tables.FacsPointer64:(ACPI_TABLE_FACS *)acpi_tables.FacsPointer;
Platform->hardware_signature = FacsPointer->HardwareSignature;
// Verify that we have a valid hardware signature
if (Platform->hardware_signature == 0xFFFFFFFF)
{
verbose("Warning: hardware_signature is invalid, defaulting to 0 \n");
Platform->hardware_signature = 0;
}
}
out:
// Verify that we have a valid hardware signature
if (Platform->hardware_signature == 0xFFFFFFFF)
{
verbose("Warning: hardware_signature is invalid, defaulting to 0 \n");
Platform->hardware_signature = 0;
}
DT__AddProperty(chosenNode, "machine-signature", sizeof(uint32_t), &Platform->hardware_signature);
}
branches/cparm/i386/libsaio/saio_internal.h
7878
7979
8080
81
8281
8382
8483
84
8585
8686
8787
/* bootstruct.c */
extern void initKernBootStruct(void);
extern void reserveKernBootStruct(void);
extern void copyKernBootStruct(void);
extern void finalizeBootStruct(void);
extern void reserveKernLegacyBootStruct(void);
extern void reserveKern107BootStruct(void);
/* cache.c */
extern void CacheReset();
branches/cparm/i386/boot2/boot.c
119119
120120
121121
122
122123
123124
124125
......
182183
183184
184185
186
187
188
189
190
191
185192
186193
187194
......
194201
195202
196203
197
198
204
205
199206
200207
201208
202209
203210
204
205
211
212
206213
207
208
214
215
216
217
218
209219
210220
211221
......
217227
218228
219229
220
230
221231
222
223
224
225
226232
227233
228234
......
329335
330336
331337
338
332339
333
334
340
341
342
343
335344
336
337345
338346
339347
......
342350
343351
344352
345
346
347
348
349
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
350371
351
352
353
354
355
356
372
373
357374
358
359
360375
361376
362377
......
686701
687702
688703
689
704
690705
691706
692707
......
838853
839854
840855
841
856
842857
843858
844859
static bool find_file_with_ext(const char* dir, const char *ext, const char * name_compare, size_t ext_size);
static bool found_extra_kext(void);
static void determineCpuArch(void);
static void init_pic(void);
void getKernelCachePath();
#endif
}
static void init_pic(void)
{
outb(0x21, 0xff); /* Maskout all interrupts Pic1 */
outb(0xa1, 0xff); /* Maskout all interrupts Pic2 */
}
//==========================================================================
// execKernel - Load the kernel image (mach-o) and jump to its entry point.
if(gMacOSVersion[3] <= '6')
{
bootArgs->Version = kBootArgsVersion1;
bootArgs->Revision = gMacOSVersion[3];
bootArgs->Header.Version = kBootArgsVersion1;
bootArgs->Header.Revision = gMacOSVersion[3];
}
else
{
#if kBootArgsVersion > 1
bootArgs->Version = kBootArgsVersion;
bootArgs->Revision = kBootArgsRevision;
bootArgs->Header.Version = kBootArgsVersion;
bootArgs->Header.Revision = kBootArgsRevision;
#else
bootArgs->Version = 2;
bootArgs->Revision = 0;
if(gMacOSVersion[3] == '7')
{
bootArgs->Header.Version = 2;
bootArgs->Header.Revision = 0;
}
#endif
}
(int *)&bootArgs->ksize );
if ( ret != 0 )
return ret;
return ret;
// Reserve space for boot args for 10.7 only (for 10.6 and earlier, we will convert (to legacy) the structure and reserve kernel memory for it later.)
if(gMacOSVersion[3] == '7')
reserveKernBootStruct();
// Load boot drivers from the specifed root path.
if (!gHaveKernelCache)
finalizeBootStruct();
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL, NULL, NULL);// Notify modules that the kernel is about to be started
if (gMacOSVersion[3] <= '6')
reserveKernLegacyBootStruct();
if (gMacOSVersion[3] <= '6')
reserveKernLegacyBootStruct();
else if (gMacOSVersion[3] == '7')
reserveKern107BootStruct();
execute_hook("Kernel Start", (void*)kernelEntry, (void*)bootArgs, NULL, NULL, NULL, NULL);// Notify modules that the kernel is about to be started
#if UNUSED
turnOffFloppy();
#endif
#include "apic.h"
IMPS_LAPIC_WRITE(LAPIC_LVT1, LAPIC_ICR_DM_NMI);
#endif
if (gMacOSVersion[3] <= '6')
{
// Jump to kernel's entry point. There's no going back now. XXX LEGACY OS XXX
startprog( kernelEntry, bootArgsLegacy );
switch (gMacOSVersion[3]) {
case '4':
case '5':
case '6':
// Jump to kernel's entry point. There's no going back now. XXX LEGACY OS XXX
startprog( kernelEntry, bootArgsLegacy );
break;
case '7':
init_pic();
// Jump to kernel's entry point. There's no going back now. XXX LION XXX
startprog( kernelEntry, bootArgs107 );
default:
#if DEBUG_BOOT
printf("Error: Unsupported Darwin version\n");
getc();
#endif
break;
}
outb(0x21, 0xff); /* Maskout all interrupts Pic1 */
outb(0xa1, 0xff); /* Maskout all interrupts Pic2 */
// Jump to kernel's entry point. There's no going back now. XXX LION XXX
startprog( kernelEntry, bootArgs );
// Should not be reached
// Not reached
return 0;
}
{
bootFile = gBootKernelCacheFile;
verbose("Loading kernel cache %s\n", bootFile);
if (gMacOSVersion[3] == '7')
if (gMacOSVersion[3] > '6')
{
ret = LoadThinFatFile(bootFile, &binary);
if (ret <= 0 && archCpuType == CPU_TYPE_X86_64)
}
else
{
if(gMacOSVersion[3] == '7')
if(gMacOSVersion[3] > '6')
{
sprintf(gBootKernelCacheFile, "%s", kDefaultCachePath);
}
branches/cparm/i386/boot2/drivers.c
762762
763763
764764
765
765
766766
767767
768768
printf("adler mismatch\n");
return -1;
}
if (((gBootMode & kBootModeSafe) == 0) && (gBootKernelCacheFile[0] != '\0') && gMacOSVersion[3] == '7')
if (((gBootMode & kBootModeSafe) == 0) && (gBootKernelCacheFile[0] != '\0') && gMacOSVersion[3] > '6')
bootInfo->adler32 = kernel_header->adler32;
}
branches/cparm/i386/boot2/mboot.c
322322
323323
324324
325
326
325
326
327327
328328
329329
This is the same assumption that initKernBootStruct makes.
We could check the multiboot info I guess, but why bother?
*/
boot_args temporaryBootArgsData;
bzero(&temporaryBootArgsData, sizeof(boot_args));
boot_args_common temporaryBootArgsData;
bzero(&temporaryBootArgsData, sizeof(boot_args_common));
bootArgs = &temporaryBootArgsData;
bootArgs->Video.v_display = VGA_TEXT_MODE;
branches/cparm/i386/boot2/options.c
588588
589589
590590
591
591
592592
593593
594594
// If the user is holding down a modifier key, enter safe mode.
if ((readKeyboardShiftFlags() & 0x0F) != 0) {
//gBootMode |= kBootModeSafe;
gBootMode |= kBootModeSafe;
}
// Checking user pressed keys
branches/cparm/i386/modules/GUI/gui.c
1212
1313
1414
15
16
17
18
1519
1620
1721
......
4852
4953
5054
55
5156
5257
5358
......
8994
9095
9196
97
98
9299
93100
94101
......
104111
105112
106113
114
115
116
117
118
119
120
121
107122
108123
124
125
126
127
128
129
130
131
109132
110
133
111134
112135
113136
114137
138
139
115140
116141
117142
......
155180
156181
157182
158
159
183
184
185
186
187
188
189
190
191
192
193
194
160195
161196
197
198
199
200
201
202
203
204
205
162206
163207
164208
165209
166210
167211
212
213
168214
169215
170216
......
299345
300346
301347
302
303
304
305
348
349
350
351
352
353
354
306355
307356
308357
......
336385
337386
338387
339
388
340389
341
342
343
344
345
390
391
392
393
394
395
396
397
398
399
400
401
346402
347403
348404
......
351407
352408
353409
354
410
411
412
413
355414
356
357
415
416
358417
359418
360419
......
366425
367426
368427
428
369429
370430
431
432
433
434
435
436
437
438
439
371440
372441
442
443
444
445
446
447
448
449
450
373451
374452
375453
376454
377455
378456
457
458
379459
380460
381461
......
9721052
9731053
9741054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
9751149
9761150
9771151
......
9831157
9841158
9851159
1160
1161
1162
9861163
9871164
988
989
990
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
9911188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
9921213
9931214
1215
9941216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
9951403
9961404
9971405
......
10151423
10161424
10171425
1426
1427
1428
1429
10181430
10191431
10201432
......
10371449
10381450
10391451
1040
1452
10411453
10421454
10431455
......
15301942
15311943
15321944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
15331964
15341965
15351966
1536
1537
1967
15381968
1539
1969
15401970
15411971
15421972
15431973
15441974
15451975
1546
1976
15471977
1548
1549
1978
1979
15501980
15511981
15521982
15531983
1554
1555
1984
1985
1986
1987
1988
15561989
1557
1558
1559
1560
1990
15611991
15621992
15631993
......
15651995
15661996
15671997
1568
1998
1999
2000
15692001
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
2002
2003
15882004
1589
1590
2005
2006
15912007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
15922018
15932019
2020
2021
2022
2023
15942024
15952025
15962026
......
16032033
16042034
16052035
1606
2036
16072037
16082038
16092039
......
16412071
16422072
16432073
2074
2075
2076
16442077
16452078
16462079
2080
2081
16472082
16482083
16492084
* cparm : cleaned
*/
/*
* cparm : add volume version detection
*/
#include "gui.h"
#include "GUI_appleboot.h"
#include "vers.h"
static void colorFont(font_t *font, uint32_t color);
static int initFont(font_t *font, image_t *data);
static void drawStrCenteredAt(char *text, font_t *font, pixmap_t *blendInto, position_t p);
static position_t drawChar(unsigned char ch, font_t *font, pixmap_t *blendInto, position_t p);
static void drawStr(char *ch, font_t *font, pixmap_t *blendInto, position_t p);
#if DEBUG
static int dprintf( window_t * window, const char * fmt, ...);
#define vram VIDEO(baseAddr)
#define TAB_PIXELS_WIDTH (font->chars[0]->width * 4) // tab = 4 spaces
int lasttime = 0; // we need this for animating maybe
extern int gDeviceCount;
iDeviceGeneric_o,
iDeviceHFS,
iDeviceHFS_o,
iDeviceHFS_Lion,
iDeviceHFS_Lion_o,
iDeviceHFS_SL,
iDeviceHFS_SL_o,
iDeviceHFS_Leo,
iDeviceHFS_Leo_o,
iDeviceHFS_Tiger,
iDeviceHFS_Tiger_o,
iDeviceHFSRAID,
iDeviceHFSRAID_o,
iDeviceHFSRAID_Lion,
iDeviceHFSRAID_Lion_o,
iDeviceHFSRAID_SL,
iDeviceHFSRAID_SL_o,
iDeviceHFSRAID_Leo,
iDeviceHFSRAID_Leo_o,
iDeviceHFSRAID_Tiger,
iDeviceHFSRAID_Tiger_o,
iDeviceEXT3,
iDeviceEXT3_o,
iDeviceEXT3_o,
iDeviceFreeBSD,
iDeviceFreeBSD_o,
iDeviceOpenBSD,
iDeviceOpenBSD_o,
iDeviceBEFS, /* Haiku detection and Icon credits to scorpius */
iDeviceBEFS_o, /* Haiku detection and Icon credits to scorpius */
iDeviceFAT,
iDeviceFAT_o,
iDeviceFAT16,
{.name = "device_generic", .image = NULL},
{.name = "device_generic_o", .image = NULL},
{.name = "device_hfsplus", .image = NULL},
{.name = "device_hfsplus_o", .image = NULL},
{.name = "device_hfsplus", .image = NULL},
{.name = "device_hfsplus_o", .image = NULL},
{.name = "device_hfsplus_lion", .image = NULL},
{.name = "device_hfsplus_lion_o", .image = NULL},
{.name = "device_hfsplus_sl", .image = NULL},
{.name = "device_hfsplus_sl_o", .image = NULL},
{.name = "device_hfsplus_leo", .image = NULL},
{.name = "device_hfsplus_leo_o", .image = NULL},
{.name = "device_hfsplus_tiger", .image = NULL},
{.name = "device_hfsplus_tiger_o", .image = NULL},
{.name = "device_hfsraid", .image = NULL},
{.name = "device_hfsraid_o", .image = NULL},
{.name = "device_hfsplus_raid_lion", .image = NULL},
{.name = "device_hfsplus_raid_lion_o", .image = NULL},
{.name = "device_hfsplus_raid_sl", .image = NULL},
{.name = "device_hfsplus_raid_sl_o", .image = NULL},
{.name = "device_hfsplus_raid_leo", .image = NULL},
{.name = "device_hfsplus_raid_leo_o", .image = NULL},
{.name = "device_hfsplus_raid_tiger", .image = NULL},
{.name = "device_hfsplus_raid_tiger_o", .image = NULL},
{.name = "device_ext3", .image = NULL},
{.name = "device_ext3_o", .image = NULL},
{.name = "device_freebsd", .image = NULL},
{.name = "device_freebsd_o", .image = NULL},
{.name = "device_openbsd", .image = NULL},
{.name = "device_openbsd_o", .image = NULL},
{.name = "device_befs", .image = NULL}, /* Haiku detection and Icon credits to scorpius */
{.name = "device_befs_o", .image = NULL}, /* Haiku detection and Icon credits to scorpius */
{.name = "device_fat", .image = NULL},
{.name = "device_fat_o", .image = NULL},
{.name = "device_fat16", .image = NULL},
}
if ((i = getImageIndexByName(image)) >= 0)
{
if (images[i].image == NULL) {
images[i].image = malloc(sizeof(pixmap_t));
}
{
if (images[i].image == NULL) {
images[i].image = malloc(sizeof(pixmap_t));
if (images[i].image == NULL) {
return 1;
}
}
sprintf(dirspec, "%s/%s/%s.png", src, theme_name, image);
width = 0;
return 0;
}
#endif
else if (alt_image != IMG_REQUIRED && images[alt_image].image->pixels != NULL)
else if (alt_image != IMG_REQUIRED)
{
// Using the passed alternate image for non-mandatory images.
// We don't clone the already existing pixmap, but using its properties instead!
images[i].image->width = images[alt_image].image->width;
images[i].image->height = images[alt_image].image->height;
images[i].image->pixels = images[alt_image].image->pixels;
if (images[alt_image].image->pixels != NULL) {
// Using the passed alternate image for non-mandatory images.
// We don't clone the already existing pixmap, but using its properties instead!
images[i].image->width = images[alt_image].image->width;
images[i].image->height = images[alt_image].image->height;
images[i].image->pixels = images[alt_image].image->pixels;
} else {
free(images[i].image);
images[i].image = NULL;
}
return 0;
}
else
printf("ERROR: GUI: could not open '%s/%s.png'!\n", theme_name, image);
sleep(2);
#endif
return 1;
free(images[i].image);
images[i].image = NULL;
return 1;
}
}
}
return 1;
}
LOADPNG(src, device_generic, IMG_REQUIRED);
LOADPNG(src, device_generic_o, iDeviceGeneric);
LOADPNG(src, device_hfsplus, iDeviceGeneric);
LOADPNG(src, device_hfsplus_o, iDeviceHFS);
LOADPNG(src, device_hfsplus_lion, iDeviceHFS_Lion);
LOADPNG(src, device_hfsplus_lion_o, iDeviceHFS_Lion_o);
LOADPNG(src, device_hfsplus_sl, iDeviceHFS_SL);
LOADPNG(src, device_hfsplus_sl_o, iDeviceHFS_SL_o);
LOADPNG(src, device_hfsplus_leo, iDeviceHFS_Leo);
LOADPNG(src, device_hfsplus_leo_o, iDeviceHFS_Leo_o);
LOADPNG(src, device_hfsplus_tiger, iDeviceHFS_Tiger);
LOADPNG(src, device_hfsplus_tiger_o, iDeviceHFS_Tiger_o);
LOADPNG(src, device_hfsraid, iDeviceGeneric);
LOADPNG(src, device_hfsraid_o, iDeviceHFSRAID);
LOADPNG(src, device_hfsplus_raid_lion, iDeviceHFSRAID_Lion);
LOADPNG(src, device_hfsplus_raid_lion_o, iDeviceHFSRAID_Lion_o);
LOADPNG(src, device_hfsplus_raid_sl, iDeviceHFSRAID_SL);
LOADPNG(src, device_hfsplus_raid_sl_o, iDeviceHFSRAID_SL_o);
LOADPNG(src, device_hfsplus_raid_leo, iDeviceHFSRAID_Leo);
LOADPNG(src, device_hfsplus_raid_leo_o, iDeviceHFSRAID_Leo_o);
LOADPNG(src, device_hfsplus_raid_tiger, iDeviceHFSRAID_Tiger);
LOADPNG(src, device_hfsplus_raid_tiger_o, iDeviceHFSRAID_Tiger_o);
LOADPNG(src, device_ext3, iDeviceGeneric);
LOADPNG(src, device_ext3_o, iDeviceEXT3);
LOADPNG(src, device_freebsd, iDeviceGeneric);
LOADPNG(src, device_freebsd_o, iDeviceFreeBSD);
LOADPNG(src, device_openbsd, iDeviceGeneric);
LOADPNG(src, device_openbsd_o, iDeviceOpenBSD);
LOADPNG(src, device_befs, iDeviceGeneric); /* Haiku detection and Icon credits to scorpius */
LOADPNG(src, device_befs_o, iDeviceBEFS); /* Haiku detection and Icon credits to scorpius */
LOADPNG(src, device_fat, iDeviceGeneric);
LOADPNG(src, device_fat_o, iDeviceFAT);
LOADPNG(src, device_fat16, iDeviceFAT);
return 1;
}
/*************************************************
*
* Volume Versioning Management
*/
volume_t* volumeList = NULL;
bool add_volume(char* Version, BVRef bvr)
{
volume_t* new_volume= malloc(sizeof(volume_t));
if (new_volume)
{
new_volume->next = volumeList;
volumeList = new_volume;
strlcpy(new_volume->version,Version,sizeof(new_volume->version)+1);
new_volume->bvr = bvr;
return true;
}
return false;
}
bool get_volume_version(char *str,BVRef bvr)
{
volume_t* volume = volumeList;
while(volume)
{
if (volume->bvr == bvr) {
strlcpy(str,volume->version,sizeof(volume->version)+1);
return true;
}
volume = volume->next;
}
return false;
}
static bool getOSVersionForVolume(char *str, BVRef bvr)
{
bool valid = false;
if (get_volume_version(str,bvr) == false)
{
char dirSpec[128];
char dirSpec2[128];
config_file_t systemVersion;
sprintf(dirSpec, "hd(%d,%d)/System/Library/CoreServices/SystemVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
sprintf(dirSpec2, "hd(%d,%d)/System/Library/CoreServices/ServerVersion.plist", BIOS_DEV_UNIT(bvr), bvr->part_no);
if (!loadConfigFile(dirSpec, &systemVersion))
{
valid = true;
}
else if (!loadConfigFile(dirSpec2, &systemVersion))
{
valid = true;
}
if (valid)
{
const char *val;
int len;
if (getValueForKey(kProductVersion, &val, &len, &systemVersion))
{
// getValueForKey uses const char for val
// so copy it and trim
*str = '\0';
strncat(str, val, MIN(len, 4));
add_volume(str, bvr);
}
else
valid = false;
}
}
else
{
valid = true;
}
return valid;
}
static bool is_image_loaded(int i)
{
return (images[i].image != NULL) ? true : false;
}
/*************************************************/
static void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected)
{
int devicetype;
switch (device->part_type)
{
case kPartitionTypeHFS:
{
char VolumeMacOSVersion[8];
#ifdef BOOT_HELPER_SUPPORT
// Use HFS or HFSRAID icon depending on bvr flags.
devicetype = (device->flags & kBVFlagBooter) ? iDeviceHFSRAID : iDeviceHFS;
#else
devicetype = iDeviceHFS;
if (device->flags & kBVFlagBooter) {
getOSVersionForRaidVolume(VolumeMacOSVersion,device);
switch (VolumeMacOSVersion[3]) {
case '7':
devicetype = is_image_loaded(iDeviceHFSRAID_Lion) ? iDeviceHFSRAID_Lion : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
break;
case '6':
devicetype = is_image_loaded(iDeviceHFSRAID_SL) ? iDeviceHFSRAID_SL : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
break;
case '5':
devicetype = is_image_loaded(iDeviceHFSRAID_Leo) ? iDeviceHFSRAID_Leo : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
break;
case '4':
devicetype = is_image_loaded(iDeviceHFSRAID_Tiger) ? iDeviceHFSRAID_Tiger : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
break;
default:
devicetype = is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
break;
}
} else
#endif
{
getOSVersionForVolume(VolumeMacOSVersion,device);
switch (VolumeMacOSVersion[3]) {
case '7':
devicetype = is_image_loaded(iDeviceHFS_Lion) ? iDeviceHFS_Lion : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
break;
case '6':
devicetype = is_image_loaded(iDeviceHFS_SL) ? iDeviceHFS_SL : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
break;
case '5':
devicetype = is_image_loaded(iDeviceHFS_Leo) ? iDeviceHFS_Leo : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
break;
case '4':
devicetype = is_image_loaded(iDeviceHFS_Tiger) ? iDeviceHFS_Tiger : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
break;
default:
devicetype = is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
break;
}
}
break;
}
case kPartitionTypeHPFS:
devicetype = is_image_loaded(iDeviceNTFS) ? iDeviceNTFS : iDeviceGeneric;// Use HPFS / NTFS icon
break;
case kPartitionTypeFAT16:
devicetype = is_image_loaded(iDeviceFAT16) ? iDeviceFAT16 : iDeviceGeneric;// Use FAT16 icon
break;
case kPartitionTypeFAT32:
devicetype = is_image_loaded(iDeviceFAT32) ? iDeviceFAT32 : iDeviceGeneric;// Use FAT32 icon
break;
case kPartitionTypeEXT3:
devicetype = is_image_loaded(iDeviceEXT3) ? iDeviceEXT3 : iDeviceGeneric;// Use EXT2/3 icon
break;
case kPartitionTypeFreeBSD:
devicetype = is_image_loaded(iDeviceFreeBSD) ? iDeviceFreeBSD : iDeviceGeneric;// Use FreeBSD icon
break;
case kPartitionTypeOpenBSD:
devicetype = is_image_loaded(iDeviceOpenBSD) ? iDeviceOpenBSD : iDeviceGeneric;// Use OpenBSD icon
break;
case kPartitionTypeBEFS: /* Haiku detection and Icon credits to scorpius */
devicetype = is_image_loaded(iDeviceBEFS) ? iDeviceBEFS : iDeviceGeneric;// Use BEFS / Haiku icon
break;
default:
devicetype = iDeviceGeneric;// Use Generic icon
break;
}
}
// Draw the selection image and use the next (device_*_o) image for the selected item.
if (isSelected)
{
blend(images[iSelection].image, buffer, centeredAt(images[iSelection].image, p));
devicetype++; // selec override image
}
// draw icon
blend( images[devicetype].image, buffer, centeredAt( images[devicetype].image, p ));
p.y += (images[iSelection].image->height / 2) + font_console.chars[0]->height;
// draw volume label
drawStrCenteredAt( device->label, &font_small, buffer, p);
}
#if 0
static void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected)
{
int devicetype;
if( diskIsCDROM(device) )
devicetype = iDeviceCDROM;// Use CDROM icon
else
{
switch (device->part_type)
{
case kPartitionTypeHFS:
{
bool hfs_img_replacement_found = false;
char VolumeMacOSVersion[8];
#ifdef BOOT_HELPER_SUPPORT
// Use HFS or HFSRAID icon depending on bvr flags.
if (device->flags & kBVFlagBooter) {
if (getOSVersionForRaidVolume(VolumeMacOSVersion,device))
{
int i ;
if (VolumeMacOSVersion[3] == '7') {
if ((i = getImageIndexByName("device_hfsplus_raid_lion")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '6') {
if ((i = getImageIndexByName("device_hfsplus_raid_sl")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '5') {
if ((i = getImageIndexByName("device_hfsplus_raid_leo")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '4') {
if ((i = getImageIndexByName("device_hfsplus_raid_tiger")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
}
}
switch (VolumeMacOSVersion[3]) {
case '7':
devicetype = (hfs_img_replacement_found) ? iDeviceHFSRAID_Lion : iDeviceHFSRAID;
break;
case '6':
devicetype = (hfs_img_replacement_found) ? iDeviceHFSRAID_SL : iDeviceHFSRAID;
break;
case '5':
devicetype = (hfs_img_replacement_found) ? iDeviceHFSRAID_Leo : iDeviceHFSRAID;
break;
case '4':
devicetype = (hfs_img_replacement_found) ? iDeviceHFSRAID_Tiger : iDeviceHFSRAID;
break;
default:
devicetype = iDeviceHFSRAID;
break;
}
} else
#endif
{
if (getOSVersionForVolume(VolumeMacOSVersion,device))
{
int i ;
if (VolumeMacOSVersion[3] == '7') {
if ((i = getImageIndexByName("device_hfsplus_lion")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '6') {
if ((i = getImageIndexByName("device_hfsplus_sl")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '5') {
if ((i = getImageIndexByName("device_hfsplus_leo")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
} else if (VolumeMacOSVersion[3] == '4') {
if ((i = getImageIndexByName("device_hfsplus_tiger")) >= 0)
{
if (images[i].image != NULL) {
hfs_img_replacement_found = true;
}
}
}
}
switch (VolumeMacOSVersion[3]) {
case '7':
devicetype = (hfs_img_replacement_found) ? iDeviceHFS_Lion : iDeviceHFS;
break;
case '6':
devicetype = (hfs_img_replacement_found) ? iDeviceHFS_SL : iDeviceHFS;
break;
case '5':
devicetype = (hfs_img_replacement_found) ? iDeviceHFS_Leo : iDeviceHFS;
break;
case '4':
devicetype = (hfs_img_replacement_found) ? iDeviceHFS_Tiger : iDeviceHFS;
break;
default:
devicetype = iDeviceHFS;
break;
}
}
break;
}
case kPartitionTypeHPFS:
devicetype = iDeviceNTFS;// Use HPFS / NTFS icon
break;
devicetype = iDeviceOpenBSD;// Use OpenBSD icon
break;
case kPartitionTypeBEFS: /* Haiku detection and Icon credits to scorpius */
devicetype = iDeviceBEFS;// Use BEFS / Haiku icon
break;
default:
devicetype = iDeviceGeneric;// Use Generic icon
break;
drawStrCenteredAt( device->label, &font_small, buffer, p);
}
#endif
void drawDeviceList (int start, int end, int selection)
{
int i;
return 1;
}
pixmap_t* charToPixmap(unsigned char ch, font_t *font) {
unsigned int cha = (unsigned int)ch - 32;
if (cha >= font->count)
// return ? if the font for the char doesn't exists
cha = '?' - 32;
return font->chars[cha] ? font->chars[cha] : NULL;
}
static position_t drawChar(unsigned char ch, font_t *font, pixmap_t *blendInto, position_t p) {
pixmap_t* pm = charToPixmap(ch, font);
if (pm && ((p.x + pm->width) < blendInto->width))
{
blend(pm, blendInto, p);
return pos(p.x + pm->width, p.y);
}
else
return p;
}
static void drawStr(char *ch, font_t *font, pixmap_t *blendInto, position_t p)
{
int i=0;
int y=0; // we need this to support multilines '\n'
int x=0;
position_t current_pos = pos(p.x, p.y);
for(i=0;i<strlen(ch);i++)
for (i=0; i < strlen(ch); i++)
{
int cha=(int)ch[i];
cha-=32;
// newline ?
if( ch[i] == '\n' )
if ( ch[i] == '\n' )
{
x = 0;
y += font->height;
current_pos.x = p.x;
current_pos.y += font->height;
continue;
}
// tab ?
if( ch[i] == '\t' )
x+=(font->chars[0]->width*5);
if ( ch[i] == '\t' )
{
current_pos.x += TAB_PIXELS_WIDTH;
continue;
}
if(font->chars[cha])
blend(font->chars[cha], blendInto, pos(p.x+x, p.y+y));
x += font->chars[cha]->width;
current_pos = drawChar(ch[i], font, blendInto, current_pos);
}
}
{
int i = 0;
int width = 0;
int max_width = 0;
int height = font->height;
// calculate the width in pixels
for(i=0;i<strlen(text);i++)
width += font->chars[text[i]-32]->width;
p.x = ( p.x - ( width / 2 ) );
p.y = ( p.y - ( font->height / 2 ) );
if ( p.x == -6 )
{
p.x = 0;
}
for(i=0;i<strlen(text);i++)
{
int cha=(int)text[i];
cha-=32;
if(font->chars[cha])
for (i=0; i < strlen(text); i++) {
if (text[i] == '\n')
{
blend(font->chars[cha], blendInto, p);
p.x += font->chars[cha]->width;
width = 0;
height += font->height;
}
else if (text[i] == '\t')
width += TAB_PIXELS_WIDTH;
else
{
pixmap_t* pm = charToPixmap(text[i], font);
if (pm)
width += pm->width;
}
if (width > max_width)
max_width = width;
}
p.x = ( p.x - ( max_width / 2 ) );
p.y = ( p.y - ( height / 2 ) );
drawStr(text, font, blendInto, p);
}
static int initFont(font_t *font, image_t *data)
font->height = data->image->height;
for( x = 0; x < data->image->width; x++)
for( x = 0; x < data->image->width && count < CHARACTERS_COUNT; x++)
{
start = end;
}
}
for (x = count; x < CHARACTERS_COUNT; x++)
font->chars[x] = NULL;
if(monospaced)
font->width = 0;
font->count = count;
return 0;
}
branches/cparm/i386/modules/GUI/gui.h
7070
7171
7272
73
74
75
76
77
78
79
80
81
7382
7483
7584
7685
7786
7887
88
7989
8090
8191
......
130140
131141
132142
133
134143
135144
136145
137146
138
139
147
140148
141
142149
143150
144151
145
146152
147153
148154
149155
150156
151
152157
153158
154159
......
156161
157162
158163
159
160
161
162164
} image_t;
/*
* Volume structure.
*/
typedef struct volume_t {
charversion[8];
BVRefbvr;
struct volume_t* next;
} volume_t;
/*
* Font structure.
*/
typedef struct {
uint16_theight;// Font Height
uint16_twidth;// Font Width for monospace font only
pixmap_t*chars[CHARACTERS_COUNT];
uint16_t count; // Number of chars in font
} font_t;
/*
int initGUI();
//int startGUI();
void drawBootGraphics(void);
void drawBackground();
void drawLogo();
//void setupDeviceList(config_file_t *theme);
//void drawDeviceIcon(BVRef device, pixmap_t *buffer, position_t p, bool isSelected);
void drawDeviceList(int start, int end, int selection);
//void drawProgressBar(pixmap_t *blendInto, uint16_t width, position_t p, uint8_t progress);
void showInfoBox(char *title, char *text);
//int dprintf( window_t * window, const char * fmt, ...);
int gprintf( window_t * window, const char * fmt, ...);
int vprf(const char * fmt, va_list ap);
int drawInfoMenu();
int updateInfoMenu(int key);
//void drawInfoMenuItems();
void showGraphicBootPrompt();
void clearGraphicBootPrompt();
void updateVRAM();
//void drawStr(char *ch, font_t *font, pixmap_t *blendInto, position_t p);
//void drawStrCenteredAt(char *ch, font_t *font, pixmap_t *blendInto, position_t p);
#endif /* !__BOOT2_GUI_H */
branches/cparm/README
11
22
3
4
3
Chameleon is a Darwin/XNU boot loader based on Apple's boot-132.
WARNING: FOR NOW, THIS PROJECT IS NOT YET FULLY COMPATIBLE WITH XCODE4
(AFAIK ONLY THE MODULES GUI AND SMBIOSGETTERS WILL NOT WORK WITH XCODE4, EVEN IF THEY ARE BUILT WITHOUT ANY ERRORS)
WARNING: THIS PROJECT IS NOT COMPATIBLE WITH XCODE4

Archive Download the corresponding diff file

Revision: 1724