Changeset 339e053 in mainline for arch/ia32/src/boot/boot.S


Ignore:
Timestamp:
2005-09-04T09:59:13Z (20 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8ec9bae
Parents:
23f4b1fb
Message:

finish GRUB booting (including memory map and SMP)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/boot/boot.S

    r23f4b1fb r339e053  
    2828
    2929#include <arch/boot/boot.h>
     30#include <arch/boot/memmapasm.h>
    3031
    3132.section K_TEXT_START
     
    8182        movw %ax, %ss
    8283       
    83         call map_kernel                 # map kernel and turn paging on
    84        
    8584        movb $0xd1, %al                 # enable A20 using the keyboard controller
    8685        outb %al, $0x64
     
    9392        cld
    9493        rep movsb
     94       
     95        call map_kernel                 # map kernel and turn paging on
    9596       
    9697        call main_bsp                   # never returns
     
    114115        multiboot_meeting_point:
    115116       
    116         pushl %ebx
     117        pushl %ebx                                                                              # save parameters from GRUB
    117118        pushl %eax
     119       
     120        movl $BOOTSTRAP_OFFSET + BOOT_OFFSET, %esi
     121        movl $BOOTSTRAP_OFFSET, %edi
     122        movl $_hardcoded_unmapped_size, %ecx
     123        cld
     124        rep movsb
    118125       
    119126        call map_kernel                                                                 # map kernel and turn paging on
     
    121128        popl %eax
    122129        popl %ebx
    123         cmpl $MULTIBOOT_LOADER_MAGIC, %eax
     130        cmpl $MULTIBOOT_LOADER_MAGIC, %eax                      # compare GRUB signature
    124131        je valid_boot
    125        
    126                 # ...
     132               
     133                xorl %ecx, %ecx                                                 # no memory size or map available
     134                movl %ecx, e801memorysize
     135                movl %ecx, e820counter
    127136               
    128137                jmp invalid_boot
    129        
     138               
    130139        valid_boot:
    131140               
    132                 movl (%ebx), %eax
    133                
    134                 # ... check flags in eax
    135                
    136                 movl 4(%ebx), %ecx
    137                 addl 8(%ebx), %ecx
     141                movl (%ebx), %eax                                               # ebx = physical address of struct multiboot_info
     142               
     143                bt $0, %eax                                                             # mbi->flags[0] (mem_lower, mem_upper valid)
     144                jc mem_valid
     145                       
     146                        xorl %ecx, %ecx
     147                        jmp mem_invalid
     148                       
     149                mem_valid:
     150                movl 4(%ebx), %ecx                                              # mbi->mem_lower
     151                addl 8(%ebx), %ecx                                              # mbi->mem_upper
     152               
     153                mem_invalid:
    138154                movl %ecx, e801memorysize
    139155               
    140 #               movl 44(%ebx), %ecx
    141                 xorl %ecx, %ecx
    142                 movl %ecx, e820counter
    143 #               movl 48(%ebx), %esi
    144 #               movl $e820table, %edi
    145 #               cld
    146 #               rep movsb
     156                bt $6, %eax                                                             # mbi->flags[6] (mmap_length, mmap_addr valid) 
     157                jc mmap_valid
     158                       
     159                        xorl %edx, %edx
     160                        jmp mmap_invalid
     161                       
     162                mmap_valid:
     163                movl 44(%ebx), %ecx                                             # mbi->mmap_length
     164                movl 48(%ebx), %esi                                             # mbi->mmap_addr
     165                movl $e820table, %edi
     166                xorl %edx, %edx
     167               
     168                mmap_loop:
     169                        cmpl $0, %ecx
     170                        jle mmap_end
     171                       
     172                        movl 4(%esi), %eax                                      # mmap->base_addr_low
     173                        movl %eax, (%edi)
     174                       
     175                        movl 8(%esi), %eax                                      # mmap->base_addr_high
     176                        movl %eax, 4(%edi)
     177                       
     178                        movl 12(%esi), %eax                                     # mmap->length_low
     179                        movl %eax, 8(%edi)
     180                       
     181                        movl 16(%esi), %eax                                     # mmap->length_high
     182                        movl %eax, 12(%edi)
     183                       
     184                        movl 20(%esi), %eax                                     # mmap->type
     185                        movl %eax, 16(%edi)
     186                       
     187                        movl (%esi), %eax                                       # mmap->size
     188                        addl $0x4, %eax
     189                        addl %eax, %esi
     190                        subl %eax, %ecx
     191                        addl $MEMMAP_E820_RECORD_SIZE, %edi
     192                        incl %edx
     193                        jmp mmap_loop
     194               
     195                mmap_end:
     196               
     197                mmap_invalid:
     198                movl %edx, e820counter
    147199               
    148200        invalid_boot:
Note: See TracChangeset for help on using the changeset viewer.