Changeset 46c20c8 in mainline for boot/arch


Ignore:
Timestamp:
2010-11-26T20:08:10Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
45df59a
Parents:
fb150d78 (diff), ffdd2b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
boot/arch
Files:
18 added
136 deleted
6 edited
38 moved

Legend:

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

    rfb150d78 r46c20c8  
    2727#
    2828
    29 include Makefile.common
     29PAGE_SIZE = 4096
    3030
    31 RD_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
     31RD_SRVS_ESSENTIAL += \
     32        $(USPACE_PATH)/srv/hw/char/i8042/i8042
    3633
    37 MODULES := $(notdir $(COMPONENTS))
     34RD_SRVS_NON_ESSENTIAL += \
     35        $(USPACE_PATH)/srv/bd/ata_bd/ata_bd \
     36        $(USPACE_PATH)/srv/hid/char_mouse/char_ms
    3837
    39 build: $(BASE)/image.iso
     38RD_DRVS += \
     39        rootia32 \
     40        pciintel \
     41        isa \
     42        ns8250
     43       
     44RD_DRV_CFG += \
     45        isa/isa.dev
    4046
    41 $(BASE)/image.iso: arch/$(BARCH)/grub/stage2_eltorito $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_SRVS) $(RD_APPS)
    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         cp $(KERNELDIR)/kernel.bin $(TMP)/boot/
    59         for task in $(INIT_TASKS) ; do \
    60                 cp $$task $(TMP)/boot/ ; \
    61         done
    62         for file in $(RD_SRVS) ; do \
    63                 cp $$file $(USPACEDIR)/dist/srv/ ; \
    64         done
    65         for file in $(RD_APPS) ; do \
    66                 cp $$file $(USPACEDIR)/dist/app/ ; \
    67         done
    68        
    69 ifeq ($(RDFMT),tmpfs)
    70         $(BASE)/tools/mktmpfs.py $(USPACEDIR)/dist/ $(TMP)/boot/$(INITRD).fs
    71 endif
    72 ifeq ($(RDFMT),fat)
    73         $(BASE)/tools/mkfat.py $(USPACEDIR)/dist/ $(TMP)/boot/$(INITRD).fs
    74 endif
    75         $(BASE)/tools/mkhord.py 4096 $(TMP)/boot/$(INITRD).fs $(TMP)/boot/$(INITRD).img
    76         rm $(TMP)/boot/$(INITRD).fs
    77         mkisofs -J -r -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $@ $(TMP)/
    78 
    79 clean:
    80         for file in $(RD_SRVS) ; do \
    81                 rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
    82         done
    83         for file in $(RD_APPS) ; do \
    84                 rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    85         done
    86         rm -fr $(TMP)
    87         rm -f $(BASE)/image.iso
     47BOOT_OUTPUT = $(ROOT_PATH)/image.iso
     48PREBUILD = $(INITRD).img
     49BUILD = Makefile.grub
  • boot/arch/arm32/Makefile.inc

    rfb150d78 r46c20c8  
    2727#
    2828
    29 build: $(BASE)/image.boot
     29ifeq ($(MACHINE), gta02)
     30        BOOT_OUTPUT = image.boot
     31        POST_OUTPUT = $(ROOT_PATH)/uImage.bin
     32        POSTBUILD = Makefile.uboot
     33endif
    3034
    31 $(BASE)/image.boot:
    32         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
    33         cp arch/$(BARCH)/loader/image.boot $@
     35BFD_NAME = elf32-littlearm
     36BFD_OUTPUT = $(BFD_NAME)
     37BFD_ARCH = arm
    3438
    35 clean:
    36         $(MAKE) -C arch/$(BARCH)/loader clean
    37         rm -f $(BASE)/image.boot
     39BITS = 32
     40ENDIANESS = LE
     41PAGE_SIZE = 4096
     42
     43RD_SRVS_ESSENTIAL += \
     44        $(USPACE_PATH)/srv/hid/s3c24xx_ts/s3c24ts \
     45        $(USPACE_PATH)/srv/hw/char/s3c24xx_uart/s3c24ser
     46
     47RD_SRVS_NON_ESSENTIAL += \
     48        $(USPACE_PATH)/srv/bd/gxe_bd/gxe_bd
     49
     50SOURCES = \
     51        arch/$(BARCH)/src/asm.S \
     52        arch/$(BARCH)/src/main.c \
     53        arch/$(BARCH)/src/mm.c \
     54        arch/$(BARCH)/src/putchar.c \
     55        $(COMPS_C) \
     56        genarch/src/division.c \
     57        generic/src/memstr.c \
     58        generic/src/printf_core.c \
     59        generic/src/vprintf.c \
     60        generic/src/printf.c \
     61        generic/src/str.c \
     62        generic/src/version.c \
     63        generic/src/inflate.c
  • boot/arch/arm32/include/asm.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    11/*
    22 * Copyright (c) 2007 Michal Kebrt
    3  * Copyright (c) 2009 Vineeth Pillai
     3 * Copyright (c) 2010 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    2828 */
    2929
    30 
    3130/** @addtogroup arm32boot
    3231 * @{
    3332 */
    3433/** @file
    35  *  @brief bootloader output logic
    36  */
     34 * @brief Boot related declarations.
     35 */
     36
     37#ifndef BOOT_arm32_MAIN_H
     38#define BOOT_arm32_MAIN_H
     39
     40/** Address where characters to be printed are expected. */
     41
     42/** GTA02 serial console UART register addresses.
     43 *
     44 * This is UART channel 2 of the S3C24xx CPU
     45 */
     46#define GTA02_SCONS_UTRSTAT     0x50008010
     47#define GTA02_SCONS_UTXH        0x50008020
     48
     49/* Bits in UTXH register */
     50#define S3C24XX_UTXH_TX_EMPTY   0x00000004
    3751
    3852
    39 #include <printf.h>
     53/** GXemul testarm serial console output register */
     54#define TESTARM_SCONS_ADDR      0x10000000
    4055
     56/** IntegratorCP serial console output register */
     57#define ICP_SCONS_ADDR          0x16000000
    4158
    42 /** Address where characters to be printed are expected. */
    43 #ifdef MACHINE_testarm
    44         #define PUTC_ADDRESS  0x10000000
     59extern void bootstrap(void);
     60
    4561#endif
    46 
    47 #ifdef MACHINE_integratorcp
    48         #define PUTC_ADDRESS  0x16000000
    49 #endif
    50 
    51 
    52 
    53 /** Prints a character to the console.
    54  *
    55  * @param ch Character to be printed.
    56  */
    57 static void putc(char ch)
    58 {
    59         if (ch == '\n')
    60                 *((volatile char *) PUTC_ADDRESS) = '\r';
    61         *((volatile char *) PUTC_ADDRESS) = ch;
    62 }
    63 
    64 
    65 /** Prints a string to the console.
    66  *
    67  * @param str String to be printed.
    68  * @param len Number of characters to be printed.
    69  */
    70 void write(const char *str, const int len)
    71 {
    72         int i;
    73         for (i = 0; i < len; ++i) {
    74                 putc(str[i]);
    75         }
    76 }
    7762
    7863/** @}
    7964 */
    80 
  • boot/arch/arm32/include/types.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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
    3537.global jump_to_kernel
    36 .global page_table
    37 .global boot_stack
    3838
    3939start:
    4040        ldr sp, =boot_stack
    4141        b bootstrap
     42
     43.section BOOTPT
     44boot_pt:
     45        .space PTL0_ENTRIES * PTL0_ENTRY_SIZE
     46
     47.section BOOTSTACK
     48        .space 4096
     49boot_stack:
     50
     51.text
     52
     53halt:
     54        b halt
    4255
    4356jump_to_kernel:
     
    4861        #
    4962        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/ia64/Makefile.inc

    rfb150d78 r46c20c8  
    2727#
    2828
    29 build: $(BASE)/image.boot
     29BFD_NAME = elf64-ia64-little
     30BFD_OUTPUT = $(BFD_NAME)
     31BFD_ARCH = ia64
    3032
    31 $(BASE)/image.boot:
    32         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
    33         cp arch/$(BARCH)/loader/image.boot $@
     33BITS = 64
     34ENDIANESS = LE
     35PAGE_SIZE = 16384
     36EXTRA_CFLAGS = -fno-unwind-tables -mfixed-range=f32-f127 -mno-pic
    3437
    35 clean:
    36         $(MAKE) -C arch/$(BARCH)/loader clean
    37         rm -f $(BASE)/image.boot $(BASE)/hello.efi $(BASE)/image.bin
     38RD_SRVS_NON_ESSENTIAL +=
     39
     40RD_SRVS_ESSENTIAL += \
     41        $(USPACE_PATH)/srv/hw/char/i8042/i8042
     42
     43SOURCES = \
     44        arch/$(BARCH)/src/boot.S \
     45        arch/$(BARCH)/src/asm.S \
     46        arch/$(BARCH)/src/main.c \
     47        arch/$(BARCH)/src/putchar.c \
     48        $(COMPS_C) \
     49        genarch/src/division.c \
     50        generic/src/balloc.c \
     51        generic/src/memstr.c \
     52        generic/src/printf_core.c \
     53        generic/src/vprintf.c \
     54        generic/src/printf.c \
     55        generic/src/str.c \
     56        generic/src/version.c \
     57        generic/src/inflate.c
     58
     59ifeq ($(MACHINE),ski)
     60SOURCES += \
     61        arch/$(BARCH)/src/ski.c
     62endif
  • boot/arch/ia64/_link.ld.in

    rfb150d78 r46c20c8  
    55        .boot 0x4400000: AT (0x4400000) {
    66                *(BOOTSTRAP);
    7 [[COMPONENTS]]         
    8                 . = ALIGN (16384);
    97                *(.text);
     8                *(.sdata);
     9                *(.sdata2);
     10                *(.sbss);
    1011                *(.rodata);
    1112                *(.rodata.*);
    1213                *(.data);               /* initialized data */
    1314                _got = . ;
    14                 *(.got .got.*);               
     15                *(.got .got.*);
    1516                *(.bss);                /* uninitialized static variables */
    1617                *(COMMON);
     18[[COMPONENTS]]
    1719        }
    1820
    19         .sboot : {
    20                 *(.sdata);
    21                 *(.sdata2);
    22                 *(.sbss);
    23         }
    24        
    2521        /DISCARD/ : {
    2622                *(.comment);
  • boot/arch/ia64/include/arch.h

    rfb150d78 r46c20c8  
    11/*
     2 * Copyright (c) 2006 Martin Decky
    23 * Copyright (c) 2006 Jakub Jermar
    34 * All rights reserved.
     
    2728 */
    2829
    29 #ifndef BOOT_sparc64_STACK_H_
    30 #define BOOT_sparc64_STACK_H_
     30#ifndef BOOT_ia64_ARCH_H_
     31#define BOOT_ia64_ARCH_H_
    3132
     33#define PAGE_WIDTH  14
     34#define PAGE_SIZE   (1 << PAGE_WIDTH)
     35
     36#define LOADER_ADDRESS  0x4400000
     37#define KERNEL_ADDRESS  0x4800000
     38
     39#define STACK_SIZE                   8192
    3240#define STACK_ALIGNMENT              16
    33 #define STACK_BIAS                   2047
    34 #define STACK_WINDOW_SAVE_AREA_SIZE  (16 * 8)
    3541
    3642#endif
  • boot/arch/ia64/include/asm.h

    rfb150d78 r46c20c8  
    3131#define BOOT_ia64_ASM_H_
    3232
    33 #include "types.h"
    34 #include "main.h"
    35 
    36 #define PAGE_WIDTH  14
    37 #define PAGE_SIZE   (1 << PAGE_WIDTH)
    38 
    39 #define BALLOC_MAX_SIZE  (128 * 1024)
    40 
    41 extern void halt(void);
    4233extern void jump_to_kernel(void *) __attribute__((noreturn));
    4334
    44 
    4535#endif
  • boot/arch/ia64/include/main.h

    rfb150d78 r46c20c8  
    3030#define BOOT_ia64_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/ia64/include/types.h

    rfb150d78 r46c20c8  
    2727 */
    2828
    29 #ifndef BOOT_mips32_MAIN_H_
    30 #define BOOT_mips32_MAIN_H_
     29#ifndef BOOT_ia64_TYPES_H_
     30#define BOOT_ia64_TYPES_H_
    3131
    32 #define CPUMAP               0x80001000
    33 #define INITIAL_STACK        0x80002000
    34 #define MSIM_DORDER_ADDRESS  0xb0000004
     32#define TASKMAP_MAX_RECORDS             32
     33#define BOOTINFO_TASK_NAME_BUFLEN       32
     34#define MEMMAP_ITEMS                    128     
    3535
    36 #define TASKMAP_MAX_RECORDS  32
    37 #define CPUMAP_MAX_RECORDS   32
    38 
    39 #ifndef __ASM__
    40 
    41 /** Size of buffer for storing task name in task_t. */
    42 #define BOOTINFO_TASK_NAME_BUFLEN 32
    43 
    44 /** Struct holding information about single loaded task. */
    45 typedef struct {
    46         /** Address where the task was placed. */
    47         void *addr;
    48         /** Size of the task's binary. */
    49         unsigned int size;
    50         /** Task name. */
    51         char name[BOOTINFO_TASK_NAME_BUFLEN];
    52 } task_t;
     36typedef uint64_t size_t;
     37typedef uint64_t unative_t;
     38typedef uint64_t uintptr_t;
    5339
    5440typedef struct {
    55         unsigned int cpumap;
    56         unsigned int cnt;
    57         task_t tasks[TASKMAP_MAX_RECORDS];
     41        void *addr;
     42        size_t size;
     43        char name[BOOTINFO_TASK_NAME_BUFLEN];
     44} binit_task_t;
     45
     46typedef struct {
     47        size_t cnt;
     48        binit_task_t tasks[TASKMAP_MAX_RECORDS];
     49} binit_t;
     50
     51typedef struct {
     52        unsigned int type;
     53        unsigned long base;
     54        unsigned long size;
     55} efi_memmap_item_t;
     56
     57typedef struct {
     58        binit_t taskmap;
     59
     60        efi_memmap_item_t memmap[MEMMAP_ITEMS];
     61        unsigned int memmap_items;
     62
     63        unative_t *sapic;
     64        unsigned long sys_freq;
     65        unsigned long freq_scale;
     66        unsigned int wakeup_intno;
     67        int hello_configured;
    5868} bootinfo_t;
    5969
    60 extern void start(void);
    61 extern void bootstrap(void);
    62 
    6370#endif
    64 
    65 #endif
  • boot/arch/ia64/src/asm.S

    rfb150d78 r46c20c8  
    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>
     30#include <arch/arch.h>
    3131
    3232.text
    3333
     34.global halt
     35.global memcpy
    3436.global jump_to_kernel
    3537
     38halt:
     39        br halt
     40
    3641jump_to_kernel:
    37     alloc loc0 = ar.pfs, 1, 1, 0, 0
    38     movl r8 = 0x4404000;;
    39     mov b1 = r8 ;;
    40     mov r1 = in0;               #Save bootinfo prt
    41     br.call.sptk.many b0 = b1;;
     42        alloc loc0 = ar.pfs, 1, 1, 0, 0
     43        mov r2 = in0 ;;                 # Pass bootinfo address
     44        movl r8 = KERNEL_ADDRESS;;
     45        mov b1 = r8 ;;
     46        br.call.sptk.many b0 = b1;;
  • boot/arch/ia64/src/boot.S

    rfb150d78 r46c20c8  
    2828#
    2929
    30 #include <stack.h>
     30#include <arch/arch.h>
    3131
    3232.section BOOTSTRAP, "ax"
     
    3434.global start
    3535start:
     36        movl gp = LOADER_ADDRESS
    3637
    37 
     38        #
     39        # Initialize the register stack to some sane value.
     40        #
    3841        mov ar.rsc = r0
    39 #       movl r8 = (VRN_KERNEL << VRN_SHIFT) ;;
    40         movl r1 = 0x4400000
    4142        movl r8 = initial_stack ;;
    4243        mov ar.bspstore = r8
    4344        loadrs
    4445
    45         # initialize memory stack to some sane value
     46        #
     47        # Initialize memory stack to some sane value and allocate a scratch area
     48        # on it.
     49        #
    4650        movl r12 = initial_stack_top ;;
    47        
    48         add r12 = -16, r12      /* allocate a scratch area on the stack */
     51        add r12 = -16, r12
    4952
    50         # initialize gp (Global Pointer) register
    51         #movl r1 = _hardcoded_load_address
    52 
    53         ssm (1 << 19) ;; /* Disable f32 - f127 */
     53        #
     54        # Disable Floating-point High register set (f32 - f127)
     55        #
     56        ssm (1 << 19) ;;
    5457        srlz.i
    5558        srlz.d ;;
    5659
    57         movl r18 = bootstrap ;;
    58         mov b1 = r18 ;;
    59         br.call.sptk.many b0 = b1
     60        br.call.sptk.many rp = bootstrap
    6061
    61 .align 512
    62 ap_start:
     62.bss
    6363
    64 
    65 ap_loop:
    66         movl r18=0x4405000;;
    67         mov b1 = r18 ;;
    68         br.call.sptk.many b0 = b1;;
    69 
    70 .align 1024
    71 
    72 .align 4096
    73 .global binfo
    74 binfo:
    75 
    76 
    77 .bss #on this line is ".bss", it cannot be seen in my mcedit :-(
    78 
    79 
    80 .align 8192
    81 
     64.align STACK_SIZE
    8265initial_stack:
    83         .space 8192
    84 
     66        .space STACK_SIZE
    8567initial_stack_top:
  • boot/arch/mips32/Makefile.inc

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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    2727 */
    2828
    29 /** @addtogroup amd64debug
    30  * @{
    31  */
    32 /** @file
    33  */
     29#ifndef BOOT_mips32_MAIN_H_
     30#define BOOT_mips32_MAIN_H_
    3431
    35 #ifndef KERN_ia32_DEBUG_H_
    36 #define KERN_ia32_DEBUG_H_
    37 
    38 #include <arch/asm.h>
    39 
    40 #define HERE get_ip()
     32extern void bootstrap(void);
    4133
    4234#endif
    43 
    44 /** @}
    45  */
  • boot/arch/mips32/include/regname.h

    rfb150d78 r46c20c8  
    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/mips32/include/types.h

    rfb150d78 r46c20c8  
    2727 */
    2828
     29#ifndef BOOT_mips32_TYPES_H_
     30#define BOOT_mips32_TYPES_H_
    2931
    30 /** @addtogroup arm32boot
    31  * @{
    32  */
    33 /** @file
    34  *  @brief Definitions of basic types like #uintptr_t.
    35  */
     32#define TASKMAP_MAX_RECORDS        32
     33#define CPUMAP_MAX_RECORDS         32
     34#define BOOTINFO_TASK_NAME_BUFLEN  32
    3635
     36typedef uint32_t size_t;
     37typedef uint32_t uintptr_t;
    3738
    38 #ifndef BOOT_arm32_TYPES_H
    39 #define BOOT_arm32_TYPES_H
     39typedef struct {
     40        /** Address where the task was placed. */
     41        void *addr;
     42        /** Size of the task's binary. */
     43        size_t size;
     44        /** Task name. */
     45        char name[BOOTINFO_TASK_NAME_BUFLEN];
     46} task_t;
    4047
    41 
    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 
     48typedef struct {
     49        uint32_t cpumap;
     50        size_t cnt;
     51        task_t tasks[TASKMAP_MAX_RECORDS];
     52} bootinfo_t;
    5453
    5554#endif
    56 
    57 
    58 /** @}
    59  */
  • boot/arch/mips32/src/asm.S

    rfb150d78 r46c20c8  
    2727#
    2828
    29 #include "regname.h"
     29#include <arch/arch.h>
     30#include <arch/regname.h>
    3031
    3132.set noat
     
    3334.set nomacro
    3435
     36.global start
     37.global halt
     38.global jump_to_kernel
     39
     40.section BOOTSTRAP
     41
     42start:
     43        /* Setup CPU map (on msim this code
     44           is executed in parallel on all CPUs,
     45           but it not an issue) */
     46        la $a0, PA2KA(CPUMAP_OFFSET)
     47       
     48        sw $zero, 0($a0)
     49        sw $zero, 4($a0)
     50        sw $zero, 8($a0)
     51        sw $zero, 12($a0)
     52       
     53        sw $zero, 16($a0)
     54        sw $zero, 20($a0)
     55        sw $zero, 24($a0)
     56        sw $zero, 28($a0)
     57       
     58        sw $zero, 32($a0)
     59        sw $zero, 36($a0)
     60        sw $zero, 40($a0)
     61        sw $zero, 44($a0)
     62       
     63        sw $zero, 48($a0)
     64        sw $zero, 52($a0)
     65        sw $zero, 56($a0)
     66        sw $zero, 60($a0)
     67       
     68        sw $zero, 64($a0)
     69        sw $zero, 68($a0)
     70        sw $zero, 72($a0)
     71        sw $zero, 76($a0)
     72       
     73        sw $zero, 80($a0)
     74        sw $zero, 84($a0)
     75        sw $zero, 88($a0)
     76        sw $zero, 92($a0)
     77       
     78        sw $zero, 96($a0)
     79        sw $zero, 100($a0)
     80        sw $zero, 104($a0)
     81        sw $zero, 108($a0)
     82       
     83        sw $zero, 112($a0)
     84        sw $zero, 116($a0)
     85        sw $zero, 120($a0)
     86        sw $zero, 124($a0)
     87       
     88        lui $a1, 1
     89       
     90#ifdef MACHINE_msim
     91       
     92        /* Read dorder value */
     93        la $k0, MSIM_DORDER_ADDRESS
     94        lw $k1, ($k0)
     95       
     96        /* If we are not running on BSP
     97           then end in an infinite loop  */
     98        beq $k1, $zero, bsp
     99        nop
     100       
     101        /* Record CPU presence */
     102        sll $a2, $k1, 2
     103        addu $a2, $a2, $a0
     104        sw $a1, ($a2)
     105       
     106        loop:
     107                j loop
     108                nop
     109       
     110#endif
     111       
     112        bsp:
     113                /* Record CPU presence */
     114                sw $a1, ($a0)
     115               
     116                /* Setup initial stack */
     117                la $sp, PA2KA(STACK_OFFSET)
     118               
     119                j bootstrap
     120                nop
     121
    35122.text
    36123
    37 .global halt
    38 .global memcpy
    39 .global jump_to_kernel
    40 
    41124halt:
    42         b halt
     125        j halt
    43126        nop
    44        
    45 memcpy:
    46         addiu   $v0,$a1,3
    47         li      $v1,-4                  # 0xfffffffffffffffc
    48         and     $v0,$v0,$v1
    49         beq     $a1,$v0,3f
    50         move    $t0,$a0
    51         move    $t2,$a0                 # save dst
    52 
    53 0:
    54         beq     $a2,$zero,2f
    55         move    $a3,$zero
    56 
    57 1:
    58         addu    $v0,$a1,$a3
    59         lbu     $a0,0($v0)
    60         addu    $v1,$t0,$a3
    61         addiu   $a3,$a3,1
    62         bne     $a3,$a2,1b
    63         sb      $a0,0($v1)
    64 
    65 2:
    66         jr      $ra
    67         move    $v0,$t2
    68 
    69 3:
    70         addiu   $v0,$a0,3
    71         and     $v0,$v0,$v1
    72         bne     $a0,$v0,0b
    73         srl     $t1,$a2,2
    74 
    75         beq     $t1,$zero,5f
    76         move    $a3,$zero
    77 
    78         move    $a3,$zero
    79         move    $a0,$zero
    80 4:
    81         addu    $v0,$a1,$a0
    82         lw      $v1,0($v0)
    83         addiu   $a3,$a3,1
    84         addu    $v0,$t0,$a0
    85         sw      $v1,0($v0)
    86         bne     $a3,$t1,4b
    87         addiu   $a0,$a0,4
    88 
    89 5:
    90         andi    $a2,$a2,0x3
    91         beq     $a2,$zero,2b
    92         nop
    93 
    94         sll     $v0,$a3,2
    95         addu    $t1,$v0,$t0
    96         move    $a3,$zero
    97         addu    $t0,$v0,$a1
    98 6:
    99         addu    $v0,$t0,$a3
    100         lbu     $a0,0($v0)
    101         addu    $v1,$t1,$a3
    102         addiu   $a3,$a3,1
    103         bne     $a3,$a2,6b
    104         sb      $a0,0($v1)
    105 
    106         jr      $ra
    107         move    $v0,$t2
    108127
    109128jump_to_kernel:
    110129        #
    111         # TODO
     130        # TODO:
    112131        # Make sure that the I-cache, D-cache and memory are mutually coherent
    113132        # before passing control to the copied code.
  • boot/arch/mips32/src/putchar.c

    rfb150d78 r46c20c8  
    11/*
    2  * Copyright (c) 2005 Jakub Vana
     2 * Copyright (c) 2006 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #include <print.h>
    30 #include <debug.h>
     29#include <typedefs.h>
     30#include <arch/arch.h>
     31#include <putchar.h>
     32#include <str.h>
    3133
    32 #include <test.h>
    33 #include <sysinfo/sysinfo.h>
    34 
    35 char *test_sysinfo1(void)
     34void putchar(const wchar_t ch)
    3635{
    37         if (!test_quiet)
    38                 sysinfo_dump(NULL, 0);
    39         return NULL;
     36        if (ascii_check(ch))
     37                *((char *) MSIM_VIDEORAM_ADDRESS) = ch;
     38        else
     39                *((char *) MSIM_VIDEORAM_ADDRESS) = U_SPECIAL;
    4040}
  • boot/arch/ppc32/Makefile.inc

    rfb150d78 r46c20c8  
    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:
    44         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
     42RD_SRVS_ESSENTIAL += \
     43        $(USPACE_PATH)/srv/hw/bus/cuda_adb/cuda_adb
    4544
    46 clean: generic_clean
    47         $(MAKE) -C arch/$(BARCH)/loader clean
    48         rm -fr $(TMP)
    49         rm -f $(BASE)/image.iso
     45RD_SRVS_NON_ESSENTIAL += \
     46        $(USPACE_PATH)/srv/hid/adb_mouse/adb_ms
     47
     48SOURCES = \
     49        arch/$(BARCH)/src/asm.S \
     50        arch/$(BARCH)/src/main.c \
     51        arch/$(BARCH)/src/ofw.c \
     52        $(COMPS_C) \
     53        genarch/src/ofw.c \
     54        genarch/src/ofw_tree.c \
     55        genarch/src/division.c \
     56        genarch/src/multiplication.c \
     57        generic/src/balloc.c \
     58        generic/src/memstr.c \
     59        generic/src/printf_core.c \
     60        generic/src/vprintf.c \
     61        generic/src/printf.c \
     62        generic/src/str.c \
     63        generic/src/version.c \
     64        generic/src/inflate.c
  • boot/arch/ppc32/_link.ld.in

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    2727 */
    2828
    29 #ifndef BOOT_ia64_TYPES_H_
    30 #define BOOT_ia64_TYPES_H_
     29#ifndef BOOT_ppc32_ARCH_H_
     30#define BOOT_ppc32_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 BOOT_OFFSET  0x8000
    3536
    36 typedef unsigned char uint8_t;
    37 typedef unsigned short uint16_t;
    38 typedef unsigned int uint32_t;
    39 typedef unsigned long uint64_t;
     37#define LOADER_ADDRESS  0x01000000
    4038
    41 typedef uint64_t uintptr_t;
    42 typedef uint64_t unative_t;
     39#ifndef __ASM__
     40        #define PA2KA(addr)  (((uintptr_t) (addr)) + 0x80000000)
     41#else
     42        #define PA2KA(addr)  ((addr) + 0x80000000)
     43#endif
    4344
    4445#endif
  • boot/arch/ppc32/include/asm.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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
     60.global start
     61.global halt
     62.global jump_to_kernel
     63.global real_mode
     64
     65.section BOOTSTRAP, "ax"
     66
     67start:
     68        lis r4, ofw_cif@ha
     69        addi r4, r4, ofw_cif@l
     70        stw r5, 0(r4)
     71       
     72        bl ofw_init
     73        b bootstrap
     74
    6175.text
    62 
    63 .global halt
    64 .global memcpy
    65 .global jump_to_kernel
    66 .global balloc_base
    6776
    6877halt:
    6978        b halt
    7079
    71 memcpy:
    72         srwi. r7, r5, 3
    73         addi r6, r3, -4
    74         addi r4, r4, -4
    75         beq 2f
    76        
    77         andi. r0, r6, 3
    78         mtctr r7
    79         bne 5f
    80        
    81         1:
    82                 lwz r7, 4(r4)
    83                 lwzu r8, 8(r4)
    84                 stw r7, 4(r6)
    85                 stwu r8, 8(r6)
    86                 bdnz 1b
    87                
    88                 andi. r5, r5, 7
    89        
    90         2:
    91                 cmplwi 0, r5, 4
    92                 blt 3f
    93                
    94                 lwzu r0, 4(r4)
    95                 addi r5, r5, -4
    96                 stwu r0, 4(r6)
    97        
    98         3:
    99                 cmpwi 0, r5, 0
    100                 beqlr
    101                 mtctr r5
    102                 addi r4, r4, 3
    103                 addi r6, r6, 3
    104        
    105         4:
    106                 lbzu r0, 1(r4)
    107                 stbu r0, 1(r6)
    108                 bdnz 4b
    109                 blr
    110        
    111         5:
    112                 subfic r0, r0, 4
    113                 mtctr r0
    114        
    115         6:
    116                 lbz r7, 4(r4)
    117                 addi r4, r4, 1
    118                 stb r7, 4(r6)
    119                 addi r6, r6, 1
    120                 bdnz 6b
    121                 subf r5, r0, r5
    122                 rlwinm. r7, r5, 32-3, 3, 31
    123                 beq 2b
    124                 mtctr r7
    125                 b 1b
    126 
    12780jump_to_kernel:
    12881       
    129         # r3 = bootinfo (pa)
    130         # r4 = bootinfo_size
    131         # r5 = trans (pa)
    132         # r6 = bytes to copy
    133         # r7 = real_mode (pa)
     82        # arguments:
     83        # r3 = bootinfo (physical address)
     84        # r4 = translate table (physical address)
     85        # r5 = pages to translate
     86        # r6 = real mode meeting point (physical address)
    13487       
    13588        # disable interrupts
     
    13992        mtmsr r31
    14093       
    141         # set real_mode meeting point address
    142        
    143         mtspr srr0, r7
    144        
    145         # jumps to real_mode
     94        # set real mode meeting point physical address
     95       
     96        mtspr srr0, r6
     97       
     98        # jump to real_mode
    14699       
    147100        mfmsr r31
     
    155108        rfi
    156109
     110.section REALMODE, "ax"
     111
    157112.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
    165113real_mode:
    166114       
    167         # copy kernel to proper location
    168         #
    169         # r3 = bootinfo (pa)
    170         # r4 = bootinfo_size
    171         # r5 = trans (pa)
    172         # r6 = bytes to copy
     115        # arguments:
     116        # r3 = bootinfo (physical address)
     117        # r4 = translate table (physical address)
     118        # r5 = pages to translate
     119       
     120        # move the images of components to the proper
     121        # location using the translate table
    173122       
    174123        li r31, PAGE_SIZE >> 2
     
    177126        page_copy:
    178127               
    179                 cmpwi r6, 0
     128                cmpwi r5, 0
    180129                beq copy_end
    181130               
    182                 # copy page
    183                
    184131                mtctr r31
    185                 lwz r29, 0(r5)
     132                lwz r29, 0(r4)
    186133               
    187134                copy_loop:
     
    194141                        addi r29, r29, 4
    195142                        addi r30, r30, 4
    196                         subi r6, r6, 4
    197                        
    198                         cmpwi r6, 0
    199                         beq copy_end
    200143                       
    201144                        bdnz copy_loop
    202                        
    203                 addi r5, r5, 4
     145               
     146                addi r4, r4, 4
     147                subi r5, r5, 1
    204148                b page_copy
    205149       
     
    266210        # on top of memory, size 64 KB
    267211       
    268         lwz r31, 0(r3)                # r31 = memory size
     212        lwz r31, 4(r3)                # r31 = memory size
    269213       
    270214        lis r30, 65536@h
     
    303247        # create BAT identity mapping
    304248       
    305         lwz r31, 0(r3)                # r31 = memory size
     249        lwz r31, 4(r3)                # r31 = memory size
    306250       
    307251        lis r29, 0x0002
     
    354298        #
    355299        # pc = PA2KA(BOOT_OFFSET)
    356         # r3 = bootinfo (pa)
     300        # r3 = bootinfo (physical address)
    357301        # sprg0 = BOOT_OFFSET
    358302        # sprg3 = physical memory size
    359         # sp = 0 (pa)
     303        # sp = 0 (enforces the usage of sprg0 as exception stack)
    360304       
    361305        lis r31, PA2KA(BOOT_OFFSET)@ha
     
    367311        mtsprg0 r31
    368312       
    369         lwz r31, 0(r3)
     313        # bootinfo starts with a 64 bit integer containing
     314        # the physical memory size, get the lower 4 bytes
     315       
     316        lwz r31, 4(r3)
    370317        mtsprg3 r31
    371318       
     
    379326        isync
    380327        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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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 -mcmodel=medlow
    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_NON_ESSENTIAL +=
    5543
    56 arch/$(BARCH)/loader/image.boot:
    57         $(MAKE) -C arch/$(BARCH)/loader PRECHECK=$(PRECHECK)
     44RD_SRVS_ESSENTIAL += \
     45        $(USPACE_PATH)/srv/hw/cir/fhc/fhc \
     46        $(USPACE_PATH)/srv/hw/cir/obio/obio
    5847
    59 clean: generic_clean
    60         $(MAKE) -C arch/$(BARCH)/loader clean
    61         rm -fr $(TMP)
    62         rm -f $(BASE)/image.iso
     48SOURCES = \
     49        arch/$(BARCH)/src/asm.S \
     50        arch/$(BARCH)/src/main.c \
     51        arch/$(BARCH)/src/ofw.c \
     52        $(COMPS_C) \
     53        genarch/src/ofw.c \
     54        genarch/src/ofw_tree.c \
     55        generic/src/balloc.c \
     56        generic/src/memstr.c \
     57        generic/src/printf_core.c \
     58        generic/src/vprintf.c \
     59        generic/src/printf.c \
     60        generic/src/str.c \
     61        generic/src/version.c \
     62        generic/src/inflate.c
  • boot/arch/sparc64/_link.ld.in

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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(uintptr_t physmem_start, bootinfo_t *bootinfo,
     36    uint8_t subarch, void *entry) __attribute__((noreturn));
    3837
    3938#endif
  • boot/arch/sparc64/include/ofw.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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
     39.register %g6, #scratch
     40.register %g7, #scratch
     41
     42.global start
     43.global halt
     44.global jump_to_kernel
     45
     46.section BOOTSTRAP, "ax"
     47
     48start:
     49        ba %xcc, 1f
     50        nop
     51
     52/*
     53 * This header forces SILO to load the image at 0x4000.
     54 * More precisely, SILO will think this is an old version of Linux.
     55 */
     56.ascii "HdrS"
     57.word 0
     58.half 0
     59.half 0
     60.half 0
     61.half 0
     62.word 0
     63.word 0
     64
     65.align 8
     661:
     67        ! Disable interrupts and disable address masking.
     68       
     69        wrpr %g0, PSTATE_PRIV_BIT, %pstate
     70       
     71        wrpr %g0, NWINDOWS - 2, %cansave   ! Set maximum saveable windows
     72        wrpr %g0, 0, %canrestore           ! Get rid of windows we will never need again
     73        wrpr %g0, 0, %otherwin             ! Make sure the window state is consistent
     74        wrpr %g0, NWINDOWS - 1, %cleanwin  ! Prevent needless clean_window traps for kernel
     75       
     76        set initial_stack, %sp
     77        add %sp, -STACK_BIAS, %sp
     78       
     79        set ofw_cif, %l0
     80       
     81        ! Initialize OpenFirmware
     82       
     83        call ofw_init
     84        stx %o4, [%l0]
     85       
     86        ba %xcc, bootstrap
     87        nop
     88
     89.align STACK_ALIGNMENT
     90        .space STACK_SIZE
     91initial_stack:
     92        .space STACK_WINDOW_SAVE_AREA_SIZE
    3593
    3694.text
    37 
    38 .global halt
    39 .global memcpy
    40 .global jump_to_kernel
    4195
    4296halt:
     
    4498        nop
    4599
    46 memcpy:
    47         mov %o0, %o3      ! save dst
    48         add %o1, 7, %g1
    49         and %g1, -8, %g1
    50         cmp %o1, %g1
    51         be,pn %xcc, 3f
    52         add %o0, 7, %g1
    53         mov 0, %g3
    54        
    55         0:
    56                 brz,pn %o2, 2f
    57                 mov 0, %g2
    58        
    59         1:
    60                 ldub [%g3 + %o1], %g1
    61                 add %g2, 1, %g2
    62                 cmp %o2, %g2
    63                 stb %g1, [%g3 + %o0]
    64                 bne,pt %xcc, 1b
    65                 mov %g2, %g3
    66        
    67         2:
    68                 jmp %o7 + 8   ! exit point
    69                 mov %o3, %o0
    70        
    71         3:
    72                 and %g1, -8, %g1
    73                 cmp %o0, %g1
    74                 bne,pt %xcc, 0b
    75                 mov 0, %g3
    76                 srlx %o2, 3, %g4
    77                 brz,pn %g4, 5f
    78                 mov 0, %g5
    79        
    80         4:
    81                 sllx %g3, 3, %g2
    82                 add %g5, 1, %g3
    83                 ldx [%o1 + %g2], %g1
    84                 mov %g3, %g5
    85                 cmp %g4, %g3
    86                 bne,pt %xcc, 4b
    87                 stx %g1, [%o0 + %g2]
    88        
    89         5:
    90                 and %o2, 7, %o2
    91                 brz,pn %o2, 2b
    92                 sllx %g4, 3, %g1
    93                 mov 0, %g2
    94                 add %g1, %o0, %o0
    95                 add %g1, %o1, %g4
    96                 mov 0, %g3
    97        
    98         6:
    99                 ldub [%g2 + %g4], %g1
    100                 stb %g1, [%g2 + %o0]
    101                 add %g3, 1, %g2
    102                 cmp %o2, %g2
    103                 bne,pt %xcc, 6b
    104                 mov %g2, %g3
    105        
    106         jmp %o7 + 8   ! exit point
    107         mov %o3, %o0
    108 
    109100jump_to_kernel:
    110101        /*
    111          * We have copied code and now we need to guarantee cache coherence.
     102         * Guarantee cache coherence:
    112103         * 1. Make sure that the code we have moved has drained to main memory.
    113104         * 2. Invalidate I-cache.
     
    118109         * US3 processors have a write-invalidate cache, so explicitly
    119110         * invalidating it is not required. Whether to invalidate I-cache
    120          * or not is decided according to the value of the 5th argument
    121          * (subarchitecture).
     111         * or not is decided according to the value of the 3rd argument
     112         * (subarch).
    122113         */
    123         cmp %i4, 3
     114        cmp %o2, SUBARCH_US3
    124115        be %xcc, 1f
    125116        nop
     
    137128        flush %i7
    138129       
    139         mov %o0, %l1
    140         mov %o1, %o0
    141         mov %o2, %o1
    142         mov %o3, %o2
    143         jmp %l1       ! jump to kernel
     130        ! Jump to kernel
     131        jmp %o3
    144132        nop
    145 
    146 #define ICACHE_SIZE       8192
    147 #define ICACHE_LINE_SIZE  32
    148 #define ICACHE_SET_BIT    (1 << 13)
    149 #define ASI_ICACHE_TAG    0x67
    150133
    151134# Flush I-cache
     
    162145        membar #Sync
    163146        retl
     147       
    164148        ! SF Erratum #51
     149       
    165150        nop
    166151
     
    171156        ldx [%l0], %l0
    172157       
    173         rdpr  %pstate, %l1
    174         and  %l1, ~PSTATE_AM_BIT, %l2
    175         wrpr  %l2, 0, %pstate
     158        rdpr %pstate, %l1
     159        and %l1, ~PSTATE_AM_BIT, %l2
     160        wrpr %l2, 0, %pstate
    176161       
    177162        jmpl %l0, %o7
  • boot/arch/sparc64/src/ofw.c

    rfb150d78 r46c20c8  
    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.