Changeset 4872160 in mainline for boot/arch


Ignore:
Timestamp:
2010-05-04T10:44:55Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
568db0f
Parents:
bb252ca
Message:

new boot infrastructure

  • more code and metadata unification
  • import of up-to-date implementations from the kernel
  • the boot loaders should behave more similarly on all platforms
  • support for deflate compressed (LZ77) boot components
    • this again allows feasible boot images to be created on mips32
  • IA64 is still not booting
    • the broken forked GNU EFI library has been removed, a replacement of the functionality is on its way
Location:
boot/arch
Files:
12 added
144 deleted
5 edited
32 moved

Legend:

Unmodified
Added
Removed
  • boot/arch/amd64/Makefile.inc

    rbb252ca r4872160  
    2727#
    2828
    29 include Makefile.common
     29PAGE_SIZE = 4096
    3030
    3131RD_SRVS += \
    32         $(USPACEDIR)/srv/bd/ata_bd/ata_bd \
    33         $(USPACEDIR)/srv/hw/char/i8042/i8042 \
    34         $(USPACEDIR)/srv/hw/bus/pci/pci \
    35         $(USPACEDIR)/srv/hid/char_mouse/char_ms
     32        $(USPACE_PATH)/srv/bd/ata_bd/ata_bd \
     33        $(USPACE_PATH)/srv/hw/char/i8042/i8042 \
     34        $(USPACE_PATH)/srv/hw/bus/pci/pci \
     35        $(USPACE_PATH)/srv/hid/char_mouse/char_ms
    3636
    37 MODULES := $(notdir $(COMPONENTS))
    38 
    39 build: $(BASE)/image.iso
    40 
    41 $(BASE)/image.iso: arch/$(BARCH)/grub/stage2_eltorito $(COMPONENTS) $(INIT_TASKS) $(RD_SRVS) $(RD_APPS) $(CFG)
    42         mkdir -p $(TMP)/boot/grub
    43         cp arch/$(BARCH)/grub/stage2_eltorito $(TMP)/boot/grub/
    44        
    45         echo "default 0" > $(TMP)/boot/grub/menu.lst
    46         echo "timeout 10" >> $(TMP)/boot/grub/menu.lst
    47         echo "" >> $(TMP)/boot/grub/menu.lst
    48         echo "title=HelenOS" >> $(TMP)/boot/grub/menu.lst
    49         echo "  root (cd)" >> $(TMP)/boot/grub/menu.lst
    50         for module in $(MODULES) $(INITRD).img ; do \
    51                 if [ $$module = kernel.bin ] ; then \
    52                         echo "  kernel /boot/$$module" >> $(TMP)/boot/grub/menu.lst ; \
    53                 else \
    54                         echo "  module /boot/$$module" >> $(TMP)/boot/grub/menu.lst ; \
    55                 fi \
    56         done
    57        
    58         rm -f $(USPACEDIR)/dist/srv/*
    59         rm -f $(USPACEDIR)/dist/app/*
    60         rm -f $(USPACEDIR)/dist/cfg/net/*
    61        
    62         cp $(KERNELDIR)/kernel.bin $(TMP)/boot/
    63         for task in $(INIT_TASKS) ; do \
    64                 cp $$task $(TMP)/boot/ ; \
    65         done
    66         for file in $(RD_SRVS) ; do \
    67                 cp $$file $(USPACEDIR)/dist/srv/ ; \
    68         done
    69         for file in $(RD_APPS) ; do \
    70                 cp $$file $(USPACEDIR)/dist/app/ ; \
    71         done
    72         for file in $(NET_CFG) ; do \
    73                 cp $$file $(USPACEDIR)/dist/cfg/net/ ; \
    74         done
    75        
    76 ifeq ($(RDFMT),tmpfs)
    77         $(BASE)/tools/mktmpfs.py $(USPACEDIR)/dist/ $(TMP)/boot/$(INITRD).fs
    78 endif
    79 ifeq ($(RDFMT),fat)
    80         $(BASE)/tools/mkfat.py $(USPACEDIR)/dist/ $(TMP)/boot/$(INITRD).fs
    81 endif
    82         $(BASE)/tools/mkhord.py 4096 $(TMP)/boot/$(INITRD).fs $(TMP)/boot/$(INITRD).img
    83         rm $(TMP)/boot/$(INITRD).fs
    84         mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $@ $(TMP)/
    85 
    86 clean:
    87         rm -f $(USPACEDIR)/dist/srv/*
    88         rm -f $(USPACEDIR)/dist/app/*
    89         rm -f $(USPACEDIR)/dist/cfg/net/*
    90 
    91         for file in $(RD_SRVS) ; do \
    92                 rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
    93         done
    94         for file in $(RD_APPS) ; do \
    95                 rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    96         done
    97         for file in $(NET_CFG) ; do \
    98                 rm -f $(USPACEDIR)/dist/cfg/net/`basename $$file` ; \
    99         done
    100         rm -fr $(TMP)
    101         rm -f $(BASE)/image.iso
     37BOOT_OUTPUT = $(ROOT_PATH)/image.iso
     38PREBUILD = $(INITRD).img
     39BUILD = Makefile.grub
  • boot/arch/arm32/Makefile.inc

    rbb252ca r4872160  
    2727#
    2828
    29 include Makefile.common
     29BFD_NAME = elf32-littlearm
     30BFD_OUTPUT = $(BFD_NAME)
     31BFD_ARCH = arm
    3032
    31 build: $(BASE)/image.boot
     33BITS = 32
     34ENDIANESS = LE
     35PAGE_SIZE = 4096
    3236
    33 $(BASE)/image.boot: $(COMPONENTS) $(INIT_TASKS) $(RD_SRVS) $(RD_APPS) $(CFG)
    34         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
    35         cp arch/$(BARCH)/loader/image.boot $@
     37RD_SRVS += \
     38        $(USPACE_PATH)/srv/bd/gxe_bd/gxe_bd
    3639
    37 clean:
    38         $(MAKE) -C arch/$(BARCH)/loader clean
    39         rm -f $(BASE)/image.boot
     40SOURCES = \
     41        arch/$(BARCH)/src/asm.S \
     42        arch/$(BARCH)/src/main.c \
     43        arch/$(BARCH)/src/mm.c \
     44        arch/$(BARCH)/src/putchar.c \
     45        $(COMPS_C) \
     46        genarch/src/division.c \
     47        generic/src/printf_core.c \
     48        generic/src/vprintf.c \
     49        generic/src/printf.c \
     50        generic/src/str.c \
     51        generic/src/version.c \
     52        generic/src/inflate.c
  • boot/arch/arm32/include/arch.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef BOOT_ia64_TYPES_H_
    30 #define BOOT_ia64_TYPES_H_
     29#ifndef BOOT_arm32_ARCH_H
     30#define BOOT_arm32_ARCH_H
    3131
    32 #include <gentypes.h>
     32#define PAGE_WIDTH  12
     33#define PAGE_SIZE   (1 << PAGE_WIDTH)
    3334
    34 typedef signed char int8_t;
     35#define PTL0_ENTRIES     4096
     36#define PTL0_ENTRY_SIZE  4
    3537
    36 typedef unsigned char uint8_t;
    37 typedef unsigned short uint16_t;
    38 typedef unsigned int uint32_t;
    39 typedef unsigned long uint64_t;
     38#define BOOT_OFFSET  0x800000
    4039
    41 typedef uint64_t uintptr_t;
    42 typedef uint64_t unative_t;
     40#ifndef __ASM__
     41        #define PA2KA(addr)  (((uintptr_t) (addr)) + 0x80000000)
     42#else
     43        #define PA2KA(addr)  ((addr) + 0x80000000)
     44#endif
    4345
    4446#endif
     47
     48/** @}
     49 */
  • boot/arch/arm32/include/asm.h

    rbb252ca r4872160  
    2727 */
    2828
    29 
    3029/** @addtogroup arm32boot
    3130 * @{
    3231 */
    3332/** @file
    34  *  @brief Functions implemented in assembly.
     33 * @brief Functions implemented in assembly.
    3534 */
    36 
    3735
    3836#ifndef BOOT_arm32_ASM_H
    3937#define BOOT_arm32_ASM_H
    4038
     39#include <arch/arch.h>
     40#include <arch/mm.h>
    4141
    42 /** Called when the CPU is switched on.
     42extern pte_level0_section_t boot_pt[PTL0_ENTRIES];
     43extern void *boot_stack;
     44
     45/** Jump to the kernel entry point.
    4346 *
    44  *  This function is placed to the 0x0 address where ARM CPU starts execution.
    45  *  Jumps to the #bootstrap only.
    46  */
    47 extern void start(void);
    48 
    49 
    50 /** Jumps to the kernel entry point.
    51  *
    52  * @param entry    Kernel entry point address.
     47 * @param entry    Kernel entry point.
    5348 * @param bootinfo Structure holding information about loaded tasks.
    5449 *
    5550 */
    56 extern void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn));
    57 
     51extern void jump_to_kernel(void *entry, void *bootinfo)
     52    __attribute__((noreturn));
    5853
    5954#endif
  • boot/arch/arm32/include/main.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2007 Michal Kebrt
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 
    3029/** @addtogroup arm32boot
    3130 * @{
    3231 */
    33 /** @file 
    34  *  @brief Definitions of basic types like #uintptr_t.
    35  */ 
     32/** @file
     33 * @brief Boot related declarations.
     34 */
    3635
     36#ifndef BOOT_arm32_MAIN_H
     37#define BOOT_arm32_MAIN_H
    3738
    38 #ifndef BOOT_arm32_TYPES_H
    39 #define BOOT_arm32_TYPES_H
     39/** Address where characters to be printed are expected. */
     40#ifdef MACHINE_testarm
     41        #define VIDEORAM_ADDRESS  0x10000000
     42#endif
    4043
     44#ifdef MACHINE_integratorcp
     45        #define VIDEORAM_ADDRESS  0x16000000
     46#endif
    4147
    42 #include <gentypes.h>
    43 
    44 typedef signed char int8_t;
    45 
    46 typedef unsigned char uint8_t;
    47 typedef unsigned short uint16_t;
    48 typedef unsigned int uint32_t;
    49 typedef unsigned long long uint64_t;
    50 
    51 typedef uint32_t uintptr_t;
    52 typedef uint32_t unative_t;
    53 
     48extern void bootstrap(void);
    5449
    5550#endif
    5651
    57 
    5852/** @}
    5953 */
  • boot/arch/arm32/include/mm.h

    rbb252ca r4872160  
    11/*
     2 * Copyright (c) 2007 Pavel Jancik
    23 * Copyright (c) 2007 Michal Kebrt
    34 * All rights reserved.
     
    2728 */
    2829
    29 
    3030/** @addtogroup arm32boot
    3131 * @{
    3232 */
    3333/** @file
    34  *  @brief Boot related declarations.
     34 * @brief Memory management used while booting the kernel.
     35 *
     36 * So called "section" paging is used while booting the kernel. The term
     37 * "section" comes from the ARM architecture specification and stands for the
     38 * following: one-level paging, 1MB sized pages, 4096 entries in the page
     39 * table.
    3540 */
    3641
     42#ifndef BOOT_arm32__MM_H
     43#define BOOT_arm32__MM_H
    3744
    38 #ifndef BOOT_arm32_MAIN_H
    39 #define BOOT_arm32_MAIN_H
     45#include <typedefs.h>
    4046
     47/** Describe "section" page table entry (one-level paging with 1 MB sized pages). */
     48#define PTE_DESCRIPTOR_SECTION  0x02
    4149
    42 /** Maximum number of tasks in the #bootinfo_t struct. */
    43 #define TASKMAP_MAX_RECORDS 32
     50/** Page table access rights: user - no access, kernel - read/write. */
     51#define PTE_AP_USER_NO_KERNEL_RW  0x01
    4452
    45 /** Size of buffer for storing task name in task_t. */
    46 #define BOOTINFO_TASK_NAME_BUFLEN 32
     53/* Page table level 0 entry - "section" format is used
     54 * (one-level paging, 1 MB sized pages). Used only while booting the kernel.
     55 */
     56typedef struct {
     57        unsigned int descriptor_type : 2;
     58        unsigned int bufferable : 1;
     59        unsigned int cacheable : 1;
     60        unsigned int impl_specific : 1;
     61        unsigned int domain : 4;
     62        unsigned int should_be_zero_1 : 1;
     63        unsigned int access_permission : 2;
     64        unsigned int should_be_zero_2 : 8;
     65        unsigned int section_base_addr : 12;
     66} __attribute__((packed)) pte_level0_section_t;
    4767
    48 
    49 /** Struct holding information about single loaded task. */
    50 typedef struct {
    51         /** Address where the task was placed. */
    52         void *addr;
    53         /** Size of the task's binary. */
    54         unsigned int size;
    55         /** Task name. */
    56         char name[BOOTINFO_TASK_NAME_BUFLEN];
    57 } task_t;
    58 
    59 
    60 /** Struct holding information about loaded tasks. */
    61 typedef struct {
    62         /** Number of loaded tasks. */
    63         unsigned int cnt;
    64         /** Array of loaded tasks. */
    65         task_t tasks[TASKMAP_MAX_RECORDS];
    66 } bootinfo_t;
    67 
    68 
    69 extern void bootstrap(void);
     68extern void mmu_start(void);
    7069
    7170#endif
  • boot/arch/arm32/include/types.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2005 Martin Decky
     2 * Copyright (c) 2006 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef BOOT_ppc32_MAIN_H_
    30 #define BOOT_ppc32_MAIN_H_
     29/** @addtogroup arm32boot
     30 * @{
     31 */
     32/** @file
     33 * @brief Definitions of basic types like #uintptr_t.
     34 */
    3135
    32 #include <ofw.h>
    33 #include <ofw_tree.h>
    34 #include <balloc.h>
    35 #include <types.h>
     36#ifndef BOOT_arm32_TYPES_H
     37#define BOOT_arm32_TYPES_H
    3638
    37 #define TASKMAP_MAX_RECORDS  32
    38 
    39 /** Size of buffer for storing task name in task_t. */
     39#define TASKMAP_MAX_RECORDS        32
    4040#define BOOTINFO_TASK_NAME_BUFLEN  32
    4141
     42typedef uint32_t size_t;
     43typedef uint32_t uintptr_t;
     44
     45typedef uint32_t pfn_t;
     46
    4247typedef struct {
     48        /** Address where the task was placed. */
    4349        void *addr;
    44         uint32_t size;
     50        /** Size of the task's binary. */
     51        size_t size;
     52        /** Task name. */
    4553        char name[BOOTINFO_TASK_NAME_BUFLEN];
    4654} task_t;
    4755
    4856typedef struct {
    49         uint32_t count;
     57        size_t cnt;
    5058        task_t tasks[TASKMAP_MAX_RECORDS];
    51 } taskmap_t;
    52 
    53 typedef struct {
    54         memmap_t memmap;
    55         taskmap_t taskmap;
    56         ballocs_t ballocs;
    57         ofw_tree_node_t *ofw_root;
    5859} bootinfo_t;
    5960
    60 extern void start(void);
    61 extern void bootstrap(void);
     61#endif
    6262
    63 #endif
     63/** @}
     64 */
  • boot/arch/arm32/src/asm.S

    rbb252ca r4872160  
    2727#
    2828
    29 
    30 #include "mm.h"
     29#include <arch/arch.h>
    3130
    3231.section BOOTSTRAP
    3332
    3433.global start
     34.global boot_pt
     35.global boot_stack
     36.global halt
     37.global memcpy
    3538.global jump_to_kernel
    36 .global page_table
    37 .global boot_stack
    3839
    3940start:
    4041        ldr sp, =boot_stack
    4142        b bootstrap
     43
     44.section BOOTPT
     45boot_pt:
     46        .space PTL0_ENTRIES * PTL0_ENTRY_SIZE
     47
     48.section BOOTSTACK
     49        .space 4096
     50boot_stack:
     51
     52.text
     53
     54halt:
     55        b halt
     56
     57memcpy:
     58        add r3, r1, #3
     59        bic r3, r3, #3
     60        cmp r1, r3
     61        stmdb sp!, {r4, r5, lr}
     62        mov r5, r0
     63        beq 4f
     64       
     65        1:
     66                cmp r2, #0
     67                movne ip, #0
     68                beq 3f
     69       
     70        2:
     71                ldrb r3, [ip, r1]
     72                strb r3, [ip, r0]
     73                add ip, ip, #1
     74                cmp ip, r2
     75                bne 2b
     76       
     77        3:
     78                mov r0, r5
     79                ldmia sp!, {r4, r5, pc}
     80       
     81        4:
     82                add r3, r0, #3
     83                bic r3, r3, #3
     84                cmp r0, r3
     85                bne 1b
     86                movs r4, r2, lsr #2
     87                moveq lr, r4
     88                beq 6f
     89                mov lr, #0
     90                mov ip, lr
     91       
     92        5:
     93                ldr r3, [ip, r1]
     94                add lr, lr, #1
     95                cmp lr, r4
     96                str r3, [ip, r0]
     97                add ip, ip, #4
     98                bne 5b
     99       
     100        6:
     101                ands r4, r2, #3
     102                beq 3b
     103                mov r3, lr, lsl #2
     104                add r0, r3, r0
     105                add ip, r3, r1
     106                mov r2, #0
     107       
     108        7:
     109                ldrb r3, [r2, ip]
     110                strb r3, [r2, r0]
     111                add r2, r2, #1
     112                cmp r2, r4
     113                bne 7b
     114                b 3b
    42115
    43116jump_to_kernel:
     
    48121        #
    49122        bx r0
    50 
    51 #bootloader stack
    52 .section ST
    53         .space 4096
    54 boot_stack:
    55 
    56 # place page_table to PT section
    57 .section PT
    58 
    59 # make place for PTL0 page table
    60 page_table:
    61         .skip PTL0_ENTRIES * PTL0_ENTRY_SIZE
  • boot/arch/arm32/src/putchar.c

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2007 Michal Kebrt
     3 * Copyright (c) 2009 Vineeth Pillai
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup generic
     30/** @addtogroup arm32boot
    3031 * @{
    3132 */
    3233/** @file
     34 * @brief bootloader output logic
    3335 */
    3436
    35 #ifndef BOOT_STRING_H_
    36 #define BOOT_STRING_H_
     37#include <typedefs.h>
     38#include <arch/main.h>
     39#include <putchar.h>
     40#include <str.h>
    3741
    38 #include <types.h>
    39 
    40 extern size_t strlen(const char *str);
    41 extern int strcmp(const char *src, const char *dst);
    42 extern int strncmp(const char *src, const char *dst, size_t len);
    43 extern void strncpy(char *dest, const char *src, size_t len);
    44 extern unative_t atoi(const char *text);
    45 extern void *memmove(void *dst, const void *src, size_t len);
    46 
    47 #endif
     42void putchar(const wchar_t ch)
     43{
     44        if (ch == '\n')
     45                *((volatile char *) VIDEORAM_ADDRESS) = '\r';
     46       
     47        if (ascii_check(ch))
     48                *((volatile char *) VIDEORAM_ADDRESS) = ch;
     49        else
     50                *((volatile char *) VIDEORAM_ADDRESS) = U_SPECIAL;
     51}
    4852
    4953/** @}
  • boot/arch/mips32/Makefile.inc

    rbb252ca r4872160  
    2727#
    2828
    29 include Makefile.common
     29BFD_ARCH = mips
     30BITS = 32
     31PAGE_SIZE = 16384
     32EXTRA_CFLAGS = -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3
    3033
    31 build: $(BASE)/image.boot
     34RD_SRVS += \
     35        $(USPACE_PATH)/srv/bd/gxe_bd/gxe_bd
    3236
    33 $(BASE)/image.boot: $(COMPONENTS) $(INIT_TASKS) $(RD_SRVS) $(RD_APPS) $(CFG)
    34         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
    35         cp arch/$(BARCH)/loader/image.boot $@
     37ifeq ($(MACHINE),lgxemul)
     38        BFD_NAME = elf32-tradlittlemips
     39        BFD_OUTPUT = ecoff-littlemips
     40        ENDIANESS = LE
     41endif
     42ifeq ($(MACHINE),bgxemul)
     43        BFD_NAME = elf32-tradbigmips
     44        BFD_OUTPUT = ecoff-bigmips
     45        ENDIANESS = BE
     46endif
     47ifeq ($(MACHINE),msim)
     48        BFD_NAME = elf32-tradlittlemips
     49        BFD_OUTPUT = binary
     50        ENDIANESS = LE
     51        EXTRA_GCC_CFLAGS = -mhard-float
     52endif
    3653
    37 clean:
    38         $(MAKE) -C arch/$(BARCH)/loader clean
    39         rm -f $(BASE)/image.boot
     54SOURCES = \
     55        arch/$(BARCH)/src/asm.S \
     56        arch/$(BARCH)/src/main.c \
     57        arch/$(BARCH)/src/putchar.c \
     58        $(COMPS_C) \
     59        genarch/src/division.c \
     60        genarch/src/multiplication.c \
     61        generic/src/printf_core.c \
     62        generic/src/vprintf.c \
     63        generic/src/printf.c \
     64        generic/src/str.c \
     65        generic/src/version.c \
     66        generic/src/inflate.c
  • boot/arch/mips32/include/arch.h

    rbb252ca r4872160  
    11/*
    22 * Copyright (c) 2006 Martin Decky
    3  * Copyright (c) 2006 Jakub Jermar
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 #ifndef BOOT_sparc64_ASM_H_
    31 #define BOOT_sparc64_ASM_H_
    32 
    33 #include "types.h"
    34 #include "main.h"
     29#ifndef BOOT_mips32_ARCH_H_
     30#define BOOT_mips32_ARCH_H_
    3531
    3632#define PAGE_WIDTH  14
    3733#define PAGE_SIZE   (1 << PAGE_WIDTH)
    3834
    39 #define BALLOC_MAX_SIZE  (128 * 1024)
     35#define CPUMAP_OFFSET    0x00001000
     36#define STACK_OFFSET     0x00002000
     37#define BOOTINFO_OFFSET  0x00003000
     38#define BOOT_OFFSET      0x00100000
     39#define LOADER_OFFSET    0x1fc00000
    4040
    41 extern void halt(void);
    42 extern void jump_to_kernel(void *entry, uint64_t cfg, bootinfo_t *bootinfo,
    43     unsigned int bootinfo_size, uint8_t subarchitecture) __attribute__((noreturn));
     41#define MSIM_VIDEORAM_ADDRESS  0xb0000000
     42#define MSIM_DORDER_ADDRESS    0xb0000004
     43
     44#ifndef __ASM__
     45        #define PA2KA(addr)    (((uintptr_t) (addr)) + 0x80000000)
     46        #define KSEG2PA(addr)  (((uintptr_t) (addr)) - 0xa0000000)
     47#else
     48        #define PA2KA(addr)    ((addr) + 0x80000000)
     49        #define KSEG2PA(addr)  ((addr) - 0xa0000000)
     50#endif
    4451
    4552#endif
  • boot/arch/mips32/include/asm.h

    rbb252ca r4872160  
    3030#define BOOT_mips32_ASM_H_
    3131
    32 #define PAGE_SIZE   16384
    33 #define PAGE_WIDTH  14
    34 
    35 void jump_to_kernel(void *entry, void *bootinfo) __attribute__((noreturn));
     32extern void jump_to_kernel(void *, void *) __attribute__((noreturn));
    3633
    3734#endif
  • boot/arch/mips32/include/main.h

    rbb252ca r4872160  
    2727 */
    2828
    29 #ifndef BOOT_ia64_MAIN_H_
    30 #define BOOT_ia64_MAIN_H_
     29#ifndef BOOT_mips32_MAIN_H_
     30#define BOOT_mips32_MAIN_H_
    3131
    32 #include <types.h>
    33 #include <../../../../kernel/arch/ia64/include/bootinfo.h>
    34 
    35 
    36 #define CONFIG_INIT_TASKS  32
    37 
    38 extern void start(void);
    3932extern void bootstrap(void);
    4033
  • boot/arch/mips32/include/regname.h

    rbb252ca r4872160  
    6363#define ra      31
    6464
    65 #define rindex          0
    66 #define rrandom         1
    67 #define entrylo0        2
    68 #define entrylo1        3
    69 #define context         4
    70 #define pagemask        5
    71 #define wired           6
    72 #define badvaddr        8
    73 #define count           9
    74 #define entryhi         10
    75 #define compare         11
    76 #define status          12
    77 #define cause           13
    78 #define epc             14
    79 #define rconfig         16
    80 #define lladdr          17
    81 #define watchlo         18
    82 #define watchhi         19
    83 #define xcontext        20
    84 #define rdebug          23
    85 #define depc            24
    86 #define eepc            30
     65#define rindex    0
     66#define rrandom   1
     67#define entrylo0  2
     68#define entrylo1  3
     69#define context   4
     70#define pagemask  5
     71#define wired     6
     72#define badvaddr  8
     73#define count     9
     74#define entryhi   10
     75#define compare   11
     76#define status    12
     77#define cause     13
     78#define epc       14
     79#define rconfig   16
     80#define lladdr    17
     81#define watchlo   18
     82#define watchhi   19
     83#define xcontext  20
     84#define rdebug    23
     85#define depc      24
     86#define eepc      30
    8787
    88 #endif /* _REGNAME_H_ */
     88#endif
  • boot/arch/ppc32/Makefile.inc

    rbb252ca r4872160  
    2727#
    2828
    29 include Makefile.common
     29BOOT_OUTPUT = image.boot
     30POST_OUTPUT = $(ROOT_PATH)/image.iso
     31POSTBUILD = Makefile.yaboot
    3032
    31 build: $(BASE)/image.iso
     33BFD_NAME = elf32-powerpc
     34BFD_OUTPUT = $(BFD_NAME)
     35BFD_ARCH = powerpc:common
    3236
    33 $(BASE)/image.iso: arch/$(BARCH)/loader/image.boot
    34         mkdir -p $(TMP)/boot
    35         mkdir -p $(TMP)/ppc
    36         cp arch/$(BARCH)/loader/image.boot $(TMP)/boot/image.boot
    37         cp arch/$(BARCH)/yaboot/ofboot.b $(TMP)/boot/ofboot.b
    38         cp arch/$(BARCH)/yaboot/bootinfo.txt $(TMP)/ppc/bootinfo.txt
    39         cp arch/$(BARCH)/yaboot/yaboot $(TMP)/boot/yaboot
    40         cp arch/$(BARCH)/yaboot/yaboot.conf $(TMP)/boot/yaboot.conf
    41         mkisofs -hfs -part -map arch/$(BARCH)/yaboot/maps -no-desktop -hfs-volid "HelenOS" -hfs-bless $(TMP)/boot -r -o $@ $(TMP)/
     37BITS = 32
     38ENDIANESS = BE
     39PAGE_SIZE = 4096
     40EXTRA_CFLAGS = -mcpu=powerpc -msoft-float -m32
    4241
    43 arch/$(BARCH)/loader/image.boot: $(COMPONENTS) $(INIT_TASKS) $(RD_SRVS) $(RD_APPS) $(CFG)
    44         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
     42RD_SRVS += \
     43        $(USPACE_PATH)/srv/hid/adb_mouse/adb_ms \
     44        $(USPACE_PATH)/srv/hw/bus/cuda_adb/cuda_adb
    4545
    46 clean: generic_clean
    47         $(MAKE) -C arch/$(BARCH)/loader clean
    48         rm -fr $(TMP)
    49         rm -f $(BASE)/image.iso
     46SOURCES = \
     47        arch/$(BARCH)/src/asm.S \
     48        arch/$(BARCH)/src/main.c \
     49        arch/$(BARCH)/src/ofw.c \
     50        $(COMPS_C) \
     51        genarch/src/ofw.c \
     52        genarch/src/ofw_tree.c \
     53        genarch/src/division.c \
     54        genarch/src/multiplication.c \
     55        generic/src/balloc.c \
     56        generic/src/printf_core.c \
     57        generic/src/vprintf.c \
     58        generic/src/printf.c \
     59        generic/src/str.c \
     60        generic/src/version.c \
     61        generic/src/inflate.c
  • boot/arch/ppc32/_link.ld.in

    rbb252ca r4872160  
    1 OUTPUT_FORMAT("elf32-powerpc")
    2 OUTPUT_ARCH(powerpc:common)
    31ENTRY(start)
    42
    53SECTIONS {
    6         .boot 0x01000000: AT (0) {
     4        . = 0x01000000;
     5        .text : {
    76                *(BOOTSTRAP);
    87                *(REALMODE);
    98                *(.text);
    10                
     9        }
     10        .data : {
     11                *(.data);       /* initialized data */
    1112                *(.rodata);
    1213                *(.rodata.*);
    13                 *(.data);       /* initialized data */
    1414                *(.sdata);
    15                 *(.sdata2);
     15                *(.reginfo);
    1616                *(.sbss);
     17                *(.scommon);
    1718                *(.bss);        /* uninitialized static variables */
    1819                *(COMMON);      /* global variables */
     
    2122       
    2223        /DISCARD/ : {
     24                *(.gnu.*);
     25                *(.mdebug*);
     26                *(.pdr);
    2327                *(.comment);
    24                 *(.note*);
     28                *(.note.*);
    2529        }
    2630}
  • boot/arch/ppc32/include/arch.h

    rbb252ca r4872160  
    11/*
    22 * Copyright (c) 2006 Martin Decky
    3  * Copyright (c) 2006 Jakub Jermar
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 #ifndef BOOT_ia64_ASM_H_
    31 #define BOOT_ia64_ASM_H_
     29#ifndef BOOT_ppc32_ARCH_H_
     30#define BOOT_ppc32_ARCH_H_
    3231
    33 #include "types.h"
    34 #include "main.h"
    35 
    36 #define PAGE_WIDTH  14
     32#define PAGE_WIDTH  12
    3733#define PAGE_SIZE   (1 << PAGE_WIDTH)
    3834
    39 #define BALLOC_MAX_SIZE  (128 * 1024)
     35#define BOOT_OFFSET  0x8000
    4036
    41 extern void halt(void);
    42 extern void jump_to_kernel(void *) __attribute__((noreturn));
     37#define LOADER_ADDRESS  0x01000000
    4338
     39#ifndef __ASM__
     40        #define PA2KA(addr)  (((uintptr_t) (addr)) + 0x80000000)
     41#else
     42        #define PA2KA(addr)  ((addr) + 0x80000000)
     43#endif
    4444
    4545#endif
  • boot/arch/ppc32/include/asm.h

    rbb252ca r4872160  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
    29 #include "msim.h"
    30 #include <printf.h>
    3128
    32 #define MSIM_VIDEORAM            0xB0000000
     29#ifndef BOOT_ppc32_ASM_H_
     30#define BOOT_ppc32_ASM_H_
    3331
    34 void write(const char *str, const int len)
    35 {
    36         int i;
    37        
    38         for (i = 0; i < len; i++)
    39                 *((char *) MSIM_VIDEORAM) = str[i];
    40 }
     32#include <typedefs.h>
     33#include <arch/main.h>
     34
     35extern void jump_to_kernel(void *, void *, size_t, void *)
     36    __attribute__((noreturn));
     37extern void real_mode();
     38
     39#endif
  • boot/arch/ppc32/include/regname.h

    rbb252ca r4872160  
    2727 */
    2828
    29 #ifndef __ppc32_REGNAME_H__
    30 #define __ppc32_REGNAME_H__
     29#ifndef BOOT_ppc32_REGNAME_H_
     30#define BOOT_ppc32_REGNAME_H_
    3131
    3232/* Condition Register Bit Fields */
  • boot/arch/ppc32/include/types.h

    rbb252ca r4872160  
    3030#define BOOT_ppc32_TYPES_H_
    3131
    32 #include <gentypes.h>
     32#define TASKMAP_MAX_RECORDS        32
     33#define BOOTINFO_TASK_NAME_BUFLEN  32
    3334
    34 typedef signed char int8_t;
    35 
    36 typedef unsigned char uint8_t;
    37 typedef unsigned short uint16_t;
    38 typedef unsigned int uint32_t;
    39 typedef unsigned long long uint64_t;
    40 
     35typedef uint32_t size_t;
    4136typedef uint32_t uintptr_t;
    4237typedef uint32_t unative_t;
     38typedef int32_t native_t;
     39
     40typedef struct {
     41        void *addr;
     42        size_t size;
     43        char name[BOOTINFO_TASK_NAME_BUFLEN];
     44} task_t;
     45
     46typedef struct {
     47        size_t cnt;
     48        task_t tasks[TASKMAP_MAX_RECORDS];
     49} taskmap_t;
    4350
    4451#endif
  • boot/arch/ppc32/src/asm.S

    rbb252ca r4872160  
    2727#
    2828
    29 #include "asm.h"
    30 #include "regname.h"
    31 #include "ofwarch.h"
     29#include <arch/arch.h>
     30#include <arch/regname.h>
    3231
    3332.macro SMC_COHERENCY addr
     
    5958.endm
    6059
    61 .text
    62 
     60.global start
    6361.global halt
    6462.global memcpy
    6563.global jump_to_kernel
    66 .global balloc_base
     64.global real_mode
     65
     66.section BOOTSTRAP, "ax"
     67
     68start:
     69        lis r4, ofw_cif@ha
     70        addi r4, r4, ofw_cif@l
     71        stw r5, 0(r4)
     72       
     73        bl ofw_init
     74        b bootstrap
     75
     76.text
    6777
    6878halt:
     
    127137jump_to_kernel:
    128138       
    129         # r3 = bootinfo (pa)
    130         # r4 = bootinfo_size
    131         # r5 = trans (pa)
    132         # r6 = bytes to copy
    133         # r7 = real_mode (pa)
     139        # arguments:
     140        # r3 = bootinfo (physical address)
     141        # r4 = translate table (physical address)
     142        # r5 = pages to translate
     143        # r6 = real mode meeting point (physical address)
    134144       
    135145        # disable interrupts
     
    139149        mtmsr r31
    140150       
    141         # set real_mode meeting point address
    142        
    143         mtspr srr0, r7
    144        
    145         # jumps to real_mode
     151        # set real mode meeting point physical address
     152       
     153        mtspr srr0, r6
     154       
     155        # jump to real_mode
    146156       
    147157        mfmsr r31
     
    155165        rfi
    156166
     167.section REALMODE, "ax"
     168
    157169.align PAGE_WIDTH
    158 balloc_base:
    159         .fill BALLOC_MAX_SIZE
    160 
    161 .section REALMODE, "ax"
    162 
    163 .align PAGE_WIDTH
    164 .global real_mode
    165170real_mode:
    166171       
    167         # copy kernel to proper location
    168         #
    169         # r3 = bootinfo (pa)
    170         # r4 = bootinfo_size
    171         # r5 = trans (pa)
    172         # r6 = bytes to copy
     172        # arguments:
     173        # r3 = bootinfo (physical address)
     174        # r4 = translate table (physical address)
     175        # r5 = pages to translate
     176       
     177        # move the images of components to the proper
     178        # location using the translate table
    173179       
    174180        li r31, PAGE_SIZE >> 2
     
    177183        page_copy:
    178184               
    179                 cmpwi r6, 0
     185                cmpwi r5, 0
    180186                beq copy_end
    181187               
    182                 # copy page
    183                
    184188                mtctr r31
    185                 lwz r29, 0(r5)
     189                lwz r29, 0(r4)
    186190               
    187191                copy_loop:
     
    194198                        addi r29, r29, 4
    195199                        addi r30, r30, 4
    196                         subi r6, r6, 4
    197                        
    198                         cmpwi r6, 0
    199                         beq copy_end
    200200                       
    201201                        bdnz copy_loop
    202                        
    203                 addi r5, r5, 4
     202               
     203                addi r4, r4, 4
     204                subi r5, r5, 1
    204205                b page_copy
    205206       
     
    266267        # on top of memory, size 64 KB
    267268       
    268         lwz r31, 0(r3)                # r31 = memory size
     269        lwz r31, 4(r3)                # r31 = memory size
    269270       
    270271        lis r30, 65536@h
     
    303304        # create BAT identity mapping
    304305       
    305         lwz r31, 0(r3)                # r31 = memory size
     306        lwz r31, 4(r3)                # r31 = memory size
    306307       
    307308        lis r29, 0x0002
     
    354355        #
    355356        # pc = PA2KA(BOOT_OFFSET)
    356         # r3 = bootinfo (pa)
     357        # r3 = bootinfo (physical address)
    357358        # sprg0 = BOOT_OFFSET
    358359        # sprg3 = physical memory size
    359         # sp = 0 (pa)
     360        # sp = 0 (enforces the usage of sprg0 as exception stack)
    360361       
    361362        lis r31, PA2KA(BOOT_OFFSET)@ha
     
    367368        mtsprg0 r31
    368369       
    369         lwz r31, 0(r3)
     370        # bootinfo starts with a 64 bit integer containing
     371        # the physical memory size, get the lower 4 bytes
     372       
     373        lwz r31, 4(r3)
    370374        mtsprg3 r31
    371375       
     
    379383        isync
    380384        rfi
    381 
    382 .align PAGE_WIDTH
    383 .global trans
    384 trans:
    385         .rept TRANS_SIZE
    386         .int 0
    387         .endr
  • boot/arch/ppc32/src/ofw.c

    rbb252ca r4872160  
    2727 */
    2828
    29 #include <ofwarch.h>
    30 #include <ofw.h>
    31 #include <printf.h>
     29#include <genarch/ofw.h>
     30#include <typedefs.h>
     31#include <putchar.h>
     32#include <str.h>
    3233
    3334typedef int (*ofw_entry_t)(ofw_args_t *args);
    3435
    35 int ofw(ofw_args_t *args)
     36ofw_arg_t ofw(ofw_args_t *args)
    3637{
    3738        return ((ofw_entry_t) ofw_cif)(args);
    3839}
    3940
    40 void write(const char *str, const int len)
     41void putchar(const wchar_t ch)
    4142{
    42         int i;
     43        if (ch == '\n')
     44                ofw_putchar('\r');
    4345       
    44         for (i = 0; i < len; i++) {
    45                 if (str[i] == '\n')
    46                         ofw_write("\r", 1);
    47                 ofw_write(&str[i], 1);
    48         }
     46        if (ascii_check(ch))
     47                ofw_putchar(ch);
     48        else
     49                ofw_putchar(U_SPECIAL);
    4950}
    50 
    51 int ofw_translate_failed(ofw_arg_t flag)
    52 {
    53         /* PearPC returns buggy flag */
    54         return 0;
    55 }
  • boot/arch/sparc64/Makefile.inc

    rbb252ca r4872160  
    2727#
    2828
    29 include Makefile.common
     29BOOT_OUTPUT = image.boot
     30POST_OUTPUT = $(ROOT_PATH)/image.iso
     31POSTBUILD = Makefile.silo
    3032
    31 ifeq ($(CONFIG_AOUT_ISOFS_B),y)
    32         SILO_PACKAGE = silo.tar.gz
    33 else
    34         SILO_PACKAGE = silo.patched.tar.gz
    35 endif
     33BFD_NAME = elf64-sparc
     34BFD_OUTPUT = $(BFD_NAME)
     35BFD_ARCH = sparc
    3636
    37 build: $(BASE)/image.iso
     37BITS = 64
     38ENDIANESS = BE
     39PAGE_SIZE = 16384
     40EXTRA_CFLAGS = -mcpu=ultrasparc -m64 -mno-fpu
    3841
    39 $(BASE)/image.iso: arch/$(BARCH)/loader/image.boot
    40         mkdir -p $(TMP)/boot
    41         mkdir -p $(TMP)/HelenOS
    42         cat arch/$(BARCH)/silo/$(SILO_PACKAGE) | (cd $(TMP)/boot; tar xvfz -)
    43         cp arch/$(BARCH)/silo/README arch/$(BARCH)/silo/COPYING $(TMP)/boot
    44 ifeq ($(CONFIG_RD_EXTERNAL),y)
    45         cp arch/$(BARCH)/silo/silo.conf $(TMP)/boot/silo.conf
    46 else
    47         cat arch/$(BARCH)/silo/silo.conf | grep -v initrd > $(TMP)/boot/silo.conf
    48 endif
    49         cp arch/$(BARCH)/loader/image.boot $(TMP)/HelenOS/image.boot
    50         gzip -f $(TMP)/HelenOS/image.boot
    51 ifeq ($(CONFIG_RD_EXTERNAL),y)
    52         cp arch/$(BARCH)/loader/initrd.img $(TMP)/HelenOS/initrd.img
    53 endif
    54         mkisofs -f -G $(TMP)/boot/isofs.b -B ... -r -o $@ $(TMP)/
     42RD_SRVS += \
     43        $(USPACE_PATH)/srv/hw/cir/fhc/fhc \
     44        $(USPACE_PATH)/srv/hw/cir/obio/obio
    5545
    56 arch/$(BARCH)/loader/image.boot: $(COMPONENTS) $(INIT_TASKS) $(RD_SRVS) $(RD_APPS) $(CFG)
    57         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
    58 
    59 clean: generic_clean
    60         $(MAKE) -C arch/$(BARCH)/loader clean
    61         rm -fr $(TMP)
    62         rm -f $(BASE)/image.iso
     46SOURCES = \
     47        arch/$(BARCH)/src/asm.S \
     48        arch/$(BARCH)/src/main.c \
     49        arch/$(BARCH)/src/ofw.c \
     50        $(COMPS_C) \
     51        genarch/src/ofw.c \
     52        genarch/src/ofw_tree.c \
     53        generic/src/balloc.c \
     54        generic/src/printf_core.c \
     55        generic/src/vprintf.c \
     56        generic/src/printf.c \
     57        generic/src/str.c \
     58        generic/src/version.c \
     59        generic/src/inflate.c
  • boot/arch/sparc64/_link.ld.in

    rbb252ca r4872160  
    22
    33SECTIONS {
    4         .boot 0xbfc00000: AT (0) {
     4        . = 0x4000;
     5        .boot : {
    56                *(BOOTSTRAP);
    67                *(.text);
    78               
     9                *(.data);       /* initialized data */
    810                *(.rodata);
    911                *(.rodata.*);
    10                 *(.data);       /* initialized data */
    1112                *(.sdata);
    12                 *(.sdata2);
     13                *(.reginfo);
    1314                *(.sbss);
    14                 *(.scommon);
    1515                *(.bss);        /* uninitialized static variables */
    1616                *(COMMON);      /* global variables */
    17                 *(.reginfo);
    1817[[COMPONENTS]]
    1918        }
     19       
     20        /DISCARD/ : {
     21                *(.gnu.*);
     22                *(.mdebug*);
     23                *(.pdr);
     24                *(.comment);
     25                *(.note.*);
     26        }
    2027}
  • boot/arch/sparc64/include/asm.h

    rbb252ca r4872160  
    11/*
     2 * Copyright (c) 2006 Martin Decky
    23 * Copyright (c) 2006 Jakub Jermar
    34 * All rights reserved.
     
    2728 */
    2829
    29 #ifndef BOOT_sparc64_REGISTER_H_
    30 #define BOOT_sparc64_REGISTER_H_
     30#ifndef BOOT_sparc64_ASM_H_
     31#define BOOT_sparc64_ASM_H_
    3132
    32 #define PSTATE_IE_BIT    2
    33 #define PSTATE_PRIV_BIT  4
    34 #define PSTATE_AM_BIT    8
     33#include <typedefs.h>
    3534
    36 #define ASI_ICBUS_CONFIG        0x4a
    37 #define ICBUS_CONFIG_MID_SHIFT  17
     35extern void jump_to_kernel(void *entry, bootinfo_t *bootinfo,
     36    uintptr_t physmem_start, uint8_t subarch) __attribute__((noreturn));
    3837
    3938#endif
  • boot/arch/sparc64/include/main.h

    rbb252ca r4872160  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2005 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef BOOT_mips32_TYPES_H_
    30 #define BOOT_mips32_TYPES_H_
     29#ifndef BOOT_sparc64_MAIN_H_
     30#define BOOT_sparc64_MAIN_H_
    3131
    32 #include <gentypes.h>
     32#include <typedefs.h>
     33#include <balloc.h>
     34#include <genarch/ofw_tree.h>
    3335
    34 typedef signed char int8_t;
     36typedef struct {
     37        uintptr_t physmem_start;
     38        taskmap_t taskmap;
     39        memmap_t memmap;
     40        ballocs_t ballocs;
     41        ofw_tree_node_t *ofw_root;
     42} bootinfo_t;
    3543
    36 typedef unsigned char uint8_t;
    37 typedef unsigned short uint16_t;
    38 typedef unsigned int uint32_t;
    39 typedef unsigned long long uint64_t;
    40 
    41 typedef uint32_t uintptr_t;
    42 typedef uint32_t unative_t;
     44extern void bootstrap(void);
    4345
    4446#endif
  • boot/arch/sparc64/include/ofw.h

    rbb252ca r4872160  
    2727 */
    2828
    29 #ifndef BOOT_sparc64_OFWARCH_H_
    30 #define BOOT_sparc64_OFWARCH_H_
     29#ifndef BOOT_sparc64_OFW_H_
     30#define BOOT_sparc64_OFW_H_
    3131
    32 #include "main.h"
    33 #include "types.h"
     32#include <typedefs.h>
    3433
    3534#define OFW_ADDRESS_CELLS  2
    3635#define OFW_SIZE_CELLS     2
    3736
    38 extern int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start);
    39 extern int ofw_get_physmem_start(uintptr_t *start);
     37extern uintptr_t ofw_get_physmem_start(void);
     38extern void ofw_cpu(uint16_t, uintptr_t);
    4039
    4140#endif
  • boot/arch/sparc64/include/types.h

    rbb252ca r4872160  
    3030#define BOOT_sparc64_TYPES_H_
    3131
    32 #include <gentypes.h>
     32#define TASKMAP_MAX_RECORDS        32
     33#define BOOTINFO_TASK_NAME_BUFLEN  32
    3334
    34 typedef signed char int8_t;
    35 
    36 typedef unsigned char uint8_t;
    37 typedef unsigned short uint16_t;
    38 typedef unsigned int uint32_t;
    39 typedef unsigned long uint64_t;
    40 
     35typedef uint64_t size_t;
    4136typedef uint64_t uintptr_t;
    4237typedef uint64_t unative_t;
     38typedef int64_t native_t;
     39
     40typedef struct {
     41        void *addr;
     42        size_t size;
     43        char name[BOOTINFO_TASK_NAME_BUFLEN];
     44} task_t;
     45
     46typedef struct {
     47        size_t cnt;
     48        task_t tasks[TASKMAP_MAX_RECORDS];
     49} taskmap_t;
    4350
    4451#endif
  • boot/arch/sparc64/src/asm.S

    rbb252ca r4872160  
    11#
    22# Copyright (c) 2006 Martin Decky
    3 # Copyright (c) 2006 Jakub Jermar 
     3# Copyright (c) 2006 Jakub Jermar
    44# All rights reserved.
    55#
     
    2828#
    2929
    30 #include <stack.h>
    31 #include <register.h>
     30#include <arch/arch.h>
     31
     32#define ICACHE_SIZE       8192
     33#define ICACHE_LINE_SIZE  32
     34#define ICACHE_SET_BIT    (1 << 13)
     35#define ASI_ICACHE_TAG    0x67
    3236
    3337.register %g2, #scratch
    3438.register %g3, #scratch
    35 
    36 .text
    37 
     39.register %g6, #scratch
     40.register %g7, #scratch
     41
     42.global start
    3843.global halt
    3944.global memcpy
    4045.global jump_to_kernel
    4146
     47.section BOOTSTRAP, "ax"
     48
     49start:
     50        ba %xcc, 1f
     51        nop
     52
     53/*
     54 * This header forces SILO to load the image at 0x4000.
     55 * More precisely, SILO will think this is an old version of Linux.
     56 */
     57.ascii "HdrS"
     58.word 0
     59.half 0
     60.half 0
     61.half 0
     62.half 0
     63.word 0
     64.word 0
     65
     66.align 8
     671:
     68        ! Disable interrupts and disable address masking.
     69       
     70        wrpr %g0, PSTATE_PRIV_BIT, %pstate
     71       
     72        wrpr %g0, NWINDOWS - 2, %cansave   ! Set maximum saveable windows
     73        wrpr %g0, 0, %canrestore           ! Get rid of windows we will never need again
     74        wrpr %g0, 0, %otherwin             ! Make sure the window state is consistent
     75        wrpr %g0, NWINDOWS - 1, %cleanwin  ! Prevent needless clean_window traps for kernel
     76       
     77        set initial_stack, %sp
     78        add %sp, -STACK_BIAS, %sp
     79       
     80        set ofw_cif, %l0
     81       
     82        ! Initialize OpenFirmware
     83       
     84        call ofw_init
     85        stx %o4, [%l0]
     86       
     87        ba %xcc, bootstrap
     88        nop
     89
     90.align STACK_ALIGNMENT
     91        .space STACK_SIZE
     92initial_stack:
     93        .space STACK_WINDOW_SAVE_AREA_SIZE
     94
     95.text
     96
    4297halt:
    4398        ba %xcc, halt
     
    45100
    46101memcpy:
    47         mov %o0, %o3      ! save dst
     102        ! Save dst
     103       
     104        mov %o0, %o3
    48105        add %o1, 7, %g1
    49106        and %g1, -8, %g1
     
    66123       
    67124        2:
    68                 jmp %o7 + 8   ! exit point
     125                ! Exit point
     126               
     127                jmp %o7 + 8
    69128                mov %o3, %o0
    70129       
     
    104163                mov %g2, %g3
    105164       
    106         jmp %o7 + 8   ! exit point
     165        ! Exit point
     166       
     167        jmp %o7 + 8
    107168        mov %o3, %o0
    108169
    109170jump_to_kernel:
    110171        /*
    111          * We have copied code and now we need to guarantee cache coherence.
     172         * Guarantee cache coherence:
    112173         * 1. Make sure that the code we have moved has drained to main memory.
    113174         * 2. Invalidate I-cache.
     
    115176         */
    116177       
    117 #if defined (SUN4U)
    118178        /*
    119179         * US3 processors have a write-invalidate cache, so explicitly
    120180         * invalidating it is not required. Whether to invalidate I-cache
    121          * or not is decided according to the value of the 5th argument
    122          * (subarchitecture).
     181         * or not is decided according to the value of the 3rd argument
     182         * (subarch).
    123183         */
    124         cmp %i4, 3
     184        cmp %i2, SUBARCH_US3
    125185        be %xcc, 1f
    126186        nop
     
    129189                call icache_flush
    130190                nop
    131 #endif 
     191       
    132192        1:
    133193                membar #StoreStore
     
    138198        flush %i7
    139199       
     200        ! Jump to kernel
    140201        mov %o0, %l1
    141202        mov %o1, %o0
    142         mov %o2, %o1
    143         mov %o3, %o2
    144         jmp %l1       ! jump to kernel
    145         nop
    146 
    147 #define ICACHE_SIZE       8192
    148 #define ICACHE_LINE_SIZE  32
    149 #define ICACHE_SET_BIT    (1 << 13)
    150 #define ASI_ICACHE_TAG    0x67
     203        mov %o3, %o1
     204       
     205        jmp %l1
     206        nop
    151207
    152208# Flush I-cache
     
    163219        membar #Sync
    164220        retl
     221       
    165222        ! SF Erratum #51
     223       
    166224        nop
    167225
     
    172230        ldx [%l0], %l0
    173231       
    174         rdpr  %pstate, %l1
    175         and  %l1, ~PSTATE_AM_BIT, %l2
    176         wrpr  %l2, 0, %pstate
     232        rdpr %pstate, %l1
     233        and %l1, ~PSTATE_AM_BIT, %l2
     234        wrpr %l2, 0, %pstate
    177235       
    178236        jmpl %l0, %o7
  • boot/arch/sparc64/src/ofw.c

    rbb252ca r4872160  
    3333 */
    3434
    35 #include <ofwarch.h>
    36 #include <ofw.h>
     35#include <arch/arch.h>
     36#include <arch/ofw.h>
     37#include <genarch/ofw.h>
     38#include <typedefs.h>
    3739#include <printf.h>
    38 #include <string.h>
    39 #include <register.h>
    40 #include "main.h"
    41 #include "asm.h"
     40#include <halt.h>
     41#include <putchar.h>
     42#include <str.h>
    4243
    43 void write(const char *str, const int len)
     44void putchar(const wchar_t ch)
    4445{
    45         int i;
     46        if (ch == '\n')
     47                ofw_putchar('\r');
    4648       
    47         for (i = 0; i < len; i++) {
    48                 if (str[i] == '\n')
    49                         ofw_write("\r", 1);
    50                 ofw_write(&str[i], 1);
    51         }
     49        if (ascii_check(ch))
     50                ofw_putchar(ch);
     51        else
     52                ofw_putchar(U_SPECIAL);
    5253}
    5354
    54 int ofw_translate_failed(ofw_arg_t flag)
    55 {
    56         return flag != -1;
    57 }
    58 
    59 /**
    60  * Starts all CPUs represented by following siblings of the given node,
    61  * except for the current CPU.
     55/** Start all CPUs represented by following siblings of the given node.
     56 *
     57 * Except for the current CPU.
    6258 *
    6359 * @param child         The first child of the OFW tree node whose children
     
    7167 *
    7268 */
    73 static int wake_cpus_in_node(phandle child, uint64_t current_mid,
     69static size_t wake_cpus_in_node(phandle child, uint64_t current_mid,
    7470    uintptr_t physmem_start)
    7571{
    76         int cpus;
     72        size_t cpus;
    7773       
    78         for (cpus = 0; (child != 0) && (child != -1);
     74        for (cpus = 0; (child != 0) && (child != (phandle) -1);
    7975            child = ofw_get_peer_node(child), cpus++) {
    8076                char type_name[OFW_TREE_PROPERTY_MAX_VALUELEN];
     
    8379                    OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) {
    8480                        type_name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0;
    85                         if (strcmp(type_name, "cpu") == 0) {
     81                       
     82                        if (str_cmp(type_name, "cpu") == 0) {
    8683                                uint32_t mid;
    8784                               
     
    10097                                         */
    10198                                        (void) ofw_call("SUNW,start-cpu", 3, 1,
    102                                             NULL, child, KERNEL_VIRTUAL_ADDRESS,
     99                                            NULL, child, KERNEL_ADDRESS,
    103100                                            physmem_start | AP_PROCESSOR);
    104101                                }
     
    110107}
    111108
    112 /**
    113  * Finds out the current CPU's MID and wakes up all AP processors.
     109/** Find out the current CPU's MID and wake up all AP processors.
     110 *
    114111 */
    115 int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start)
     112void ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start)
    116113{
    117114        /* Get the current CPU MID */
     
    119116       
    120117        asm volatile (
    121                 "ldxa [%1] %2, %0\n"
    122                 : "=r" (current_mid)
    123                 : "r" (0), "i" (ASI_ICBUS_CONFIG)
     118                "ldxa [%[zero]] %[asi], %[current_mid]\n"
     119                : [current_mid] "=r" (current_mid)
     120                : [zero] "r" (0),
     121                  [asi] "i" (ASI_ICBUS_CONFIG)
    124122        );
    125123       
     
    130128       
    131129        phandle cpus_parent = ofw_find_device("/ssm@0,0");
    132         if ((cpus_parent == 0) || (cpus_parent == -1))
     130        if ((cpus_parent == 0) || (cpus_parent == (phandle) -1))
    133131                cpus_parent = ofw_find_device("/");
    134132       
    135133        phandle node = ofw_get_child_node(cpus_parent);
    136         int cpus = wake_cpus_in_node(node, current_mid, physmem_start);
    137         while ((node != 0) && (node != -1)) {
     134        size_t cpus = wake_cpus_in_node(node, current_mid, physmem_start);
     135       
     136        while ((node != 0) && (node != (phandle) -1)) {
    138137                char name[OFW_TREE_PROPERTY_MAX_VALUELEN];
    139138               
     
    141140                    OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) {
    142141                        name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0;
    143                         if (strcmp(name, "cmp") == 0) {
     142                       
     143                        if (str_cmp(name, "cmp") == 0) {
    144144                                phandle subnode = ofw_get_child_node(node);
    145145                                cpus += wake_cpus_in_node(subnode,
    146                                         current_mid, physmem_start);
     146                                    current_mid, physmem_start);
    147147                        }
    148148                }
     149               
    149150                node = ofw_get_peer_node(node);
    150151        }
    151152       
    152         return cpus;
     153        if (cpus == 0)
     154                printf("Warning: Unable to get CPU properties.\n");
    153155}
    154156
    155157/** Get physical memory starting address.
    156158 *
    157  * @param start Pointer to variable where the physical memory starting
    158  *              address will be stored.
    159  *
    160  * @return Non-zero on succes, zero on failure.
     159 * @return Physical memory starting address.
    161160 *
    162161 */
    163 int ofw_get_physmem_start(uintptr_t *start)
     162uintptr_t ofw_get_physmem_start(void)
    164163{
    165164        uint32_t memreg[4];
    166         if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0)
    167                 return 0;
     165        if ((ofw_ret_t) ofw_get_property(ofw_memory, "reg", &memreg,
     166            sizeof(memreg)) <= 0) {
     167                printf("Error: Unable to get physical memory starting address, halting.\n");
     168                halt();
     169        }
    168170       
    169         *start = (((uint64_t) memreg[0]) << 32) | memreg[1];
    170         return 1;
     171        return ((((uintptr_t) memreg[0]) << 32) | memreg[1]);
    171172}
Note: See TracChangeset for help on using the changeset viewer.