Changeset 4b241f3 in mainline


Ignore:
Timestamp:
2009-03-01T19:27:33Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bf25efb
Parents:
bc18d63
Message:

The ia32-specific boot code is written completely in assembly for no reason. Start fixing this. For now rewrite the copying of multiboot info to C.

Location:
kernel
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/Makefile.inc

    rbc18d63 r4b241f3  
    100100        arch/$(KARCH)/src/drivers/vesa.c \
    101101        arch/$(KARCH)/src/boot/boot.S \
     102        arch/$(KARCH)/src/boot/cboot.c \
    102103        arch/$(KARCH)/src/boot/memmap.c \
    103104        arch/$(KARCH)/src/fpu_context.c \
  • kernel/arch/ia32/src/boot/boot.S

    rbc18d63 r4b241f3  
    102102        mov %bx, KA2PA(vesa_bpp)
    103103#endif 
    104        
     104
    105105        call map_kernel                                                 # map kernel and turn paging on
    106        
     106
    107107        movl grub_eax, %eax
    108108        movl grub_ebx, %ebx
    109109        cmpl $MULTIBOOT_LOADER_MAGIC, %eax                              # compare GRUB signature
    110110        je valid_boot
    111                
     111
    112112                xorl %ecx, %ecx                                                 # no memory map available
    113113                movl %ecx, e820counter
    114                
     114
    115115                jmp invalid_boot
    116                
     116
    117117        valid_boot:
    118                
    119                 movl (%ebx), %eax                                               # ebx = physical address of struct multiboot_info
    120                
    121                 bt $3, %eax                                                             # mbi->flags[3] (mods_count, mods_addr valid)
    122                 jc mods_valid
    123                        
    124                         xorl %ecx, %ecx
    125                         movl %ecx, init
    126                         jmp mods_end
    127                
    128                 mods_valid:
    129                
    130                 movl 20(%ebx), %ecx                                             # mbi->mods_count
    131                 movl %ecx, init
    132                
    133                 cmpl $0, %ecx
    134                 je mods_end
    135                
    136                 movl 24(%ebx), %esi                                             # mbi->mods_addr
    137                 movl $init, %edi
    138                
    139                 mods_loop:
    140                
    141                         movl 0(%esi), %edx                                      # mods->mod_start
    142                         addl $0x80000000, %edx
    143                         movl %edx, 4(%edi)
    144                        
    145                         movl 4(%esi), %edx
    146                         subl 0(%esi), %edx                                      # mods->mod_end - mods->mod_start
    147                         movl %edx, 8(%edi)
    148                        
    149                         addl $16, %esi
    150                         addl $8 , %edi
    151                        
    152                         loop mods_loop
    153                        
    154                 mods_end:
    155                
    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
    199                
     118
     119        movl grub_eax, %eax
     120        movl grub_ebx, %ebx
     121
     122        # ia32_boot(grub_eax, grub_ebx)
     123        pushl %ebx
     124        pushl %eax
     125        call ia32_cboot         # Does not return.
     126
     127        # Not reached.
     128
    200129        invalid_boot:
    201        
    202 #ifdef CONFIG_SMP
    203        
    204         # copy AP bootstrap routines below 1 MB
    205        
    206         movl $BOOT_OFFSET, %esi
    207         movl $AP_BOOT_OFFSET, %edi
    208         movl $_hardcoded_unmapped_size, %ecx
    209         rep movsb
    210        
    211 #endif
    212 
    213         call main_bsp                                                           # never returns
    214130
    215131        cli
  • kernel/generic/include/main/main.h

    rbc18d63 r4b241f3  
    3636#define KERN_MAIN_H_
    3737
     38#include <arch/types.h>
     39
    3840extern uintptr_t stack_safe;
     41
     42extern void main_bsp(void);
     43extern void main_ap(void);
    3944
    4045#endif
  • kernel/generic/src/main/main.c

    rbc18d63 r4b241f3  
    8282#include <smp/smp.h>
    8383#include <ddi/ddi.h>
    84 
     84#include <main/main.h>
    8585
    8686/** Global configuration structure. */
     
    114114/** Lowest safe stack virtual address. */
    115115uintptr_t stack_safe = 0;               
    116 
    117 void main_bsp(void);
    118 void main_ap(void);
    119116
    120117/*
Note: See TracChangeset for help on using the changeset viewer.