Changeset deca67b in mainline


Ignore:
Timestamp:
2009-03-03T12:56:20Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
add04f7
Parents:
2f57690
Message:

rename ia32_cboot() to arch_pre_main() and move it to ia32.c (to be in line with other platforms)

Location:
kernel/arch/ia32
Files:
1 deleted
5 edited
1 moved

Legend:

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

    r2f57690 rdeca67b  
    100100        arch/$(KARCH)/src/drivers/vesa.c \
    101101        arch/$(KARCH)/src/boot/boot.S \
    102         arch/$(KARCH)/src/boot/cboot.c \
    103102        arch/$(KARCH)/src/boot/memmap.c \
    104103        arch/$(KARCH)/src/fpu_context.c \
  • kernel/arch/ia32/include/arch.h

    r2f57690 rdeca67b  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    3636#define KERN_ia32_ARCH_H_
    3737
     38#include <arch/boot/multiboot.h>
     39
     40extern void arch_pre_main(uint32_t signature, const mb_info_t *mi);
     41
    3842#endif
    3943
  • kernel/arch/ia32/include/boot/boot.h

    r2f57690 rdeca67b  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    3636#define KERN_ia32_BOOT_H_
    3737
    38 #define BOOT_OFFSET             0x108000
    39 #define AP_BOOT_OFFSET          0x8000
    40 #define BOOT_STACK_SIZE 0x400
     38#define BOOT_OFFSET      0x108000
     39#define AP_BOOT_OFFSET   0x8000
     40#define BOOT_STACK_SIZE  0x400
    4141
    42 #define MULTIBOOT_HEADER_MAGIC  0x1BADB002
    43 #define MULTIBOOT_HEADER_FLAGS  0x00010003
     42#define MULTIBOOT_HEADER_MAGIC  0x1BADB002
     43#define MULTIBOOT_HEADER_FLAGS  0x00010003
    4444
    45 #define MULTIBOOT_LOADER_MAGIC  0x2BADB002
     45#define MULTIBOOT_LOADER_MAGIC  0x2BADB002
     46
     47#ifndef __ASM__
     48
     49#ifdef CONFIG_SMP
     50
     51extern int _hardcoded_unmapped_size;
     52
     53#endif /* CONFIG_SMP */
     54
     55#endif /* __ASM__ */
    4656
    4757#endif
  • kernel/arch/ia32/include/boot/multiboot.h

    r2f57690 rdeca67b  
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup ia32
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_ia32_CBOOT_H__
    36 #define KERN_ia32_CBOOT_H_
     35#ifndef KERN_ia32_MULTIBOOT_H__
     36#define KERN_ia32_MULTIBOOT_H_
    3737
    3838#include <arch/types.h>
     
    5858        uintptr_t mem_lower;
    5959        uintptr_t mem_upper;
    60 
     60       
    6161        uint32_t boot_device;
    6262        char *cmdline;
    63 
     63       
    6464        uint32_t mods_count;
    6565        mb_mod_t *mods_addr;
    66 
     66       
    6767        uint32_t syms[4];
    68 
     68       
    6969        uint32_t mmap_length;
    7070        mb_mmap_t *mmap_addr;
    71 
     71       
    7272        /* ... */
    7373} __attribute__ ((packed)) mb_info_t;
    7474
    7575enum mb_info_flags {
    76         MBINFO_FLAGS_MEM        = 0x01,
    77         MBINFO_FLAGS_BOOT       = 0x02,
    78         MBINFO_FLAGS_CMDLINE    = 0x04,
    79         MBINFO_FLAGS_MODS       = 0x08,
    80         MBINFO_FLAGS_SYMS1      = 0x10,
    81         MBINFO_FLAGS_SYMS2      = 0x20,
    82         MBINFO_FLAGS_MMAP       = 0x40
     76        MBINFO_FLAGS_MEM     = 0x01,
     77        MBINFO_FLAGS_BOOT    = 0x02,
     78        MBINFO_FLAGS_CMDLINE = 0x04,
     79        MBINFO_FLAGS_MODS    = 0x08,
     80        MBINFO_FLAGS_SYMS1   = 0x10,
     81        MBINFO_FLAGS_SYMS2   = 0x20,
     82        MBINFO_FLAGS_MMAP    = 0x40
     83       
    8384        /* ... */
    8485};
    85 
    86 extern void ia32_cboot(uint32_t signature, const mb_info_t *mi);
    8786
    8887#endif
  • kernel/arch/ia32/src/boot/boot.S

    r2f57690 rdeca67b  
    105105        call map_kernel                                                 # map kernel and turn paging on
    106106
    107         # ia32_cboot(grub_eax, grub_ebx)
     107        # arch_pre_main(grub_eax, grub_ebx)
    108108        pushl grub_ebx
    109109        pushl grub_eax
    110         call ia32_cboot         # Does not return.
    111 
     110        call arch_pre_main
     111       
     112        call main_bsp
     113       
    112114        # Not reached.
    113 
     115       
    114116        cli
    115117        hlt
  • kernel/arch/ia32/src/ia32.c

    r2f57690 rdeca67b  
    11/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
     3 * Copyright (c) 2009 Jiri Svoboda
     4 * Copyright (c) 2009 Martin Decky
    35 * All rights reserved.
    46 *
     
    6466#include <ddi/device.h>
    6567#include <sysinfo/sysinfo.h>
     68#include <arch/boot/boot.h>
     69#include <string.h>
     70#include <macros.h>
    6671
    6772#ifdef CONFIG_SMP
    6873#include <arch/smp/apic.h>
    6974#endif
     75
     76/** Extract command name from the multiboot module command line.
     77 *
     78 * @param buf      Destination buffer (will always null-terminate).
     79 * @param n        Size of destination buffer.
     80 * @param cmd_line Input string (the command line).
     81 *
     82 */
     83static void extract_command(char *buf, size_t n, const char *cmd_line)
     84{
     85        const char *start, *end, *cp;
     86        size_t max_len;
     87       
     88        /* Find the first space. */
     89        end = strchr(cmd_line, ' ');
     90        if (end == NULL)
     91                end = cmd_line + strlen(cmd_line);
     92       
     93        /*
     94         * Find last occurence of '/' before 'end'. If found, place start at
     95         * next character. Otherwise, place start at beginning of buffer.
     96         */
     97        cp = end;
     98        start = buf;
     99        while (cp != start) {
     100                if (*cp == '/') {
     101                        start = cp + 1;
     102                        break;
     103                }
     104                --cp;
     105        }
     106       
     107        /* Copy the command and null-terminate the string. */
     108        max_len = min(n - 1, (size_t) (end - start));
     109        strncpy(buf, start, max_len + 1);
     110        buf[max_len] = '\0';
     111}
     112
     113/** C part of ia32 boot sequence.
     114 *
     115 * @param signature Should contain the multiboot signature.
     116 * @param mi        Pointer to the multiboot information structure.
     117 */
     118void arch_pre_main(uint32_t signature, const mb_info_t *mi)
     119{
     120        uint32_t flags;
     121        mb_mod_t *mods;
     122        uint32_t i;
     123       
     124        if (signature == MULTIBOOT_LOADER_MAGIC)
     125                flags = mi->flags;
     126        else {
     127                /* No multiboot info available. */
     128                flags = 0;
     129        }
     130       
     131        /* Copy module information. */
     132       
     133        if ((flags & MBINFO_FLAGS_MODS) != 0) {
     134                init.cnt = mi->mods_count;
     135                mods = mi->mods_addr;
     136               
     137                for (i = 0; i < init.cnt; i++) {
     138                        init.tasks[i].addr = mods[i].start + 0x80000000;
     139                        init.tasks[i].size = mods[i].end - mods[i].start;
     140                       
     141                        /* Copy command line, if available. */
     142                        if (mods[i].string) {
     143                                extract_command(init.tasks[i].name,
     144                                    CONFIG_TASK_NAME_BUFLEN,
     145                                    mods[i].string);
     146                        } else
     147                                init.tasks[i].name[0] = '\0';
     148                }
     149        } else
     150                init.cnt = 0;
     151       
     152        /* Copy memory map. */
     153       
     154        int32_t mmap_length;
     155        mb_mmap_t *mme;
     156        uint32_t size;
     157       
     158        if ((flags & MBINFO_FLAGS_MMAP) != 0) {
     159                mmap_length = mi->mmap_length;
     160                mme = mi->mmap_addr;
     161                e820counter = 0;
     162               
     163                i = 0;
     164                while (mmap_length > 0) {
     165                        e820table[i++] = mme->mm_info;
     166                       
     167                        /* Compute address of next structure. */
     168                        size = sizeof(mme->size) + mme->size;
     169                        mme = ((void *) mme) + size;
     170                        mmap_length -= size;
     171                }
     172               
     173                e820counter = i;
     174        } else
     175                e820counter = 0;
     176       
     177#ifdef CONFIG_SMP
     178        /* Copy AP bootstrap routines below 1 MB. */
     179        memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET,
     180            (size_t) &_hardcoded_unmapped_size);
     181#endif
     182}
    70183
    71184void arch_pre_mm_init(void)
Note: See TracChangeset for help on using the changeset viewer.