Changeset 7b7d7d1 in mainline


Ignore:
Timestamp:
2005-04-10T20:01:39Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
34b20f5d
Parents:
23c0c08
Message:

Cleanup floppy boot loader code and add missing stack initialization.

Location:
arch/ia32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/Makefile.inc

    r23c0c08 r7b7d7d1  
    1414
    1515CPPFLAGS=$(DEFS) -nostdinc -I../include
    16 CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Wmissing-prototypes -Werror -O1
     16CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Wmissing-prototypes -Werror -O3
    1717LFLAGS=-M -no-check-sections -T ../arch/ia32/_link.ld
    1818
  • arch/ia32/boot/boot.S

    r23c0c08 r7b7d7d1  
    3535
    3636
     37# KERNEL_SIZE is passed from the outside to the preprocessor
     38#if (KERNEL_SIZE%512>0)
     39#define TAIL            1
     40#else
     41#define TAIL            0
     42#endif
     43
     44#define SECTORS         (KERNEL_SIZE/512+TAIL)
     45
    3746.text
    3847.global _start_0x7c00
     
    4251        xorw %ax,%ax            # reset, %al will be used below
    4352        movw %ax,%dx            # fd0, %dh and %dl will be used below
    44         int $0x13
     53        movw %dx,%ds
     54
     55        movw %dx,%ss            # initialize stack
     56        movw $stack,%sp
     57
     58        int $0x13               # reset floppy
    4559        jc stop_trying
    4660
    47         movb $2,%ah             # read
    48         incb %al                # one sector
    49         movb %ah,%cl            # from disk sector 2
    50         movw %dx,%es
     61        movw %dx,%ds
     62        movw %dx,%ss
     63        movw $0x7c00,%sp
     64        movw $0xffe0,%si        # after next increment, %si will become 0x0000
     65        movw %si,%es
    5166        movw $0x8000,%bx        # at %es:%bx
    52         int $0x13
    53         jc stop_trying
    54 
    55         pushw $('.')
    56         call echo_mark
    57         add $2,%sp
    58    
    59         movw %dx,%ds
    6067       
    61         # KERNEL_SIZE is passed from the outside to the preprocessor
    62         movl $(KERNEL_SIZE),%edi
     68        movl $(SECTORS),%edi
    6369       
    64         shrl $9,%edi            # number of sectors that kernel occupies (%edi div 512)
    65    
    6670read_next:
    6771        test %edi,%edi
     
    7276        outb %al,%dx
    7377
    74         pushw $('$')
     78        movb $('$'),%al
    7579        call echo_mark
    76         add $2,%sp     
    7780       
    7881        jmpl $0,$0x8000
    7982
    8083read_sectors:
    81         pushw $('.')
     84        movb $('.'),%al
    8285        call echo_mark
    83         add $2,%sp
    8486
    8587        decl %edi
     
    105107        jnc read_next
    106108
    107         pushw $('R')
     109        movb $('R'),%al
    108110        call echo_mark
    109         add $2,%sp
    110111
    111112        xorw %ax,%ax                    # try to reset
     
    115116
    116117stop_trying:
    117         pushw $('F')
     118        movb $('F'),%al
    118119        call echo_mark
    119         add $2,%sp
    120120
    121121        cli
     
    128128        pusha
    129129   
    130         movw CH(%bp),%ax
    131130        movb $0xe,%ah
    132131        movb $7,%bl
     
    139138# current logical sector from the beginning of the disk
    140139logical_sector:
    141         .word 1
     140        .word 0
    142141
    143142# number of sectors per track on 1440 floppy
    144143sectors:
    145144        .byte 18
    146 
    147145
    148146# boot floppy signature
     
    151149        .byte 0x55
    152150        .byte 0xaa
     151stack:
Note: See TracChangeset for help on using the changeset viewer.