Chameleon

Chameleon Commit Details

Date:2013-12-02 14:27:03 (10 years 4 months ago)
Author:Jief Luce
Commit:2275
Parents: 2274
Message:new signature + passing part number to boot2
Changes:
M/branches/Jief/i386/boot1/boot1h.s

File differences

branches/Jief/i386/boot1/boot1h.s
4242
4343
4444
45
45
46
4647
4748
4849
......
5253
5354
5455
55
56
5657
5758
5859
......
6667
6768
6869
70
6971
7072
7173
......
8587
8688
8789
88
89
90
91
92
93
94
95
96
97
98
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
99109
100110
101111
......
308318
309319
310320
311
312
313
314
315
316
317
318
319321
320
321322
322323
323
324324
325325
326
327
326
327
328328
329329
330330
331
331332
332333
333334
......
336337
337338
338339
339
340
340341
341342
342343
343344
345
346
347
348
349
350
344351
345
346
347
348352
353
349354
350
351
352
353355
356
354357
358
359
360
361
362
363
355364
356365
357366
......
368377
369378
370379
380
371381
372382
373383
......
377387
378388
379389
390
391
380392
381393
382394
......
387399
388400
389401
390
391402
392403
393404
......
400411
401412
402413
414
403415
404416
405417
406418
407
408
419
420
421
409422
423
410424
411425
426
427
428
429
430
431
432
433
412434
413435
414436
......
417439
418440
419441
442
420443
421444
422445
......
426449
427450
428451
452
453
429454
430455
431456
......
439464
440465
441466
467
468
442469
443470
444471
......
472499
473500
474501
475
476502
477
478503
479504
505
480506
481
482
483
484
485
486
487
488
489
490
491
492
493
494507
508
495509
510
496511
497512
513
514
498515
499
500
501
502
503516
504
517
505518
506519
507520
......
684697
685698
686699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
687719
688720
721
722
689723
690724
691725
......
705739
706740
707741
708
742
709743
710744
711745
712746
713
747
714748
715749
716750
......
725759
726760
727761
762
763
728764
729765
730766
......
9911027
9921028
9931029
994
995
1030
1031
1032
9961033
9971034
9981035
......
11901227
11911228
11921229
1193
1230
11941231
11951232
11961233
......
12151252
12161253
12171254
1218
1255
12191256
1220
1257
12211258
1222
1259
12231260
12241261
12251262
......
14781515
14791516
14801517
1481
1518
14821519
1520
14831521
14841522
14851523
;
; Set to 1 to enable obscure debug messages.
;
DEBUGEQUCONFIG_BOOT1_HFS_DEBUG
SIMPLEDEBUGEQU1 ; only print_char for space reason
DEBUGEQU0
;
; Set to 1 to enable unused code.
;
; Set to 1 to enable verbose mode.
;
VERBOSEEQUCONFIG_BOOT1_HFS_VERBOSE
VERBOSEEQU0
;
; Various constants.
maxNodeSizeEQU16384
kSectorBytesEQU512; sector size in bytes
kChameleonBoot1hSignatureEQU0xBB99; boot sector signature
kBootSignatureEQU0xAA55; boot sector signature
kBoot1StackAddressEQU0xFFF0; boot1 stack pointer
; giving the size of the structure.
;
struc part
.bootidresb 1; bootable or not
.headresb 1; starting head, sector, cylinder
.sectresb 1;
.cylresb 1;
.typeresb 1; partition type
.endheadresb 1; ending head, sector, cylinder
.endsectresb 1;
.endcylresb 1;
.lbaresd 1; starting lba
.sectorsresd 1; size in sectors
endstruc
;.bootidresb 1; bootable or not
;.headresb 1; starting head, sector, cylinder
;.sectresb 1;
;.cylresb 1;
;.typeresb 1; partition type
;.endheadresb 1; ending head, sector, cylinder
;.endsectresb 1;
;.endcylresb 1;
;.lbaresd 1; starting lba
;.sectorsresd 1; size in sectors
;endstruc
strucgpta
.PartitionTypeGUIDresb16
.UniquePartitionGUIDresb16
.StartingLBAresb8
.EndingLBAresb8
;.Attributesresb8
;.PartitionNameresb72
endstruc
;-------------------------------------------------------------------------
; HFS+ related structures and constants
ret
%endmacro
%macro DebugCharMacro 1
pushad
moval, %1
callprint_char
callgetc
popad
%endmacro
%macro PrintCharMacro 1
pushad
moval, %1
callprint_char
popad
%endmacro
%macro PutCharMacro 1
callprint_char
%macro PrintHexEaxMacro 0
callprint_hex
%endmacro
%macro PrintHexMacro 1
mov eax, %1
callprint_hex
%endmacro
callprint_string
%endmacro
%macro LogString 1
%macro LogStringMacro 1
movdi, %1
calllog_string
%endmacro
%if SIMPLEDEBUG
%define PrintChar(x) PrintCharMacro x
%else
%define PrintChar(x)
%endif
%if DEBUG
%define DebugChar(x) DebugCharMacro x
%define PrintChar(x) PrintCharMacro x
%define PutChar(x) PutCharMacro
%define PrintHex(x) PrintHexMacro x
%define PrintHexEax PrintHexEaxMacro
%else
%define DebugChar(x)
%define PrintChar(x)
%define PutChar(x)
%define PrintHex(x)
%define PrintHexEax
%endif
%if VERBOSE
%define LogString(x) LogStringMacro x
%else
%define LogString(x)
%endif
;--------------------------------------------------------------------------
; Start of text segment.
; Set up the stack to grow down from kBoot1StackSegment:kBoot1StackAddress.
; Interrupts should be off while the stack is being manipulated.
;
cli ; interrupts off
xorax, ax ; zero ax
movss, ax ; ss <- 0
mov ds, ax ; ds <- 0
mov es, ax ; es <- 0
push ecx ; save the current partition LBA offset. will be poped after reloc
;
; Relocate boot1 code.
;
movcx, kSectorBytes; copy 256 words
repmovsb; repeat string move (word) operation
popsi
;
; Code relocated, jump to startReloc in relocated location.
;
; Start execution from the relocated location.
;
startReloc:
PrintChar ('>')
;
; Initializing global variables.
;
mov eax, [si + part.lba]
mov [gPartLBA], eax; save the current partition LBA offset
pop ecx
;PrintHex(ecx)
mov DWORD [gPartLBA], ecx; save the current partition LBA offset
mov [gBIOSDriveNumber], dl; save BIOS drive number
mov [gBIOSDrivePartNumber], dh; save BIOS drive number
movWORD [gMallocPtr], mallocStart; set free space pointer
PrintHex([gPartLBA])
xor eax,eax
mov al,[gBIOSDriveNumber]
PrintHexEax
xor eax,eax
mov al,[gBIOSDrivePartNumber]
PrintHexEax
;
; Loading upper 512 bytes of boot1h and HFS+ Volume Header.
;
mov al, 2; read 2 sectors: sector 1 of boot1h + HFS+ Volume Header
mov edx, kBoot1Sector1Addr
call readLBA
;PrintChar ('2')
;
; Initializing more global variables.
shreax, 9; convert to sector unit
mov[gBlockSize], eax; save blockSize as little-endian sector unit!
;PrintChar ('3')
;
; Looking for HFSPlus ('H+') or HFSPlus case-sensitive ('HX') signature.
;
; Find stage2 boot file in a HFS+ Volume's root folder.
;
findRootBoot:
PrintChar ('!')
;%if 0
moval, kHFSCatalogFileID
leasi, [searchCatalogKey]
leadi, [kHFSPlusBuffer + HFSPlusVolumeHeader.catalogFile + HFSPlusForkData.extents]
leadi, [si + HFSPlusCatalogFile.dataFork + HFSPlusForkData.extents]
callreadExtent
%if VERBOSE
LogString(root_str)
%endif
boot2:
PrintChar ('J')
%if DEBUG
DebugChar ('!')
%endif
%if UNUSED
;
; Waiting for a key press.
;
mov ah, 0
int0x16
%endif
mov dl, [gBIOSDriveNumber]; load BIOS drive number
mov dh, [gBIOSDrivePartNumber]; load part number
jmp kBoot2Segment:kBoot2Address
;%endif
error:
PrintChar ('E')
LogString(error_str)
%if VERBOSE
LogString(error_str)
%endif
hang:
hlt
call getc
jmp hang
;--------------------------------------------------------------------------
%endif ; VERBOSE
%if SIMPLEDEBUG
;--------------------------------------------------------------------------
; Write a ASCII character to the console.
;
; Arguments:
; AL = ASCII character.
;
print_char:
pushad
mov bx, 1 ; BH=0, BL=1 (blue)
mov ah, 0x0e ; bios INT 10, Function 0xE
int 0x10 ; display byte in tty mode
popad
ret
%endif
%if DEBUG
%if UNUSED
;--------------------------------------------------------------------------
; Write the 4-byte value to the console in hex.
;
ror eax, 8
loop .loop
%if UNUSED
;%if UNUSED
mov al, 10; carriage return
call print_char
mov al, 13
call print_char
%endif ; UNUSED
;%endif ; UNUSED
popad
ret
call print_char
ret
%endif ; UNUSED
;--------------------------------------------------------------------------
; getc - wait for a key press
;
; Azi: boot1h.s:994: error: TIMES value -67 is negative
;
pad_table_and_sig:
times510-($-$$) db 0
dwkBootSignature
times508-($-$$) db 0
dw kChameleonBoot1hSignature
dwkBootSignature // remove this ! Don't forgot boot0.s, line 419 : -4 become -2
;
; Sector 1 code area
movsi, di
lodsd
PrintChar('k')
PrintHex()
PrintHexEax()
lodsw
cmpax, 0
je.printExit
movsi, di
xoreax, eax
lodsw
PrintHex()
PrintHexEax()
lodsd
PrintHex()
PrintHexEax()
lodsd
PrintHex()
PrintHexEax()
popad
;
;
ABSOLUTEkHFSPlusBuffer + HFSPlusVolumeHeader_size
gPartLBAresd1
gPartLBAresd4
gBIOSDriveNumberresw1
gBIOSDrivePartNumberresw1
gBlockSizeresd1
gMallocPtrresw1

Archive Download the corresponding diff file

Revision: 2275