📄 ldlinux.lst
字号:
568 ; 569 ; These are the fields we actually care about. We end up expanding them 570 ; all to dword size early in the code, so generate labels for both 571 ; the expanded and unexpanded versions. 572 ;; 573 %macro superb 1 574 bx %+ %1 equ SuperInfo+($-superblock)*8+4 575 bs %+ %1 equ $ 576 zb 1 577 %endmacro 578 %macro superw 1 579 bx %+ %1 equ SuperInfo+($-superblock)*8 580 bs %+ %1 equ $ 581 zw 1 582 %endmacro 583 %macro superd 1 584 bx %+ %1 equ $ ; no expansion for dwords 585 bs %+ %1 equ $ 586 zd 1 587 %endmacro 588 superblock equ $ 589 superw BytesPerSec 590 <1> bx %+ %1 equ SuperInfo+($-superblock)*8 591 <1> bs %+ %1 equ $ 592 0000000B 0000 <1> zw 1 593 superb SecPerClust 594 <1> bx %+ %1 equ SuperInfo+($-superblock)*8+4 595 <1> bs %+ %1 equ $ 596 0000000D 00 <1> zb 1 597 superw ResSectors 598 <1> bx %+ %1 equ SuperInfo+($-superblock)*8 599 <1> bs %+ %1 equ $ 600 0000000E 0000 <1> zw 1 601 superb FATs 602 <1> bx %+ %1 equ SuperInfo+($-superblock)*8+4 603 <1> bs %+ %1 equ $ 604 00000010 00 <1> zb 1 605 superw RootDirEnts 606 <1> bx %+ %1 equ SuperInfo+($-superblock)*8 607 <1> bs %+ %1 equ $ 608 00000011 0000 <1> zw 1 609 superw Sectors 610 <1> bx %+ %1 equ SuperInfo+($-superblock)*8 611 <1> bs %+ %1 equ $ 612 00000013 0000 <1> zw 1 613 superb Media 614 <1> bx %+ %1 equ SuperInfo+($-superblock)*8+4 615 <1> bs %+ %1 equ $ 616 00000015 00 <1> zb 1 617 superw FATsecs 618 <1> bx %+ %1 equ SuperInfo+($-superblock)*8 619 <1> bs %+ %1 equ $ 620 00000016 0000 <1> zw 1 621 superw SecPerTrack 622 <1> bx %+ %1 equ SuperInfo+($-superblock)*8 623 <1> bs %+ %1 equ $ 624 00000018 0000 <1> zw 1 625 superw Heads 626 <1> bx %+ %1 equ SuperInfo+($-superblock)*8 627 <1> bs %+ %1 equ $ 628 0000001A 0000 <1> zw 1 629 superinfo_size equ ($-superblock)-1 ; How much to expand 630 superd Hidden 631 <1> bx %+ %1 equ $ 632 <1> bs %+ %1 equ $ 633 0000001C 00000000 <1> zd 1 634 superd HugeSectors 635 <1> bx %+ %1 equ $ 636 <1> bs %+ %1 equ $ 637 00000020 00000000 <1> zd 1 638 superb DriveNumber 639 <1> bx %+ %1 equ SuperInfo+($-superblock)*8+4 640 <1> bs %+ %1 equ $ 641 00000024 00 <1> zb 1 642 superb Reserved1 643 <1> bx %+ %1 equ SuperInfo+($-superblock)*8+4 644 <1> bs %+ %1 equ $ 645 00000025 00 <1> zb 1 646 superb BootSignature ; 29h if the following fields exist 647 <1> bx %+ %1 equ SuperInfo+($-superblock)*8+4 648 <1> bs %+ %1 equ $ 649 00000026 00 <1> zb 1 650 superd VolumeID 651 <1> bx %+ %1 equ $ 652 <1> bs %+ %1 equ $ 653 00000027 00000000 <1> zd 1 654 0000002B 00<rept> bsVolumeLabel zb 11 655 00000036 00<rept> bsFileSysType zb 8 ; Must be FAT12 or FAT16 for this version 656 superblock_len equ $-superblock 657 658 SecPerClust equ bxSecPerClust 659 ; 660 ; Note we don't check the constraints above now; we did that at install 661 ; time (we hope!) 662 ; 663 664 ;floppy_table equ $ ; No sense in wasting memory, overwrite start 665 666 start: 667 0000003E FA cli ; No interrupts yet, please 668 0000003F FC cld ; Copy upwards 669 ; 670 ; Set up the stack 671 ; 672 00000040 31C0 xor ax,ax 673 00000042 8ED0 mov ss,ax 674 00000044 BC[B4FF] mov sp,StackBuf ; Just below BSS 675 00000047 8EC0 mov es,ax 676 ; 677 ; DS:SI may contain a partition table entry. Preserve it for us. 678 ; 679 00000049 B90800 mov cx,8 ; Save partition info 680 0000004C 89E7 mov di,sp 681 0000004E F3A5 rep movsw 682 683 00000050 8ED8 mov ds,ax ; Now we can initialize DS... 684 685 00000052 885560 mov [di+bsDriveNumber-FloppyTable],dl 686 ; 687 ; Now sautee the BIOS floppy info block to that it will support decent- 688 ; size transfers; the floppy block is 11 bytes and is stored in the 689 ; INT 1Eh vector (brilliant waste of resources, eh?) 690 ; 691 ; Of course, if BIOSes had been properly programmed, we wouldn't have 692 ; had to waste precious space with this code. 693 ; 694 00000055 BB7800 mov bx,fdctab 695 00000058 0FB437 lfs si,[bx] ; FS:SI -> original fdctab 696 0000005B 0FA0 push fs ; Save on stack in case we need to bail 697 0000005D 56 push si 698 699 ; Save the old fdctab even if hard disk so the stack layout 700 ; is the same. The instructions above do not change the flags 701 0000005E 20D2 and dl,dl ; If floppy disk (00-7F), assume no 702 ; partition table 703 00000060 7815 js harddisk 704 705 floppy: 706 00000062 B106 mov cl,6 ; 12 bytes (CX == 0) 707 ; es:di -> FloppyTable already 708 ; This should be safe to do now, interrupts are off... 709 00000064 893F mov [bx],di ; FloppyTable 710 00000066 894702 mov [bx+2],ax ; Segment 0 711 00000069 64F3A5 fs rep movsw ; Faster to move words 712 0000006C 8A0E[1800] mov cl,[bsSecPerTrack] ; Patch the sector count 713 00000070 884DF8 mov [di-8],cl 714 ; AX == 0 here 715 00000073 CD13 int 13h ; Some BIOSes need this 716 717 00000075 EB27 jmp short not_harddisk 718 ; 719 ; The drive number and possibly partition information was passed to us 720 ; by the BIOS or previous boot loader (MBR). Current "best practice" is to 721 ; trust that rather than what the superblock contains. 722 ; 723 ; Would it be better to zero out bsHidden if we don't have a partition table? 724 ; 725 ; Note: di points to beyond the end of PartInfo 726 ; 727 harddisk: 728 00000077 F645F07F test byte [di-16],7Fh ; Sanity check: "active flag" should 729 0000007B 7508 jnz no_partition ; be 00 or 80 730 0000007D 668B45F8 mov eax,[di-8] ; Partition offset (dword) 731 00000081 66A3[1C00] mov [bsHidden],eax 732 no_partition: 733 ; 734 ; Get disk drive parameters (don't trust the superblock.) Don't do this for 735 ; floppy drives -- INT 13:08 on floppy drives will (may?) return info about 736 ; what the *drive* supports, not about the *media*. Fortunately floppy disks 737 ; tend to have a fixed, well-defined geometry which is stored in the superblock. 738 ; 739 ; DL == drive # still 740 00000085 B408 mov ah,08h 741 00000087 CD13 int 13h 742 00000089 7213 jc no_driveparm 743 0000008B 20E4 and ah,ah 744 0000008D 750F jnz no_driveparm 745 0000008F C1EA08 shr dx,8 746 00000092 42 inc dx ; Contains # of heads - 1 747 00000093 8916[1A00] mov [bsHeads],dx 748 00000097 83E13F and cx,3fh 749 0000009A 890E[1800] mov [bsSecPerTrack],cx 750 no_driveparm: 751 not_harddisk: 752 ; 753 ; Ready to enable interrupts, captain 754 ; 755 0000009E FB sti 756 ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -