Changeset 1f5c9c96 in mainline


Ignore:
Timestamp:
2011-12-02T17:29:43Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b8b1e631, c3887ad
Parents:
c48f6ab
Message:

implement multiboot v2 specification and use it in GRUB for UEFI

  • improve multiboot v1 code, move defines to a common location
  • rename VESA framebuffer stuff to generic "boot framebuffer"
  • small collateral changes
Files:
4 added
20 edited
4 moved

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    rc48f6ab r1f5c9c96  
    520520@ "1920x1080"
    521521@ "1920x1200"
    522 ! [(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_VESA_MODE (choice)
     522! [(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_BFB_MODE (choice)
    523523
    524524% Default framebuffer depth
     
    526526@ "16"
    527527@ "24"
    528 ! [(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_VESA_BPP (choice)
     528! [(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_BFB_BPP (choice)
    529529
    530530% Start AP processors by the loader
  • boot/Makefile.grub

    rc48f6ab r1f5c9c96  
    3939ifeq ($(GRUB_ARCH),pc)
    4040        BOOT_CONFIG = $(BOOT)/grub/i386-pc/grub.cfg
     41        MULTIBOOT_CMD = multiboot
     42        MODULE_CMD = module
    4143endif
    4244ifeq ($(GRUB_ARCH),efi)
    4345        BOOT_CONFIG = $(BOOT)/grub/grub.cfg
     46        MULTIBOOT_CMD = multiboot2
     47        MODULE_CMD = module2
    4448endif
    4549
     
    6973        echo "" >> $(BOOT_CONFIG)
    7074       
     75ifeq ($(GRUB_ARCH),pc)
     76        echo "insmod vbe" >> $(BOOT_CONFIG)
     77        echo "insmod vga" >> $(BOOT_CONFIG)
     78endif
     79ifeq ($(GRUB_ARCH),efi)
     80        echo "insmod efi_gop" >> $(BOOT_CONFIG)
     81        echo "insmod efi_uga" >> $(BOOT_CONFIG)
     82endif
     83        echo "" >> $(BOOT_CONFIG)
     84       
    7185        echo "menuentry 'HelenOS $(RELEASE)' --class helenos --class os {" >> $(BOOT_CONFIG)
    7286        for module in $(MODULES) ; do \
    7387                echo "  echo 'Loading $$module'" >> $(BOOT_CONFIG) ; \
    7488                if [ "$$module" = "kernel.bin" ] ; then \
    75                         echo "  multiboot /boot/$$module" >> $(BOOT_CONFIG) ; \
     89                        echo "  $(MULTIBOOT_CMD) /boot/$$module" >> $(BOOT_CONFIG) ; \
    7690                else \
    77                         echo "  module /boot/$$module" >> $(BOOT_CONFIG) ; \
     91                        echo "  $(MODULE_CMD) /boot/$$module" >> $(BOOT_CONFIG) ; \
    7892                fi \
    7993        done
  • defaults/amd64/Makefile.config

    rc48f6ab r1f5c9c96  
    5454
    5555# Default framebuffer mode
    56 CONFIG_VESA_MODE = 800x600
     56CONFIG_BFB_MODE = 800x600
    5757
    5858# Default framebuffer depth
    59 CONFIG_VESA_BPP = 16
     59CONFIG_BFB_BPP = 16
    6060
    6161# Load disk drivers on startup
  • defaults/ia32/Makefile.config

    rc48f6ab r1f5c9c96  
    6060
    6161# Default framebuffer mode
    62 CONFIG_VESA_MODE = 800x600
     62CONFIG_BFB_MODE = 800x600
    6363
    6464# Default framebuffer depth
    65 CONFIG_VESA_BPP = 16
     65CONFIG_BFB_BPP = 16
    6666
    6767# Load disk drivers on startup
  • kernel/arch/amd64/Makefile.inc

    rc48f6ab r1f5c9c96  
    7272ARCH_SOURCES = \
    7373        arch/$(KARCH)/src/fpu_context.c \
    74         arch/$(KARCH)/src/boot/boot.S \
     74        arch/$(KARCH)/src/boot/multiboot.S \
     75        arch/$(KARCH)/src/boot/multiboot2.S \
    7576        arch/$(KARCH)/src/boot/memmap.c \
    7677        arch/$(KARCH)/src/debug/stacktrace.c \
     
    7980        arch/$(KARCH)/src/context.S \
    8081        arch/$(KARCH)/src/ddi/ddi.c \
    81         arch/$(KARCH)/src/drivers/vesa.c \
    8282        arch/$(KARCH)/src/drivers/i8254.c \
    8383        arch/$(KARCH)/src/drivers/i8259.c \
  • kernel/arch/amd64/include/arch.h

    rc48f6ab r1f5c9c96  
    3838#include <genarch/multiboot/multiboot.h>
    3939
    40 extern void arch_pre_main(uint32_t, const multiboot_info_t *);
     40extern void arch_pre_main(uint32_t, void *);
    4141
    4242#endif
  • kernel/arch/amd64/include/boot/boot.h

    rc48f6ab r1f5c9c96  
    4040#define BOOT_STACK_SIZE  0x000400
    4141
    42 #define MULTIBOOT_HEADER_MAGIC  0x1BADB002
    43 #define MULTIBOOT_HEADER_FLAGS  0x00010003
    44 
    4542#ifndef __ASM__
    4643
  • kernel/arch/amd64/src/amd64.c

    rc48f6ab r1f5c9c96  
    4141#include <proc/thread.h>
    4242#include <genarch/multiboot/multiboot.h>
     43#include <genarch/multiboot/multiboot2.h>
    4344#include <genarch/drivers/legacy/ia32/io.h>
    4445#include <genarch/drivers/ega/ega.h>
    45 #include <arch/drivers/vesa.h>
     46#include <genarch/fb/bfb.h>
    4647#include <genarch/drivers/i8042/i8042.h>
    4748#include <genarch/kbrd/kbrd.h>
     
    101102/** Perform amd64-specific initialization before main_bsp() is called.
    102103 *
    103  * @param signature Should contain the multiboot signature.
    104  * @param mi        Pointer to the multiboot information structure.
    105  */
    106 void arch_pre_main(uint32_t signature, const multiboot_info_t *mi)
     104 * @param signature Multiboot signature.
     105 * @param info      Multiboot information structure.
     106 *
     107 */
     108void arch_pre_main(uint32_t signature, void *info)
    107109{
    108110        /* Parse multiboot information obtained from the bootloader. */
    109         multiboot_info_parse(signature, mi);
     111        multiboot_info_parse(signature, (multiboot_info_t *) info);
     112        multiboot2_info_parse(signature, (multiboot2_info_t *) info);
    110113       
    111114#ifdef CONFIG_SMP
     
    153156               
    154157#if (defined(CONFIG_FB) || defined(CONFIG_EGA))
    155                 bool vesa = false;
     158                bool bfb = false;
    156159#endif
    157160               
    158161#ifdef CONFIG_FB
    159                 vesa = vesa_init();
     162                bfb = bfb_init();
    160163#endif
    161164               
    162165#ifdef CONFIG_EGA
    163                 if (!vesa) {
     166                if (!bfb) {
    164167                        outdev_t *egadev = ega_init(EGA_BASE, EGA_VIDEORAM);
    165168                        if (egadev)
  • kernel/arch/amd64/src/boot/memmap.c

    rc48f6ab r1f5c9c96  
    3535#include <arch/boot/memmap.h>
    3636
    37 uint8_t e820counter = 0xffU;
     37uint8_t e820counter = 0;
    3838e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
    3939
  • kernel/arch/amd64/src/boot/multiboot.S

    rc48f6ab r1f5c9c96  
    3030
    3131#include <arch/boot/boot.h>
    32 #include <arch/boot/memmap.h>
    3332#include <arch/mm/page.h>
    3433#include <arch/mm/ptl.h>
    3534#include <arch/pm.h>
     35#include <genarch/multiboot/multiboot.h>
     36#include <arch/cpuid.h>
    3637#include <arch/cpu.h>
    37 #include <arch/cpuid.h>
    3838
    3939#define START_STACK  (BOOT_OFFSET - BOOT_STACK_SIZE)
     
    101101        multiboot_meeting_point:
    102102       
    103         /* Save GRUB arguments */
    104         movl %eax, grub_eax
    105         movl %ebx, grub_ebx
     103        /*
     104         * Protected 32-bit. We want to reuse the code-seg descriptor,
     105         * the Default operand size must not be 1 when entering long mode.
     106         */
     107       
     108        /* Save multiboot arguments */
     109        movl %eax, multiboot_eax
     110        movl %ebx, multiboot_ebx
    106111       
    107112        pm_status $status_prot
     
    149154       
    150155#include "vesa_prot.inc"
    151        
    152         /*
    153          * Protected 32-bit. We want to reuse the code-seg descriptor,
    154          * the Default operand size must not be 1 when entering long mode.
    155          */
    156156       
    157157        pm2_status $status_prot2
     
    422422        long_status $status_long
    423423       
    424         /* Call arch_pre_main(grub_eax, grub_ebx) */
     424        /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */
    425425        xorq %rdi, %rdi
    426         movl grub_eax, %edi
     426        movl multiboot_eax, %edi
    427427        xorq %rsi, %rsi
    428         movl grub_ebx, %esi
     428        movl multiboot_ebx, %esi
    429429       
    430430        movabsq $arch_pre_main, %rax
     
    645645.section K_DATA_START, "aw", @progbits
    646646
     647.global bootstrap_gdtr
    647648bootstrap_gdtr:
    648649        .word GDT_SELECTOR(GDT_ITEMS)
    649650        .long KA2PA(gdt)
    650651
    651 grub_eax:
     652.global multiboot_eax
     653multiboot_eax:
    652654        .long 0
    653655
    654 grub_ebx:
     656.global multiboot_ebx
     657multiboot_ebx:
    655658        .long 0
    656659
     
    670673status_vesa_copy:
    671674        .asciz "[vesa_copy] "
    672 status_grub_cmdline:
    673         .asciz "[grub_cmdline] "
     675status_multiboot_cmdline:
     676        .asciz "[multiboot_cmdline] "
    674677status_vesa_real:
    675678        .asciz "[vesa_real] "
  • kernel/arch/ia32/Makefile.inc

    rc48f6ab r1f5c9c96  
    106106        arch/$(KARCH)/src/drivers/i8254.c \
    107107        arch/$(KARCH)/src/drivers/i8259.c \
    108         arch/$(KARCH)/src/drivers/vesa.c \
    109         arch/$(KARCH)/src/boot/boot.S \
     108        arch/$(KARCH)/src/boot/multiboot.S \
     109        arch/$(KARCH)/src/boot/multiboot2.S \
    110110        arch/$(KARCH)/src/boot/memmap.c \
    111111        arch/$(KARCH)/src/fpu_context.c \
  • kernel/arch/ia32/include/arch.h

    rc48f6ab r1f5c9c96  
    3636#define KERN_ia32_ARCH_H_
    3737
    38 #include <genarch/multiboot/multiboot.h>
     38#include <typedefs.h>
    3939
    40 extern void arch_pre_main(uint32_t, const multiboot_info_t *);
     40extern void arch_pre_main(uint32_t, void *);
    4141
    4242#endif
  • kernel/arch/ia32/include/boot/boot.h

    rc48f6ab r1f5c9c96  
    4040#define BOOT_STACK_SIZE  0x0400
    4141
    42 #define MULTIBOOT_HEADER_MAGIC  0x1BADB002
    43 #define MULTIBOOT_HEADER_FLAGS  0x00010003
    44 
    45 #define MULTIBOOT_LOADER_MAGIC  0x2BADB002
    46 
    4742#ifndef __ASM__
    4843
  • kernel/arch/ia32/src/boot/memmap.c

    rc48f6ab r1f5c9c96  
    3535#include <arch/boot/memmap.h>
    3636
    37 uint8_t e820counter = 0xffU;
     37uint8_t e820counter = 0;
    3838e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
    3939
  • kernel/arch/ia32/src/boot/multiboot.S

    rc48f6ab r1f5c9c96  
    3030
    3131#include <arch/boot/boot.h>
    32 #include <arch/boot/memmap.h>
    3332#include <arch/mm/page.h>
    3433#include <arch/pm.h>
     34#include <genarch/multiboot/multiboot.h>
    3535#include <arch/cpuid.h>
    3636
     
    9292        multiboot_meeting_point:
    9393       
    94         /* Save GRUB arguments */
    95         movl %eax, grub_eax
    96         movl %ebx, grub_ebx
     94        /* Save multiboot arguments */
     95        movl %eax, multiboot_eax
     96        movl %ebx, multiboot_ebx
    9797       
    9898        pm_status $status_prot
     
    135135        pm2_status $status_prot3
    136136       
    137         /* Call arch_pre_main(grub_eax, grub_ebx) */
    138         pushl grub_ebx
    139         pushl grub_eax
     137        /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */
     138        pushl multiboot_ebx
     139        pushl multiboot_eax
    140140        call arch_pre_main
    141141       
     
    196196 *
    197197 */
     198.global map_kernel_non_pse
    198199map_kernel_non_pse:
    199200        /* Paging features */
     
    299300find_mem_for_pt:
    300301        /* Check if multiboot info is present */
    301         cmpl $MULTIBOOT_LOADER_MAGIC, grub_eax
     302        cmpl $MULTIBOOT_LOADER_MAGIC, multiboot_eax
    302303        je check_multiboot_map
    303304               
     
    307308               
    308309                /* Copy address of the multiboot info to ebx */
    309                 movl grub_ebx, %ebx
     310                movl multiboot_ebx, %ebx
    310311               
    311312                /* Check if memory map flag is present */
     
    701702        .space 4096, 0
    702703
     704.global bootstrap_gdtr
    703705bootstrap_gdtr:
    704706        .word GDT_SELECTOR(GDT_ITEMS)
    705707        .long KA2PA(gdt)
    706708
    707 grub_eax:
     709.global multiboot_eax
     710multiboot_eax:
    708711        .long 0
    709 grub_ebx:
     712
     713.global multiboot_ebx
     714multiboot_ebx:
    710715        .long 0
    711716
     
    725730status_vesa_copy:
    726731        .asciz "[vesa_copy] "
    727 status_grub_cmdline:
    728         .asciz "[grub_cmdline] "
     732status_multiboot_cmdline:
     733        .asciz "[multiboot_cmdline] "
    729734status_vesa_real:
    730735        .asciz "[vesa_real] "
  • kernel/arch/ia32/src/boot/vesa_prot.inc

    rc48f6ab r1f5c9c96  
    11#ifdef CONFIG_FB
    22
    3 #define MULTIBOOT_LOADER_MAGIC  0x2BADB002
    43#define MBINFO_BIT_CMDLINE      2
    54#define MBINFO_OFFSET_CMDLINE   16
     
    1413        rep movsb
    1514       
    16         /* Check for GRUB command line */
     15        /* Check for multiboot command line */
    1716       
    18         pm_status $status_grub_cmdline
     17        pm_status $status_multiboot_cmdline
    1918       
    20         mov grub_eax, %eax
     19        mov multiboot_eax, %eax
    2120        cmp $MULTIBOOT_LOADER_MAGIC, %eax
    2221        jne no_cmdline
    2322       
    24         mov grub_ebx, %ebx
     23        mov multiboot_ebx, %ebx
    2524        mov (%ebx), %eax
    2625        bt $MBINFO_BIT_CMDLINE, %eax
     
    8988                /* Returned back to protected mode */
    9089               
    91                 mov %ax, KA2PA(vesa_scanline)
     90                movzx %ax, %ecx
     91                mov %ecx, KA2PA(bfb_scanline)
     92               
    9293                shr $16, %eax
    93                 mov %ax, KA2PA(vesa_bpp)
     94                mov %ax, KA2PA(bfb_bpp)
    9495               
    95                 mov %bx, KA2PA(vesa_height)
     96                movzx %bx, %ecx
     97                mov %ecx, KA2PA(bfb_height)
     98               
    9699                shr $16, %ebx
    97                 mov %bx, KA2PA(vesa_width)
     100                mov %ebx, KA2PA(bfb_width)
    98101               
    99                 mov %dl, KA2PA(vesa_green_pos)
     102                mov %dl, KA2PA(bfb_green_pos)
     103               
    100104                shr $8, %edx
    101                 mov %dl, KA2PA(vesa_green_mask)
     105                mov %dl, KA2PA(bfb_green_size)
     106               
    102107                shr $8, %edx
    103                 mov %dl, KA2PA(vesa_red_pos)
     108                mov %dl, KA2PA(bfb_red_pos)
     109               
    104110                shr $8, %edx
    105                 mov %dl, KA2PA(vesa_red_mask)
     111                mov %dl, KA2PA(bfb_red_size)
    106112               
    107113                mov %esi, %edx
    108                 mov %dl, KA2PA(vesa_blue_pos)
     114                mov %dl, KA2PA(bfb_blue_pos)
     115               
    109116                shr $8, %edx
    110                 mov %dl, KA2PA(vesa_blue_mask)
     117                mov %dl, KA2PA(bfb_blue_size)
    111118               
    112                 mov %edi, KA2PA(vesa_ph_addr)
     119                mov %edi, KA2PA(bfb_addr)
    113120#endif
  • kernel/arch/ia32/src/boot/vesa_real.inc

    rc48f6ab r1f5c9c96  
    304304                /*
    305305                 * Store mode parameters:
    306                  *  eax = bpp[8] scanline[16]
     306                 *  eax = bpp[16] scanline[16]
    307307                 *  ebx = width[16]  height[16]
    308308                 *  edx = red_mask[8] red_pos[8] green_mask[8] green_pos[8]
     
    328328                shl $8, %edx
    329329                mov VESA_MODE_RED_POS_OFFSET(%di), %dl
     330               
    330331                shl $8, %edx
    331332                mov VESA_MODE_GREEN_MASK_OFFSET(%di), %dl
     
    369370                mov $0x0003, %ax
    370371                int $0x10
     372               
     373                xor %eax, %eax
     374                xor %ebx, %ebx
     375                xor %edx, %edx
    371376                mov $0xffffffff, %edi
    372                 xor %ax, %ax
     377               
    373378                jz vesa_leave_real  /* force relative jump */
    374379
     
    386391
    387392default_mode:
    388         .ascii STRING(CONFIG_VESA_MODE)
     393        .ascii STRING(CONFIG_BFB_MODE)
    389394        .ascii "-"
    390         .asciz STRING(CONFIG_VESA_BPP)
     395        .asciz STRING(CONFIG_BFB_BPP)
    391396        .fill 24
    392397
  • kernel/arch/ia32/src/ia32.c

    rc48f6ab r1f5c9c96  
    4242
    4343#include <genarch/multiboot/multiboot.h>
     44#include <genarch/multiboot/multiboot2.h>
    4445#include <genarch/drivers/legacy/ia32/io.h>
    4546#include <genarch/drivers/ega/ega.h>
    46 #include <arch/drivers/vesa.h>
     47#include <genarch/fb/bfb.h>
    4748#include <genarch/drivers/i8042/i8042.h>
    4849#include <genarch/kbrd/kbrd.h>
     
    7677/** Perform ia32-specific initialization before main_bsp() is called.
    7778 *
    78  * @param signature Should contain the multiboot signature.
    79  * @param mi        Pointer to the multiboot information structure.
    80  */
    81 void arch_pre_main(uint32_t signature, const multiboot_info_t *mi)
     79 * @param signature Multiboot signature.
     80 * @param info      Multiboot information structure.
     81 *
     82 */
     83void arch_pre_main(uint32_t signature, void *info)
    8284{
    8385        /* Parse multiboot information obtained from the bootloader. */
    84         multiboot_info_parse(signature, mi);
     86        multiboot_info_parse(signature, (multiboot_info_t *) info);
     87        multiboot2_info_parse(signature, (multiboot2_info_t *) info);
    8588       
    8689#ifdef CONFIG_SMP
     
    114117               
    115118#if (defined(CONFIG_FB) || defined(CONFIG_EGA))
    116                 bool vesa = false;
     119                bool bfb = false;
    117120#endif
    118121               
    119122#ifdef CONFIG_FB
    120                 vesa = vesa_init();
     123                bfb = bfb_init();
    121124#endif
    122125               
    123126#ifdef CONFIG_EGA
    124                 if (!vesa) {
     127                if (!bfb) {
    125128                        outdev_t *egadev = ega_init(EGA_BASE, EGA_VIDEORAM);
    126129                        if (egadev)
  • kernel/genarch/Makefile.inc

    rc48f6ab r1f5c9c96  
    6767                genarch/src/fb/font-8x16.c \
    6868                genarch/src/fb/logo-196x66.c \
    69                 genarch/src/fb/fb.c
     69                genarch/src/fb/fb.c \
     70                genarch/src/fb/bfb.c
    7071endif
    7172
     
    143144ifeq ($(CONFIG_MULTIBOOT), y)
    144145        GENARCH_SOURCES += \
    145                 genarch/src/multiboot/multiboot.c
     146                genarch/src/multiboot/multiboot.c \
     147                genarch/src/multiboot/multiboot2.c
    146148endif
    147149
  • kernel/genarch/include/fb/bfb.h

    rc48f6ab r1f5c9c96  
    2727 */
    2828
    29 /** @addtogroup ia32
     29/** @addtogroup genarch
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_ia32_VESA_H_
    36 #define KERN_ia32_VESA_H_
     35#ifndef KERN_BFB_H_
     36#define KERN_BFB_H_
    3737
    3838#include <typedefs.h>
    3939
    40 extern bool vesa_init(void);
     40extern uintptr_t bfb_addr;
     41extern uint32_t bfb_width;
     42extern uint32_t bfb_height;
     43extern uint16_t bfb_bpp;
     44extern uint32_t bfb_scanline;
     45
     46extern uint8_t bfb_red_pos;
     47extern uint8_t bfb_red_size;
     48
     49extern uint8_t bfb_green_pos;
     50extern uint8_t bfb_green_size;
     51
     52extern uint8_t bfb_blue_pos;
     53extern uint8_t bfb_blue_size;
     54
     55extern bool bfb_init(void);
    4156
    4257#endif
  • kernel/genarch/include/multiboot/multiboot.h

    rc48f6ab r1f5c9c96  
    3636#define KERN_MULTIBOOT_H_
    3737
     38#define MULTIBOOT_HEADER_MAGIC  0x1badb002
     39#define MULTIBOOT_HEADER_FLAGS  0x00010003
     40
     41#define MULTIBOOT_LOADER_MAGIC  0x2badb002
     42
     43#ifndef __ASM__
     44
    3845#include <typedefs.h>
    3946#include <arch/boot/memmap.h>
     47
     48/** Convert 32-bit multiboot address to a pointer. */
     49#define MULTIBOOT_PTR(mba)  ((void *) (uintptr_t) (mba))
    4050
    4151/** Multiboot 32-bit address. */
    4252typedef uint32_t mbaddr_t;
    4353
    44 /** Multiboot mod structure */
     54/** Multiboot module structure */
    4555typedef struct {
    4656        mbaddr_t start;
     
    4858        mbaddr_t string;
    4959        uint32_t reserved;
    50 } __attribute__ ((packed)) multiboot_mod_t;
     60} __attribute__((packed)) multiboot_module_t;
    5161
    5262/** Multiboot mmap structure */
     
    5464        uint32_t size;
    5565        e820memmap_t mm_info;
    56 } __attribute__ ((packed)) multiboot_mmap_t;
     66} __attribute__((packed)) multiboot_memmap_t;
    5767
    5868/** Multiboot information structure */
     
    7484       
    7585        /* ... */
    76 } __attribute__ ((packed)) multiboot_info_t;
     86} __attribute__((packed)) multiboot_info_t;
    7787
    7888enum multiboot_info_flags {
    79         MBINFO_FLAGS_MEM     = 0x01,
    80         MBINFO_FLAGS_BOOT    = 0x02,
    81         MBINFO_FLAGS_CMDLINE = 0x04,
    82         MBINFO_FLAGS_MODS    = 0x08,
    83         MBINFO_FLAGS_SYMS1   = 0x10,
    84         MBINFO_FLAGS_SYMS2   = 0x20,
    85         MBINFO_FLAGS_MMAP    = 0x40
     89        MULTIBOOT_INFO_FLAGS_MEM     = 0x01,
     90        MULTIBOOT_INFO_FLAGS_BOOT    = 0x02,
     91        MULTIBOOT_INFO_FLAGS_CMDLINE = 0x04,
     92        MULTIBOOT_INFO_FLAGS_MODS    = 0x08,
     93        MULTIBOOT_INFO_FLAGS_SYMS1   = 0x10,
     94        MULTIBOOT_INFO_FLAGS_SYMS2   = 0x20,
     95        MULTIBOOT_INFO_FLAGS_MMAP    = 0x40
    8696       
    8797        /* ... */
    8898};
    8999
    90 #define MULTIBOOT_LOADER_MAGIC  0x2BADB002
     100extern void multiboot_extract_command(char *, size_t, const char *);
     101extern void multiboot_info_parse(uint32_t, const multiboot_info_t *);
    91102
    92 /** Convert 32-bit multiboot address to a pointer. */
    93 #define MULTIBOOT_PTR(mba) ((void *)(uintptr_t) (mba))
    94 
    95 extern void multiboot_info_parse(uint32_t, const multiboot_info_t *);
     103#endif /* __ASM__ */
    96104
    97105#endif
  • kernel/genarch/src/fb/bfb.c

    rc48f6ab r1f5c9c96  
    2727 */
    2828
    29 /** @addtogroup ia32
     29/** @addtogroup genarch
    3030 * @{
    3131 */
    3232/**
    3333 * @file
    34  * @brief VESA frame buffer driver.
     34 * @brief Boot framebuffer driver.
    3535 */
    3636
    37 #ifdef CONFIG_FB
     37#include <typedefs.h>
     38#include <genarch/fb/fb.h>
     39#include <genarch/fb/bfb.h>
     40#include <console/console.h>
    3841
    39 #include <genarch/fb/fb.h>
    40 #include <arch/drivers/vesa.h>
    41 #include <console/chardev.h>
    42 #include <console/console.h>
    43 #include <putchar.h>
    44 #include <mm/page.h>
    45 #include <mm/frame.h>
    46 #include <mm/as.h>
    47 #include <arch/mm/page.h>
    48 #include <synch/spinlock.h>
    49 #include <arch/asm.h>
    50 #include <typedefs.h>
    51 #include <memstr.h>
    52 #include <bitops.h>
     42uintptr_t bfb_addr = (uintptr_t) -1;
     43uint32_t bfb_width = 0;
     44uint32_t bfb_height = 0;
     45uint16_t bfb_bpp = 0;
     46uint32_t bfb_scanline = 0;
    5347
    54 uint32_t vesa_ph_addr;
    55 uint16_t vesa_width;
    56 uint16_t vesa_height;
    57 uint16_t vesa_bpp;
    58 uint16_t vesa_scanline;
     48uint8_t bfb_red_pos = 0;
     49uint8_t bfb_red_size = 0;
    5950
    60 uint8_t vesa_red_mask;
    61 uint8_t vesa_red_pos;
     51uint8_t bfb_green_pos = 0;
     52uint8_t bfb_green_size = 0;
    6253
    63 uint8_t vesa_green_mask;
    64 uint8_t vesa_green_pos;
     54uint8_t bfb_blue_pos = 0;
     55uint8_t bfb_blue_size = 0;
    6556
    66 uint8_t vesa_blue_mask;
    67 uint8_t vesa_blue_pos;
    68 
    69 bool vesa_init(void)
     57bool bfb_init(void)
    7058{
    71         if ((vesa_width == 0xffffU) || (vesa_height == 0xffffU))
     59        if ((bfb_width == 0) || (bfb_height == 0))
    7260                return false;
    7361       
    74         visual_t visual;
     62        fb_properties_t bfb_props = {
     63                .addr = bfb_addr,
     64                .offset = 0,
     65                .x = bfb_width,
     66                .y = bfb_height,
     67                .scan = bfb_scanline
     68        };
    7569       
    76         switch (vesa_bpp) {
     70        switch (bfb_bpp) {
    7771        case 8:
    78                 visual = VISUAL_INDIRECT_8;
     72                bfb_props.visual = VISUAL_INDIRECT_8;
    7973                break;
    8074        case 16:
    81                 if ((vesa_red_mask == 5) && (vesa_red_pos == 10)
    82                     && (vesa_green_mask == 5) && (vesa_green_pos == 5)
    83                     && (vesa_blue_mask == 5) && (vesa_blue_pos == 0))
    84                         visual = VISUAL_RGB_5_5_5_LE;
     75                if ((bfb_red_pos == 10) && (bfb_red_size == 5) &&
     76                    (bfb_green_pos == 5) && (bfb_green_size == 5) &&
     77                    (bfb_blue_pos == 0) && (bfb_blue_size == 5))
     78                        bfb_props.visual = VISUAL_RGB_5_5_5_LE;
    8579                else
    86                         visual = VISUAL_RGB_5_6_5_LE;
     80                        bfb_props.visual = VISUAL_RGB_5_6_5_LE;
    8781                break;
    8882        case 24:
    89                 visual = VISUAL_BGR_8_8_8;
     83                bfb_props.visual = VISUAL_BGR_8_8_8;
    9084                break;
    9185        case 32:
    92                 visual = VISUAL_BGR_8_8_8_0;
     86                bfb_props.visual = VISUAL_BGR_8_8_8_0;
    9387                break;
    9488        default:
     
    9791        }
    9892       
    99         fb_properties_t vesa_props = {
    100                 .addr = vesa_ph_addr,
    101                 .offset = 0,
    102                 .x = vesa_width,
    103                 .y = vesa_height,
    104                 .scan = vesa_scanline,
    105                 .visual = visual,
    106         };
    107        
    108         outdev_t *fbdev = fb_init(&vesa_props);
     93        outdev_t *fbdev = fb_init(&bfb_props);
    10994        if (!fbdev)
    11095                return false;
     
    11499}
    115100
    116 #endif
    117 
    118101/** @}
    119102 */
  • kernel/genarch/src/multiboot/multiboot.c

    rc48f6ab r1f5c9c96  
    3333 */
    3434
     35#include <typedefs.h>
    3536#include <genarch/multiboot/multiboot.h>
    36 #include <typedefs.h>
    3737#include <config.h>
    3838#include <str.h>
    39 #include <macros.h>
    4039
    4140/** Extract command name from the multiboot module command line.
    4241 *
    43  * @param buf      Destination buffer (will always NULL-terminate).
    44  * @param s     Size of destination buffer (in bytes).
     42 * @param buf      Destination buffer (will be always NULL-terminated).
     43 * @param size     Size of destination buffer (in bytes).
    4544 * @param cmd_line Input string (the command line).
    4645 *
    4746 */
    48 static void extract_command(char *buf, size_t sz, const char *cmd_line)
     47void multiboot_extract_command(char *buf, size_t size, const char *cmd_line)
    4948{
    5049        /* Find the first space. */
     
    6968       
    7069        /* Copy the command. */
    71         str_ncpy(buf, sz, start, (size_t) (end - start));
     70        str_ncpy(buf, size, start, (size_t) (end - start));
     71}
     72
     73static void multiboot_modules(uint32_t count, multiboot_module_t *mods)
     74{
     75        for (uint32_t i = 0; i < count; i++) {
     76                if (init.cnt >= CONFIG_INIT_TASKS)
     77                        break;
     78               
     79                init.tasks[init.cnt].addr = PA2KA(mods[i].start);
     80                init.tasks[init.cnt].size = mods[i].end - mods[i].start;
     81               
     82                /* Copy command line, if available. */
     83                if (mods[i].string) {
     84                        multiboot_extract_command(init.tasks[init.cnt].name,
     85                            CONFIG_TASK_NAME_BUFLEN, MULTIBOOT_PTR(mods[i].string));
     86                } else
     87                        init.tasks[init.cnt].name[0] = 0;
     88               
     89                init.cnt++;
     90        }
     91}
     92
     93static void multiboot_memmap(uint32_t length, multiboot_memmap_t *memmap)
     94{
     95        uint32_t pos = 0;
     96       
     97        while ((pos < length) && (e820counter < MEMMAP_E820_MAX_RECORDS)) {
     98                e820table[e820counter] = memmap->mm_info;
     99               
     100                /* Compute address of next structure. */
     101                uint32_t size = sizeof(memmap->size) + memmap->size;
     102                memmap = (multiboot_memmap_t *) ((uintptr_t) memmap + size);
     103                pos += size;
     104               
     105                e820counter++;
     106        }
    72107}
    73108
     
    78113 *
    79114 * @param signature Should contain the multiboot signature.
    80  * @param mi        Pointer to the multiboot information structure.
     115 * @param info      Multiboot information structure.
     116 *
    81117 */
    82 void multiboot_info_parse(uint32_t signature, const multiboot_info_t *mi)
     118void multiboot_info_parse(uint32_t signature, const multiboot_info_t *info)
    83119{
    84         uint32_t flags;
     120        if (signature != MULTIBOOT_LOADER_MAGIC)
     121                return;
    85122       
    86         if (signature == MULTIBOOT_LOADER_MAGIC)
    87                 flags = mi->flags;
    88         else {
    89                 /* No multiboot info available. */
    90                 flags = 0;
    91         }
    92        
    93         /* Copy module information. */
    94         uint32_t i;
    95         if ((flags & MBINFO_FLAGS_MODS) != 0) {
    96                 init.cnt = min(mi->mods_count, CONFIG_INIT_TASKS);
    97                 multiboot_mod_t *mods
    98                     = (multiboot_mod_t *) MULTIBOOT_PTR(mi->mods_addr);
    99                
    100                 for (i = 0; i < init.cnt; i++) {
    101                         init.tasks[i].addr = PA2KA(mods[i].start);
    102                         init.tasks[i].size = mods[i].end - mods[i].start;
    103                        
    104                         /* Copy command line, if available. */
    105                         if (mods[i].string) {
    106                                 extract_command(init.tasks[i].name,
    107                                     CONFIG_TASK_NAME_BUFLEN,
    108                                     MULTIBOOT_PTR(mods[i].string));
    109                         } else
    110                                 init.tasks[i].name[0] = 0;
    111                 }
    112         } else
    113                 init.cnt = 0;
     123        /* Copy modules information. */
     124        if ((info->flags & MULTIBOOT_INFO_FLAGS_MODS) != 0)
     125                multiboot_modules(info->mods_count,
     126                    (multiboot_module_t *) MULTIBOOT_PTR(info->mods_addr));
    114127       
    115128        /* Copy memory map. */
    116        
    117         if ((flags & MBINFO_FLAGS_MMAP) != 0) {
    118                 int32_t mmap_length = mi->mmap_length;
    119                 multiboot_mmap_t *mme = MULTIBOOT_PTR(mi->mmap_addr);
    120                 e820counter = 0;
    121                
    122                 i = 0;
    123                 while ((mmap_length > 0) && (i < MEMMAP_E820_MAX_RECORDS)) {
    124                         e820table[i++] = mme->mm_info;
    125                        
    126                         /* Compute address of next structure. */
    127                         uint32_t size = sizeof(mme->size) + mme->size;
    128                         mme = ((void *) mme) + size;
    129                         mmap_length -= size;
    130                 }
    131                
    132                 e820counter = i;
    133         } else
    134                 e820counter = 0;
     129        if ((info->flags & MULTIBOOT_INFO_FLAGS_MMAP) != 0)
     130                multiboot_memmap(info->mmap_length,
     131                    (multiboot_memmap_t *) MULTIBOOT_PTR(info->mmap_addr));
    135132}
    136133
  • tools/config.py

    rc48f6ab r1f5c9c96  
    8585        if ctype == 'cnf':
    8686                return True
     87       
    8788        return False
    8889
     
    242243               
    243244                default = get_default_rule(rule)
    244 
     245               
    245246                #
    246247                # If we don't have a value but we do have
     
    344345        return True
    345346
     347def preprocess_config(config, rules):
     348        "Preprocess configuration"
     349       
     350        varname_mode = 'CONFIG_BFB_MODE'
     351        varname_width = 'CONFIG_BFB_WIDTH'
     352        varname_height = 'CONFIG_BFB_HEIGHT'
     353       
     354        if varname_mode in config:
     355                mode = config[varname_mode].partition('x')
     356               
     357                config[varname_width] = mode[0]
     358                rules.append((varname_width, 'choice', 'Default framebuffer width', None, None))
     359               
     360                config[varname_height] = mode[2]
     361                rules.append((varname_height, 'choice', 'Default framebuffer height', None, None))
     362
    346363def create_output(mkname, mcname, config, rules):
    347364        "Create output configuration"
     
    504521        if (len(sys.argv) >= 3) and (sys.argv[2] == 'default'):
    505522                if (infer_verify_choices(config, rules)):
     523                        preprocess_config(config, rules)
    506524                        create_output(MAKEFILE, MACROS, config, rules)
    507525                        return 0
     
    517535               
    518536                if (infer_verify_choices(config, rules)):
     537                        preprocess_config(config, rules)
    519538                        create_output(MAKEFILE, MACROS, config, rules)
    520539                        return 0
     
    564583                               
    565584                                default = get_default_rule(rule)
    566 
     585                               
    567586                                #
    568587                                # If we don't have a value but we do have
     
    626645                xtui.screen_done(screen)
    627646       
     647        preprocess_config(config, rules)
    628648        create_output(MAKEFILE, MACROS, config, rules)
    629649        return 0
Note: See TracChangeset for help on using the changeset viewer.