Changeset 516 for Whitix/branches/hybrid
- Timestamp:
- 05/24/08 09:45:02 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/hybrid/arch/i386/boot/iso/isoboot.asm
r462 r516 138 138 mov si,dapa 139 139 mov [si+4],bx 140 mov bx, es140 mov bx, es 141 141 mov [si+6],bx 142 142 mov [si+8],eax … … 151 151 push si 152 152 mov dl,[drive] 153 mov ah, 42h153 mov ah, 0x42 154 154 call Int13WithRetry 155 155 pop si 156 156 pop bp 157 movzx eax, word[si+2]158 add [si+8], eax159 sub bp, ax160 shl ax, 7161 add [si+6], ax162 and bp, bp157 movzx eax, word[si+2] 158 add [si+8], eax 159 sub bp, ax 160 shl ax, 7 161 add [si+6], ax 162 and bp, bp 163 163 jnz .loop 164 164 mov eax,[si+8] … … 166 166 167 167 Int13WithRetry: 168 mov byte [retryCount],6168 mov byte [retryCount],6 169 169 .try: 170 170 pushad … … 203 203 204 204 .realError: 205 mov si,ErrorStr206 jmp fail205 mov si,ErrorStr 206 jmp fail 207 207 208 208 ;Include library routines such as PrintStr … … 220 220 ImageDwords dd 0 221 221 ImageSectors dw 0 222 maxTransfer d b 0222 maxTransfer dw 32 223 223 224 224 section .bss … … 308 308 section .text 309 309 AllRead: 310 ;Read the primary volume descriptor into memory. 311 mov eax,[iso_pvd] 312 mov bx,trackBuf 313 call GetOneSec 314 315 ;Get the start sector of the root directory 316 mov eax,[trackBuf+156+2] 317 mov [dirStart],eax 318 319 ;Get the length (converted to sectors) of the root directory 320 mov eax, [trackBuf+156+10] 321 add eax, 2047 322 shr eax, 11 ;Round up to the nearest sector 323 mov [dirLength], eax 310 call DirGetRoot 324 311 325 312 ;Find /Boot. … … 343 330 mov di, kernName 344 331 call ReadInFile 332 333 ;Read in Boot.modules 334 mov ax, 0x3000 335 mov es, ax 336 xor bx, bx 337 mov di, bootModsName 338 call ReadInFile 339 340 push dword [fileLength] 341 pop dword [modulesLength] 342 343 ;Change to /System/Modules/Core to load in the boot modules. 344 call DirGetRoot 345 346 mov di, systemName 347 call FindDir 348 349 mov di, modulesName 350 call FindDir 351 352 mov di, coreName 353 call FindDir 354 355 ;Now load the modules into memory and construct an information table. 356 mov ax, 0x3000 357 mov es, ax 358 xor bx, bx 359 call ModulesLoad 360 361 mov ax, 0x2000 362 mov es, ax 363 mov bx, 0xFFFF 364 mov cl, [numModules] 365 mov [es:bx], cl 345 366 346 367 ;setup.asm puts in the kernel data area … … 456 477 mov [fileStartSector],eax 457 478 push eax 458 mov eax,[si+10] 479 mov eax, [si+10] 480 mov [fileLength], eax 459 481 add eax,2047 460 482 shr eax,11 … … 509 531 ret 510 532 533 DirGetRoot: 534 ;Read the primary volume descriptor into memory. 535 xor ax, ax 536 mov es, ax 537 mov eax, [iso_pvd] 538 mov bx, trackBuf 539 call GetOneSec 540 541 ;Get the start sector of the root directory 542 mov eax, [trackBuf+156+2] 543 mov [dirStart],eax 544 545 ;Get the length (converted to sectors) of the root directory 546 mov eax, [trackBuf+156+10] 547 add eax, 2047 548 shr eax, 11 ;Round up to the nearest sector 549 mov [dirLength], eax 550 551 ret 552 553 ; TODO: Use ds instead of es. Makes for simpler code. 554 555 ModulesLoad: 556 startAgain: 557 mov ax, bx 558 ;Parse the file 559 parseLoop: 560 mov cl, [es:bx] 561 cmp cl, byte 10 562 jz newName 563 cmp bx, [modulesLength] 564 jge newName 565 inc bx 566 jmp parseLoop 567 568 newName: 569 push bx 570 mov cx, ax 571 sub bx, ax 572 573 call ModuleDoLoad 574 575 pop bx 576 inc bx 577 cmp bx, [modulesLength] 578 jl startAgain 579 ret 580 581 ;TODO: Optimize this function. 582 ModuleDoLoad: 583 push es 584 mov ax, es 585 mov ds, ax 586 587 xor ax, ax 588 mov es, ax 589 590 ;cx contains start of string, bx contains length. Copy over to a buffer and load the file into memory. 591 mov di, moduleName 592 mov si, cx 593 mov cx, bx 594 rep movsb 595 596 ;Add .sys to the end of the filename 597 xor ax, ax 598 mov ds, ax 599 600 mov si, modSuffix 601 mov cx, 5 602 rep movsb 603 604 ;Read in the file. 605 mov ax, [modSegment] 606 mov es, ax 607 mov bx, [modOffset] 608 add bx, 4 609 mov di, moduleName 610 611 call ReadInFile 612 613 mov ax, [fileLength] 614 mov bx, [modOffset] 615 add ax, 3 ;Length + 3 to round up 616 and ax, ~3 617 mov [es:bx], eax 618 619 add ax, 4 620 add [modOffset], ax 621 mov ax, [modOffset] 622 xor dx ,dx 623 mov cx, 16 624 div cx ;Get quotient and remainder. Use shift and and soon. 625 626 add [modSegment], ax 627 mov [modOffset], dx 628 629 inc byte [numModules] 630 631 pop es 632 ret 633 511 634 notFound db "Could not find ", 0 512 635 loaderName db "KeLoader", 0 513 636 kernName db "Kernel", 0 514 637 bootName db "Boot", 0 638 bootModsName db "Boot.modules", 0 639 systemName db "System", 0 640 modulesName db "Modules", 0 641 coreName db "Core", 0 642 modSuffix db ".sys", 0 515 643 516 644 dirStart dd 0 … … 518 646 fileStartSector dd 0 519 647 fileSectorLength dd 0 648 fileLength dd 0 649 modulesLength dd 0 650 numModules db 0 651 modSegment dw 0x4000 652 modOffset dw 0 520 653 521 654 section .bss … … 524 657 IsoFileName resb 64 525 658 IsoFileNameEnd equ $ 659 moduleName resb 16 526 660 527 661 ;Track buffer at the end of the bootloader
