Chameleon

Chameleon Commit Details

Date:2011-06-25 00:32:32 (12 years 9 months ago)
Author:Azimutz
Commit:1055
Parents: 1054
Message:Sync with trunk (r1053).
Changes:
M/branches/azimutz/trunkAutoResolution/i386/util/fdisk/cmd.c
M/branches/azimutz/trunkAutoResolution/i386/boot2/options.c
M/branches/azimutz/trunkAutoResolution/i386/libsa/prf.c
M/branches/azimutz/trunkAutoResolution/i386/libsaio/console.c
M/branches/azimutz/trunkAutoResolution/i386/boot2/graphics.c
M/branches/azimutz/trunkAutoResolution/i386/boot0/boot0.s
M/branches/azimutz/trunkAutoResolution
M/branches/azimutz/trunkAutoResolution/i386/boot2/boot.c
M/branches/azimutz/trunkAutoResolution/i386/libsaio/ext2fs.c
M/branches/azimutz/trunkAutoResolution/i386/libsaio/sys.c
M/branches/azimutz/trunkAutoResolution/i386/libsaio/load.c
M/branches/azimutz/trunkAutoResolution/i386/libsaio/biosfn.c
M/branches/azimutz/trunkAutoResolution/i386/libsa/qsort.c
M/branches/azimutz/trunkAutoResolution/i386/boot2/drivers.c
M/branches/azimutz/trunkAutoResolution/i386/boot0/chain0.s
M/branches/azimutz/trunkAutoResolution/i386/libsaio/saio_types.h
M/branches/azimutz/trunkAutoResolution/i386/libsaio/msdos.c
M/branches/azimutz/trunkAutoResolution/i386/libsa/memory.h
M/branches/azimutz/trunkAutoResolution/i386/libsaio/spd.c
M/branches/azimutz/trunkAutoResolution/i386/boot2/gui.c
M/branches/azimutz/trunkAutoResolution/i386/libsaio/cpu.c
M/branches/azimutz/trunkAutoResolution/i386/libsaio/disk.c

File differences

branches/azimutz/trunkAutoResolution/i386/libsaio/console.c
263263
264264
265265
266
267
266
268267
void pause()
{
printf("Press a key to continue...\n");
getchar(); //getc(); //Azi: getc works here because the function is up above; changed for now.
// replace getchar() by pause() ??
getchar(); // replace getchar() by pause() ?? were useful...?
}
branches/azimutz/trunkAutoResolution/i386/libsaio/ext2fs.c
3737
3838
3939
40
40
4141
4242
return;
}
str[strMaxLen]=0;
strncpy (str, buf+0x478, min (strMaxLen, 16));
strncpy (str, buf+0x478, MIN(strMaxLen, 16));
free (buf);
}
branches/azimutz/trunkAutoResolution/i386/libsaio/spd.c
255255
256256
257257
258
258
259259
260260
261261
......
268268
269269
270270
271
271
272
272273
273274
274275
int i, speed;
uint8_t spd_size, spd_type;
uint32_t base, mmio, hostc;
bool dump = false;
// bool dump = false;
RamSlotInfo_t* slot;
uint16_t cmd = pci_config_read16(smbus_dev->dev.addr, 0x04);
verbose("Scanning SMBus [%04x:%04x], mmio: 0x%x, ioport: 0x%x, hostc: 0x%x\n",
smbus_dev->vendor_id, smbus_dev->device_id, mmio, base, hostc);
getBoolForKey("DumpSPD", &dump, &bootInfo->bootConfig);
//Azi: no use for this!
// getBoolForKey("DumpSPD", &dump, &bootInfo->bootConfig);
// needed at least for laptops
bool fullBanks = Platform.DMI.MemoryModules == Platform.DMI.CntMemorySlots;
branches/azimutz/trunkAutoResolution/i386/libsaio/sys.c
451451
452452
453453
454
454
455455
456456
457457
if ((iob[i].i_flgs != F_ALLOC) || (i == fdesc)) {
continue;
}
io->i_buf = max(iob[i].i_filesize + iob[i].i_buf, io->i_buf);
io->i_buf = MAX(iob[i].i_filesize + iob[i].i_buf, io->i_buf);
}
// Load entire file into memory. Unnecessary open() calls must be avoided.
branches/azimutz/trunkAutoResolution/i386/libsaio/load.c
151151
152152
153153
154
155
154
155
156156
157157
158158
case LC_SEGMENT:
ret = DecodeSegment(cmdBase, &load_addr, &load_size);
if (ret == 0 && load_size != 0 && load_addr >= KERNEL_ADDR) {
vmaddr = min(vmaddr, load_addr);
vmend = max(vmend, load_addr + load_size);
vmaddr = MIN(vmaddr, load_addr);
vmend = MAX(vmend, load_addr + load_size);
}
break;
branches/azimutz/trunkAutoResolution/i386/libsaio/cpu.c
5656
5757
5858
59
59
6060
6161
6262
......
170170
171171
172172
173
173
174174
175175
176176
*/
if((tscEnd - tscStart) <= CALIBRATE_TIME_MSEC)
continue;
// tscDelta = min(tscDelta, (tscEnd - tscStart))
// tscDelta = MIN(tscDelta, (tscEnd - tscStart))
if( (tscEnd - tscStart) < tscDelta )
tscDelta = tscEnd - tscStart;
}
strlcpy(p->CPU.BrandString,s, sizeof(p->CPU.BrandString));
if (!strncmp(p->CPU.BrandString, CPU_STRING_UNKNOWN, min(sizeof(p->CPU.BrandString), strlen(CPU_STRING_UNKNOWN) + 1))) {
if (!strncmp(p->CPU.BrandString, CPU_STRING_UNKNOWN, MIN(sizeof(p->CPU.BrandString), strlen(CPU_STRING_UNKNOWN) + 1))) {
/*
* This string means we have a firmware-programmable brand string,
* and the firmware couldn't figure out what sort of CPU we have.
branches/azimutz/trunkAutoResolution/i386/libsaio/disk.c
17661766
17671767
17681768
1769
1769
17701770
17711771
17721772
if ( matchVolumeToString(bvr, volStart, volLen) )
{
strncat(str, aliasStart, min(strMaxLen, aliasLen));
strncat(str, aliasStart, MIN(strMaxLen, aliasLen));
free(aliasList);
return true;
branches/azimutz/trunkAutoResolution/i386/libsaio/biosfn.c
509509
510510
511511
512
512
513513
514514
515515
printf("media_type: %x\n", pkt.media_type);
printf("drive_num: %x\n", pkt.drive_num);
printf("device_spec: %x\n", pkt.device_spec);
printf("press a key->\n"); getchar();
pause();
#endif
/* Some BIOSes erroneously return cf = 1 */
branches/azimutz/trunkAutoResolution/i386/libsaio/saio_types.h
233233
234234
235235
236
237
236
237
238
239
240
241
242
238243
239
240
241
244
245
242246
243247
248
244249
245250
246251
247
252
248253
249254
250255
DEV_EN = 3
};
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
/*
* min/max Macros.
*
* Azi: defined on <sys/param.h>, i386/include/IOKit/IOLib.h (min/max, lower case), and others...
*/
#ifndef MIN
#defineMIN(a,b) ( ((a) < (b)) ? (a) : (b) )
#endif
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#ifndef MAX
#defineMAX(a,b) ( ((a) > (b)) ? (a) : (b) )
#endif
/*Azi: not used
#defineround2(x, m)(((x) + (m / 2)) & ~(m - 1))
#define roundup2(x, m) (((x) + m - 1) & ~(m - 1))
#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)
#define MAKEKERNDEV(t, u, p) MAKEBOOTDEV(t, 0, 0, u, p)*/
enum {
kNetworkDeviceType = kBIOSDevTypeNetwork,
branches/azimutz/trunkAutoResolution/i386/libsaio/msdos.c
4545
4646
4747
48
48
4949
5050
51
5251
5352
5453
......
6059
6160
6261
62
63
6364
6465
6566
......
767768
768769
769770
770
771
771772
772773
773
774
774775
775776
776777
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define tolower(c) (((c)>='A' && c<='Z')?((c) | 0x20):(c))
#include "libsaio.h"
#include "sl.h"
#include "msdos_private.h"
#include "msdos.h"
#defineCLUST_RSRVD160xfff8/* reserved cluster range */
#defineCLUST_RSRVD120xff8/* reserved cluster range */
#define tolower(c) (((c)>='A' && c<='Z')?((c) | 0x20):(c))
static int msdosressector=0;
static int msdosnfats = 0;
static int msdosfatsecs = 0;
if (length==0 || length>size-offset)
toread=size-offset;
wastoread=toread;
bcopy (buf+(offset%msdosclustersize),ptr,min(msdosclustersize-(offset%msdosclustersize), toread));
bcopy (buf+(offset%msdosclustersize),ptr,MIN(msdosclustersize-(offset%msdosclustersize), toread));
ptr+=msdosclustersize-(offset%msdosclustersize);
toread-=msdosclustersize-(offset%msdosclustersize);
while (toread>0 && msdosreadcluster (ih, (uint8_t *)ptr, min(msdosclustersize,toread), &cluster))
while (toread>0 && msdosreadcluster (ih, (uint8_t *)ptr, MIN(msdosclustersize,toread), &cluster))
{
ptr+=msdosclustersize;
toread-=msdosclustersize;
branches/azimutz/trunkAutoResolution/i386/boot0/chain0.s
697697
698698
699699
700
700
times 510-($-$$) db 0
dw kBootSignature
;END
; END
branches/azimutz/trunkAutoResolution/i386/boot0/boot0.s
317317
318318
319319
320
321
320
321
322322
323
323
324324
325325
326
326
327327
328
329
328
329
330330
331331
332
332
333333
334334
335335
336336
337
337
338338
339
340
339
340
341341
342342
343
344
343
344
345345
346
346
347347
348348
349349
......
359359
360360
361361
362
362
363363
364364
365365
......
369369
370370
371371
372
372
373373
374374
375375
......
406406
407407
408408
409
409
410410
411411
412412
......
496496
497497
498498
499
500499
500
501501
502502
503503
.Pass1:
%if CONFIG_BOOT0_HFSFIRST
cmp BYTE [si + part.type], kPartTypeHFS; In pass 1 we're going to find a HFS+ partition
; equipped with boot1h in its boot record
; regardless if it's active or not.
; equipped with boot1h in its boot record
; regardless if it's active or not.
jne .continue
mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
movdh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
%else
cmp BYTE [si + part.bootid], kPartActive; In pass 1 we are walking on the standard path
; by trying to hop on the active partition.
; by trying to hop on the active partition.
jne .continue
xor dh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
xor dh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
%endif
jmp .tryToBoot
jmp .tryToBoot
.Pass2:
%if CONFIG_BOOT0_HFSFIRST
cmp BYTE [si + part.bootid], kPartActive; In pass 2 we are walking on the standard path
; by trying to hop on the active partition.
; by trying to hop on the active partition.
jne .continue
xor dh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
xordh, dh ; Argument for loadBootSector to skip HFS+ partition
; signature check.
%else
cmp BYTE [si + part.type], kPartTypeHFS; In pass 2 we're going to find a HFS+ partition
; equipped with boot1h in its boot record
; regardless if it's active or not.
; equipped with boot1h in its boot record
; regardless if it's active or not.
jne .continue
mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
mov dh, 1 ; Argument for loadBootSector to check HFS+ partition signature.
%endif
DebugChar('*')
jmp SHORT initBootLoader
.continue:
add si, BYTE part_size; advance SI to next partition entry
add si, BYTE part_size ; advance SI to next partition entry
loop .loop ; loop through all partition entries
;
;
dec bl
jnz .switchPass2; didn't find Protective MBR before
call checkGPT
call checkGPT
.switchPass2:
;
;
checkGPT:
push bx
mov di, kLBA1Buffer; address of GUID Partition Table Header
cmp DWORD [di], kGPTSignatureLow; looking for 'EFI '
jne .exit; not found. Giving up.
.exit:
pop bx
ret; no more GUID partitions. Giving up.
;--------------------------------------------------------------------------
; loadBootSector - Load boot sector
;
branches/azimutz/trunkAutoResolution/i386/boot2/graphics.c
4444
4545
4646
47
48
4947
5048
5149
uint8_t *previewSaveunder = 0;
#define VIDEO(x) (bootArgs->Video.v_ ## x)
#define MIN(x, y) ((x) < (y) ? (x) : (y))
//==========================================================================
// getVBEInfoString
branches/azimutz/trunkAutoResolution/i386/boot2/drivers.c
182182
183183
184184
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
185
227186
228187
229188
230
231
189
190
232191
233
192
234193
235194
236195
237196
238197
239
240
241
242
243
198
199
200
201
202
244203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
245220
246221
247
248
222
249223
250224
251225
252226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
253243
254244
255245
}
}
else if ( gBootFileType == kBlockDeviceType )
{
if (!gHaveKernelCache)
{
// Non-prelinked kernel, load system mkext.
// NOTE: In it's default state, XNU cannot be both prelinked, and load additional drivers
// from the bootloader. There is, however, a patch that changes this and allows
// for both to occure.
// Also try to load Extensions from boot helper partitions.
if (gBootVolume->flags & kBVFlagBooter)
{
strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/");
FileLoadDrivers(dirSpecExtra, 0);
}
}
}
if (gMKextName[0] != '\0')
{
verbose("LoadDrivers: Loading from [%s]\n", gMKextName);
if ( LoadDriverMKext(gMKextName) != 0 )
{
error("Could not load %s\n", gMKextName);
return -1;
}
}
else
{
strcpy(gExtensionsSpec, dirSpec);
strcat(gExtensionsSpec, "System/Library/");
FileLoadDrivers(gExtensionsSpec, 0);
}
}
//Azi: dependencies still need to be added to E/E.mkext!!
{
// First try to load Extra extensions from the ramdisk if isn't aliased as bt(0,0).
if (gRAMDiskVolume && !gRAMDiskBTAliased)
{
strcpy(dirSpecExtra, "rd(0,0)/Extra/");
FileLoadDrivers(dirSpecExtra, 0);
strcpy(dirSpecExtra, "rd(0,0)/Extra/");
FileLoadDrivers(dirSpecExtra, 0);
}
// Next try to load Extra extensions from the selected root partition.
strcpy(dirSpecExtra, "/Extra/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// If failed, then try to load Extra extensions from the boot partition
// in case we have a separate booter partition or a bt(0,0) aliased ramdisk.
if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no)
|| (gRAMDiskVolume && gRAMDiskBTAliased) )
{
// Next try a specfic OS version folder ie 10.5
// in case we have a separate booter partition or a bt(0,0) aliased ramdisk.
if ( !(gBIOSBootVolume->biosdev == gBootVolume->biosdev && gBIOSBootVolume->part_no == gBootVolume->part_no)
|| (gRAMDiskVolume && gRAMDiskBTAliased) )
{
// Next try a specfic OS version folder ie 10.5
sprintf(dirSpecExtra, "bt(0,0)/Extra/%s/", &gMacOSVersion);
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next we'll try the base
strcpy(dirSpecExtra, "bt(0,0)/Extra/");
FileLoadDrivers(dirSpecExtra, 0);
}
}
}
// Also try to load Extensions from boot helper partitions.
if (gBootVolume->flags & kBVFlagBooter)
{
strcpy(dirSpecExtra, "/com.apple.boot.P/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
strcpy(dirSpecExtra, "/com.apple.boot.R/System/Library/");
if (FileLoadDrivers(dirSpecExtra, 0) != 0)
{
// Next we'll try the base
strcpy(dirSpecExtra, "bt(0,0)/Extra/");
strcpy(dirSpecExtra, "/com.apple.boot.S/System/Library/");
FileLoadDrivers(dirSpecExtra, 0);
}
}
}
if (gMKextName[0] != '\0')
{
verbose("LoadDrivers: Loading from [%s]\n", gMKextName);
if ( LoadDriverMKext(gMKextName) != 0 )
{
error("Could not load %s\n", gMKextName);
return -1;
}
}
else
{
strcpy(gExtensionsSpec, dirSpec);
strcat(gExtensionsSpec, "System/Library/");
FileLoadDrivers(gExtensionsSpec, 0);
}
}
else
{
branches/azimutz/trunkAutoResolution/i386/boot2/boot.c
157157
158158
159159
160
160
161
161162
162163
163164
......
577578
578579
579580
580
581
581582
582583
583584
execute_hook("DecodedKernel", (void*)binary, NULL, NULL, NULL);
// Load boot drivers from the specifed root path.
LoadDrivers("/");
if (!gHaveKernelCache)
LoadDrivers("/");
clearActivityIndicator();
break;
}
if(getBoolForKey(kUseKernelCache, &usecache, &bootInfo->bootConfig) && usecache) {
if(getBoolForKey(kUseKernelCache, &usecache, &bootInfo->bootConfig)) {
if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) {
strlcpy(gBootKernelCacheFile, val, len+1);
}
branches/azimutz/trunkAutoResolution/i386/boot2/gui.c
2323
2424
2525
26
27
28
2926
3027
3128
3229
3330
3431
35
3632
37
3833
3934
4035
#define LOADPNG(img, alt_img) if (loadThemeImage(#img, alt_img) != 0) { return 1; }
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define VIDEO(x) (bootArgs->Video.v_ ## x)
#define vram VIDEO(baseAddr)
int lasttime = 0; // we need this for animating maybe
extern int gDeviceCount;
/*
* ATTENTION: the enum and the following array images[] MUST match !!!
*/
branches/azimutz/trunkAutoResolution/i386/boot2/options.c
324324
325325
326326
327
327
328328
329329
330330
331
331
332332
333333
334334
......
901901
902902
903903
904
904
905905
906906
907907
......
11121112
11131113
11141114
1115
1115
11161116
11171117
11181118
gMenuHeight= height;
gMenuItemCount= count;
gMenuTop= 0;
gMenuBottom= min( count, height ) - 1;
gMenuBottom= MIN( count, height ) - 1;
gMenuSelection= selection;
gMenuStart= 0;
gMenuEnd = min( count, gui.maxdevices ) - 1;
gMenuEnd = MIN( count, gui.maxdevices ) - 1;
// If the selected item is not visible, shift the list down.
printf("Use \30\31 keys to select the startup volume.");
}
showMenu( menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems );
nextRow += min( gDeviceCount, kMenuMaxItems ) + 3;
nextRow += MIN( gDeviceCount, kMenuMaxItems ) + 3;
}
// Show the boot prompt.
if (gDeviceCount) {
printf("Use \30\31 keys to select the startup volume.");
showMenu(menuItems, gDeviceCount, selectIndex, kMenuTopRow + 2, kMenuMaxItems);
nextRow += min(gDeviceCount, kMenuMaxItems) + 3;
nextRow += MIN(gDeviceCount, kMenuMaxItems) + 3;
}
showPrompt = (gDeviceCount == 0) || (menuBVR->flags & kBVFlagNativeBoot);
branches/azimutz/trunkAutoResolution/i386/libsa/prf.c
9393
9494
9595
96
96
9797
9898
9999
void prf(
char *fmt,
unsigned int *adx,
int (*putfn_p)(),
int (*putfn_p)(),
void *putfn_arg
)
{
branches/azimutz/trunkAutoResolution/i386/libsa/qsort.c
5757
5858
5959
60
6061
6162
6263
6364
64
65
6665
6766
6867
......
178177
179178
180179
181
180
182181
183
182
184183
185184
186185
#include <sys/types.h>
#include <stdlib.h>
#include "saio_types.h" //Azi: MIN/MAX
static inline char*med3 __P((char *, char *, char *, int (*)()));
static inline void swapfunc __P((char *, char *, int, int));
#define min(a, b)(a) < (b) ? a : b
/*
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
*/
}
pn = a + n * es;
r = min(pa - (char *)a, pb - pa);
r = MIN(pa - (char *)a, pb - pa);
vecswap(a, pb - r, r);
r = min(pd - pc, (pn - pd) - (int)es);
r = MIN(pd - pc, (pn - pd) - (int)es);
vecswap(pb, pn - r, r);
if ((r = pb - pa) > (int)es)
qsort(a, r / es, es, cmp);
branches/azimutz/trunkAutoResolution/i386/libsa/memory.h
4848
4949
5050
51
52
51
52
5353
54
55
54
55
5656
57
58
57
58
5959
60
60
6161
62
63
62
63
6464
65
65
6666
6767
6868
# define BASE_SEG BOOT2_SEG
#endif
#define STACK_SEG 0x1000 // zef: old STACK_SEG 0x5000
#define STACK_OFS 0xFFF0 // stack pointer
#define STACK_SEG0x1000// zef: old STACK_SEG 0x5000
#define STACK_OFS0xFFF0// stack pointer
#define BOOT1U_SEG 0x1000
#define BOOT1U_OFS 0x0200
#define BOOT1U_SEG0x1000
#define BOOT1U_OFS0x0200
#define BOOT2_SEG 0x2000
#define BOOT2_OFS 0x0200 // 512 byte disk sector offset
#define BOOT2_SEG0x2000
#define BOOT2_OFS0x0200// 512 byte disk sector offset
#define BOOT2_MAX_LENGTH 0x6FE00 // Maximum size for boot2 is currentl 447kb
#define BOOT2_MAX_LENGTH0x6FE00// Maximum size for boot2 is currentl 447kb
#define BIOS_ADDR 0x8000 // BIOS disk I/O buffer
#define BIOS_LEN 0x8000 // 32K - divisible by 512 and 2048
#define BIOS_ADDR0x8000// BIOS disk I/O buffer
#define BIOS_LEN0x8000// 32K - divisible by 512 and 2048
#define BOOT0_ADDR 0x7E00 // boot0 gets loaded here
#define BOOT0_ADDR0x7E00// boot0 gets loaded here
/* These are all "virtual" addresses...
branches/azimutz/trunkAutoResolution/i386/util/fdisk/cmd.c
6565
6666
6767
68
6869
6970
7071
#include "part.h"
#include "cmd.h"
#include "auto.h"
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
int

Archive Download the corresponding diff file

Revision: 1055