Changeset 6bbb1610 in mainline


Ignore:
Timestamp:
2006-05-21T20:13:14Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
433a2aa
Parents:
0ab829c
Message:

port ppc32 changes to ppc64 (raw)

Location:
arch/ppc64
Files:
1 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • arch/ppc64/Makefile.inc

    r0ab829c r6bbb1610  
    2929build: image.boot
    3030
    31 image.boot: kernel
    32         make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNEL=../../../$(KERNELDIR)/kernel.bin
     31image.boot: kernel uspace
     32        make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
    3333        cp arch/$(ARCH)/loader/image.boot image.boot
    3434
    35 clean: clean_kernel
    36         make -C arch/$(ARCH)/loader clean
     35clean: clean_kernel clean_uspace
     36        make -C arch/$(ARCH)/loader clean KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
    3737        -rm -f image.boot
    3838
    39 arch_distclean: distclean_kernel
     39arch_distclean: distclean_kernel distclean_uspace
  • arch/ppc64/loader/Makefile

    r0ab829c r6bbb1610  
    3131
    3232TARGET = ppc-linux-gnu
    33 TOOLCHAIN_DIR = /usr/local/ppc/bin
     33TOOLCHAIN_DIR = /usr/local/ppc64/bin
    3434
    3535ifeq ($(COMPILER),native)
     
    4747endif
    4848
    49 CFLAGS = -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=powerpc64 -m64
     49CFLAGS = -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=powerpc64 -msoft-float -m64
    5050DEFS =
    5151
     
    5757        boot.S
    5858
     59COMPONENTS = \
     60        $(KERNELDIR)/kernel.bin \
     61        $(USPACEDIR)/ns/ns \
     62        $(USPACEDIR)/init/init \
     63        $(USPACEDIR)/fb/fb
     64
    5965OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
     66COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
    6067
    6168.PHONY: all clean depend
     
    6572-include Makefile.depend
    6673
    67 image.boot: depend $(OBJECTS) kernel.o
    68         $(LD) -no-check-sections -N -T _link.ld $(OBJECTS) kernel.o -o $@
     74image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) kernel.o
     75        $(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
    6976
    7077depend:
     
    7279
    7380clean:
    74         -rm -f $(OBJECTS) image.boot kernel.o Makefile.depend
     81        -rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
    7582
    76 kernel.o: $(KERNEL)
    77         $(OBJCOPY) -I binary -O elf64-powerpc -B powerpc --rename-section .data=.image $(KERNEL) $@
     83_components.h _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
     84        ./pack $(OBJCOPY) $(COMPONENTS)
    7885
    7986%.o: %.S
  • arch/ppc64/loader/asm.S

    r0ab829c r6bbb1610  
    107107        # r4 = bootinfo_size
    108108        # r5 = trans (pa)
    109         # r6 = kernel size
    110         # r7 = framebuffer (pa)
    111         # r8 = real_mode (pa)
    112        
    113         mtspr srr0, r8
     109        # r6 = bytes to copy
     110        # r7 = real_mode (pa)
     111       
     112        # disable interrupts
     113       
     114        mfmsr r31
     115        rlwinm r31, r31, 0, 17, 15
     116        mtmsr r31
     117       
     118        # set real_mode meeting point address
     119       
     120        mtspr srr0, r7
    114121       
    115122        # jumps to real_mode
     
    125132        rfid
    126133
    127 .section REALMODE
     134.section REALMODE, "ax"
    128135.align PAGE_WIDTH
    129136.global real_mode
     
    134141        #
    135142        # r5 = trans (pa)
    136         # r6 = kernel size
    137         # r7 = framebuffer (pa)
     143        # r6 = bytes to copy
    138144       
    139145        li r31, PAGE_SIZE >> 2
     
    169175        copy_end:
    170176       
    171         # invalidate segment registers
     177        # initially fill segment registers
    172178
    173179        li r31, 16
    174180        mtctr r31
    175181        li r31, 0
    176         li r30, 0
     182        li r30, 0x2000
    177183
    178184        seg_fill:
    179185       
    180186                mtsrin r30, r31
     187                addi r30, r30, 0x111
    181188                addis r31, r31, 0x1000    # move to next SR
    182189               
    183190                bdnz seg_fill
    184191       
    185         # invalidate block address translation registers
    186        
    187         mtspr ibat0u, r30
    188         mtspr ibat0l, r30
    189        
    190         mtspr ibat1u, r30
    191         mtspr ibat1l, r30
    192        
    193         mtspr ibat2u, r30
    194         mtspr ibat2l, r30
    195        
    196         mtspr ibat3u, r30
    197         mtspr ibat3l, r30
    198        
    199         mtspr dbat0u, r30
    200         mtspr dbat0l, r30
    201        
    202         mtspr dbat1u, r30
    203         mtspr dbat1l, r30
    204        
    205         mtspr dbat2u, r30
    206         mtspr dbat2l, r30
    207        
    208         mtspr dbat3u, r30
    209         mtspr dbat3l, r30
    210        
    211         # create identity mapping
    212        
    213         # FIXME: map exactly the size of RAM
    214        
    215         lis r31, 0x8000
    216         ori r31, r31, 0x0ffe
    217        
    218         lis r30, 0x0000
    219         ori r30, r30, 0x0002
    220        
    221         mtspr ibat0u, r31
    222         mtspr ibat0l, r30
    223        
    224         mtspr dbat0u, r31
    225         mtspr dbat0l, r30
    226        
    227         # FIXME: temporal framebuffer mapping
    228        
    229         lis r31, 0xf000
    230         ori r31, r31, 0x0ffe
    231        
    232         mr r30, r7
    233         ori r30, r30, 0x0002
    234        
    235         mtspr dbat1u, r31
    236         mtspr dbat1l, r30
    237        
    238192        tlbia
     193        tlbsync
    239194       
    240195        # start the kernel
  • arch/ppc64/loader/asm.h

    r0ab829c r6bbb1610  
    3434
    3535#define TRANS_SIZE 1024
    36 #define TRANS_ITEM_SIZE 4
     36#define TRANS_ITEM_SIZE 8
    3737
    3838#define KERNEL_START_ADDR 0x80004000
     
    4545
    4646extern void halt();
    47 extern void jump_to_kernel(void *bootinfo, unsigned long bootinfo_size, void *trans, unsigned long kernel_size, void *framebuffer, void *real_mode) __attribute__((noreturn));
     47extern void jump_to_kernel(void *bootinfo, unsigned long bootinfo_size, void *trans, unsigned long kernel_size, void *real_mode) __attribute__((noreturn));
    4848extern void real_mode();
    4949
  • arch/ppc64/loader/boot.S

    r0ab829c r6bbb1610  
    2929#include "regname.h"
    3030
    31 .section BOOTSTRAP
     31.section BOOTSTRAP, "ax"
    3232
    3333.global start
  • arch/ppc64/loader/main.c

    r0ab829c r6bbb1610  
    3030#include "printf.h"
    3131#include "asm.h"
    32 
    33 #define KERNEL_START ((void *) &_binary_____________kernel_kernel_bin_start)
    34 #define KERNEL_END ((void *) &_binary_____________kernel_kernel_bin_end)
    35 #define KERNEL_SIZE ((unsigned long) KERNEL_END - (unsigned long) KERNEL_START)
     32#include "_components.h"
    3633
    3734#define HEAP_GAP 1024000
     
    7774void bootstrap(void)
    7875{
    79         printf("\nHelenOS PPC64 Bootloader\n");
     76        printf("\nHelenOS PPC Bootloader\n");
    8077       
    81         check_align(KERNEL_START, "Kernel image");
    82         check_align(&real_mode, "Bootstrap trampoline");
    83         check_align(&trans, "Translation table");
     78        init_components();
     79       
     80        unsigned int i;
     81       
     82        for (i = 0; i < COMPONENTS; i++)
     83                check_align(components[i].start, components[i].name);
     84       
     85        check_align(&real_mode, "bootstrap trampoline");
     86        check_align(&trans, "translation table");
    8487       
    8588        if (!ofw_memmap(&bootinfo.memmap)) {
    86                 printf("Error: Unable to get memory map, halting.\n");
     89                printf("Error: unable to get memory map, halting.\n");
    8790                halt();
    8891        }
    8992       
    9093        if (bootinfo.memmap.total == 0) {
    91                 printf("Error: No memory detected, halting.\n");
     94                printf("Error: no memory detected, halting.\n");
    9295                halt();
    9396        }
    9497       
    9598        if (!ofw_screen(&bootinfo.screen)) {
    96                 printf("Error: Unable to get screen properties, halting.\n");
     99                printf("Error: unable to get screen properties, halting.\n");
    97100                halt();
    98101        }
     
    104107        void *trans_pa = ofw_translate(&trans);
    105108        void *bootinfo_pa = ofw_translate(&bootinfo);
    106         void *fb = (void *) (((unsigned long) bootinfo.screen.addr) & ((unsigned long) ~0 << 17));
    107109       
    108110        printf("\nMemory statistics (total %d MB)\n", bootinfo.memmap.total >> 20);
    109         printf(" kernel image         at %L (size %d bytes)\n", KERNEL_START, KERNEL_SIZE);
    110         printf(" boot info            at %L (physical %L)\n", &bootinfo, bootinfo_pa);
    111         printf(" bootstrap trampoline at %L (physical %L)\n", &real_mode, real_mode_pa);
    112         printf(" translation table    at %L (physical %L)\n", &trans, trans_pa);
     111        printf(" %L: boot info structure (physical %L)\n", &bootinfo, bootinfo_pa);
     112        printf(" %L: bootstrap trampoline (physical %L)\n", &real_mode, real_mode_pa);
     113        printf(" %L: translation table (physical %L)\n", &trans, trans_pa);
     114        for (i = 0; i < COMPONENTS; i++)
     115                printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
    113116       
    114         unsigned long top = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE);
    115         unsigned long addr;
    116         for (addr = 0; addr < KERNEL_SIZE; addr += PAGE_SIZE) {
    117                 void *pa = ofw_translate(KERNEL_START + addr);
    118                 fix_overlap(KERNEL_START + addr, &pa, "Kernel image", &top);
    119                 trans[addr >> PAGE_WIDTH] = pa;
     117        unsigned long top = 0;
     118        for (i = 0; i < COMPONENTS; i++)
     119                top += ALIGN_UP(components[i].size, PAGE_SIZE);
     120       
     121        unsigned long pages = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE) >> PAGE_WIDTH;
     122       
     123        for (i = 0; i < pages; i++) {
     124                void *pa = ofw_translate(KERNEL_START + (i << PAGE_WIDTH));
     125                fix_overlap(KERNEL_START + (i << PAGE_WIDTH), &pa, "kernel", &top);
     126                trans[i] = pa;
    120127        }
    121128       
    122         fix_overlap(&real_mode, &real_mode_pa, "Bootstrap trampoline", &top);
    123         fix_overlap(&trans, &trans_pa, "Translation table", &top);
    124         fix_overlap(&bootinfo, &bootinfo_pa, "Boot info", &top);
     129        bootinfo.taskmap.count = 0;
     130        for (i = 1; i < COMPONENTS; i++) {
     131                unsigned long component_pages = ALIGN_UP(components[i].size, PAGE_SIZE) >> PAGE_WIDTH;
     132                unsigned long j;
     133               
     134                for (j = 0; j < component_pages; j++) {
     135                        void *pa = ofw_translate(components[i].start + (j << PAGE_WIDTH));
     136                        fix_overlap(components[i].start + (j << PAGE_WIDTH), &pa, components[i].name, &top);
     137                        trans[pages + j] = pa;
     138                        if (j == 0) {
     139                                bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = (void *) (pages << PAGE_WIDTH);
     140                                bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = components[i].size;
     141                                bootinfo.taskmap.count++;
     142                        }
     143                }
     144               
     145                pages += component_pages;
     146        }
     147       
     148        fix_overlap(&real_mode, &real_mode_pa, "bootstrap trampoline", &top);
     149        fix_overlap(&trans, &trans_pa, "translation table", &top);
     150        fix_overlap(&bootinfo, &bootinfo_pa, "boot info", &top);
    125151       
    126152        printf("\nBooting the kernel...\n");
    127         jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, KERNEL_SIZE, fb, real_mode_pa);
     153        jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa);
    128154}
  • arch/ppc64/loader/main.h

    r0ab829c r6bbb1610  
    3939#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
    4040
     41#define TASKMAP_MAX_RECORDS 32
     42
    4143typedef struct {
     44        void *addr;
     45        unsigned long size;
     46} task_t;
     47
     48typedef struct {
     49        unsigned int count;
     50        task_t tasks[TASKMAP_MAX_RECORDS];
     51} taskmap_t;
     52
     53typedef struct {
     54        taskmap_t taskmap;
    4255        memmap_t memmap;
    4356        screen_t screen;
    4457} bootinfo_t;
    4558
    46 extern long _binary_____________kernel_kernel_bin_start;
    47 extern long _binary_____________kernel_kernel_bin_end;
    4859extern void start(void);
    4960extern void bootstrap(void);
  • arch/ppc64/loader/ofw.c

    r0ab829c r6bbb1610  
    3434#define BUF_SIZE                1024
    3535
    36 typedef unsigned long ofw_arg_t;
    37 typedef unsigned long ihandle;
    38 typedef unsigned long phandle;
     36typedef unsigned int ofw_arg_t;
     37typedef unsigned int ihandle;
     38typedef unsigned int phandle;
    3939
    4040/** OpenFirmware command structure
     
    4343typedef struct {
    4444        const char *service;          /**< Command name */
    45         unsigned long nargs;           /**< Number of in arguments */
    46         unsigned long nret;            /**< Number of out arguments */
     45        unsigned int nargs;           /**< Number of in arguments */
     46        unsigned int nret;            /**< Number of out arguments */
    4747        ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */
    4848} ofw_args_t;
     
    6161
    6262
    63 static long ofw_call(const char *service, const long nargs, const long nret, ofw_arg_t *rets, ...)
     63static int ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
    6464{
    6565        va_list list;
    6666        ofw_args_t args;
    67         long i;
     67        int i;
    6868       
    6969        args.service = service;
     
    9494
    9595
    96 static long ofw_get_property(const phandle device, const char *name, const void *buf, const long buflen)
     96static int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
    9797{
    9898        return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
     
    100100
    101101
    102 static unsigned long ofw_get_address_cells(const phandle device)
    103 {
    104         unsigned long ret;
     102static unsigned int ofw_get_address_cells(const phandle device)
     103{
     104        unsigned int ret;
    105105       
    106106        if (ofw_get_property(device, "#address-cells", &ret, sizeof(ret)) <= 0)
     
    112112
    113113
    114 static unsigned long ofw_get_size_cells(const phandle device)
    115 {
    116         unsigned long ret;
     114static unsigned int ofw_get_size_cells(const phandle device)
     115{
     116        unsigned int ret;
    117117       
    118118        if (ofw_get_property(device, "#size-cells", &ret, sizeof(ret)) <= 0)
     
    185185
    186186
    187 long ofw_map(const void *phys, const void *virt, const long size, const long mode)
     187int ofw_map(const void *phys, const void *virt, const int size, const int mode)
    188188{
    189189        return ofw_call("call-method", 6, 1, NULL, "map", ofw_mmu, mode, size, virt, phys);
     
    191191
    192192
    193 long ofw_memmap(memmap_t *map)
    194 {
    195         unsigned long buf[BUF_SIZE];
    196         long ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(unsigned long) * BUF_SIZE);
     193int ofw_memmap(memmap_t *map)
     194{
     195        unsigned int buf[BUF_SIZE];
     196        int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(unsigned int) * BUF_SIZE);
    197197        if (ret <= 0)
    198198                return false;
    199199               
    200         unsigned long ac = ofw_get_address_cells(ofw_memory);
    201         unsigned long sc = ofw_get_size_cells(ofw_memory);
    202        
    203         long pos;
     200        unsigned int ac = ofw_get_address_cells(ofw_memory);
     201        unsigned int sc = ofw_get_size_cells(ofw_memory);
     202       
     203        int pos;
    204204        map->total = 0;
    205205        map->count = 0;
    206         for (pos = 0; (pos < ret / sizeof(unsigned long)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
     206        for (pos = 0; (pos < ret / sizeof(unsigned int)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
    207207                void * start = (void *) buf[pos + ac - 1];
    208                 unsigned long size = buf[pos + ac + sc - 1];
     208                unsigned int size = buf[pos + ac + sc - 1];
    209209               
    210210                if (size > 0) {
     
    218218
    219219
    220 long ofw_screen(screen_t *screen)
     220int ofw_screen(screen_t *screen)
    221221{
    222222        char device_name[BUF_SIZE];
  • arch/ppc64/loader/ofw.h

    r0ab829c r6bbb1610  
    4848typedef struct {
    4949        unsigned long total;
    50         unsigned long count;
     50        unsigned int count;
    5151        memzone_t zones[MEMMAP_MAX_RECORDS];
    5252} memmap_t;
     
    5454typedef struct {
    5555        void *addr;
    56         unsigned long width;
    57         unsigned long height;
    58         unsigned long bpp;
    59         unsigned long scanline;
     56        unsigned int width;
     57        unsigned int height;
     58        unsigned int bpp;
     59        unsigned int scanline;
    6060} screen_t;
    6161
     
    6565
    6666extern void *ofw_translate(const void *virt);
    67 extern long ofw_map(const void *phys, const void *virt, const long size, const long mode);
    68 extern long ofw_memmap(memmap_t *map);
    69 extern long ofw_screen(screen_t *screen);
     67extern int ofw_map(const void *phys, const void *virt, const long size, const int mode);
     68extern int ofw_memmap(memmap_t *map);
     69extern int ofw_screen(screen_t *screen);
    7070
    7171#endif
  • arch/ppc64/loader/regname.h

    r0ab829c r6bbb1610  
    2727 */
    2828
    29 #ifndef __ppc64_REGNAME_H__
    30 #define __ppc64_REGNAME_H__
     29#ifndef __ppc32_REGNAME_H__
     30#define __ppc32_REGNAME_H__
    3131
    3232/* Condition Register Bit Fields */
     
    190190#define sprg3   275
    191191#define prv             287
    192 #define ibat0u  528
    193 #define ibat0l  529
    194 #define ibat1u  530
    195 #define ibat1l  531
    196 #define ibat2u  532
    197 #define ibat2l  533
    198 #define ibat3u  534
    199 #define ibat3l  535
    200 #define dbat0u  536
    201 #define dbat0l  537
    202 #define dbat1u  538
    203 #define dbat1l  539
    204 #define dbat2u  540
    205 #define dbat2l  541
    206 #define dbat3u  542
    207 #define dbat3l  543
    208192#define hid0    1008
    209193
Note: See TracChangeset for help on using the changeset viewer.