Changeset 6bbb1610 in mainline
- Timestamp:
- 2006-05-21T20:13:14Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 433a2aa
- Parents:
- 0ab829c
- Location:
- arch/ppc64
- Files:
-
- 1 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ppc64/Makefile.inc
r0ab829c r6bbb1610 29 29 build: image.boot 30 30 31 image.boot: kernel 32 make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNEL =../../../$(KERNELDIR)/kernel.bin31 image.boot: kernel uspace 32 make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) 33 33 cp arch/$(ARCH)/loader/image.boot image.boot 34 34 35 clean: clean_kernel 36 make -C arch/$(ARCH)/loader clean 35 clean: clean_kernel clean_uspace 36 make -C arch/$(ARCH)/loader clean KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) 37 37 -rm -f image.boot 38 38 39 arch_distclean: distclean_kernel 39 arch_distclean: distclean_kernel distclean_uspace -
arch/ppc64/loader/Makefile
r0ab829c r6bbb1610 31 31 32 32 TARGET = ppc-linux-gnu 33 TOOLCHAIN_DIR = /usr/local/ppc /bin33 TOOLCHAIN_DIR = /usr/local/ppc64/bin 34 34 35 35 ifeq ($(COMPILER),native) … … 47 47 endif 48 48 49 CFLAGS = -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=powerpc64 -m 6449 CFLAGS = -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=powerpc64 -msoft-float -m64 50 50 DEFS = 51 51 … … 57 57 boot.S 58 58 59 COMPONENTS = \ 60 $(KERNELDIR)/kernel.bin \ 61 $(USPACEDIR)/ns/ns \ 62 $(USPACEDIR)/init/init \ 63 $(USPACEDIR)/fb/fb 64 59 65 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 66 COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS)))) 60 67 61 68 .PHONY: all clean depend … … 65 72 -include Makefile.depend 66 73 67 image.boot: depend $(OBJECTS) kernel.o68 $(LD) -no-check-sections -N -T _link.ld $( OBJECTS) kernel.o-o $@74 image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) kernel.o 75 $(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@ 69 76 70 77 depend: … … 72 79 73 80 clean: 74 -rm -f $(OBJECTS) image.boot kernel.oMakefile.depend81 -rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend 75 82 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) 78 85 79 86 %.o: %.S -
arch/ppc64/loader/asm.S
r0ab829c r6bbb1610 107 107 # r4 = bootinfo_size 108 108 # 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 114 121 115 122 # jumps to real_mode … … 125 132 rfid 126 133 127 .section REALMODE 134 .section REALMODE, "ax" 128 135 .align PAGE_WIDTH 129 136 .global real_mode … … 134 141 # 135 142 # r5 = trans (pa) 136 # r6 = kernel size 137 # r7 = framebuffer (pa) 143 # r6 = bytes to copy 138 144 139 145 li r31, PAGE_SIZE >> 2 … … 169 175 copy_end: 170 176 171 # in validatesegment registers177 # initially fill segment registers 172 178 173 179 li r31, 16 174 180 mtctr r31 175 181 li r31, 0 176 li r30, 0 182 li r30, 0x2000 177 183 178 184 seg_fill: 179 185 180 186 mtsrin r30, r31 187 addi r30, r30, 0x111 181 188 addis r31, r31, 0x1000 # move to next SR 182 189 183 190 bdnz seg_fill 184 191 185 # invalidate block address translation registers186 187 mtspr ibat0u, r30188 mtspr ibat0l, r30189 190 mtspr ibat1u, r30191 mtspr ibat1l, r30192 193 mtspr ibat2u, r30194 mtspr ibat2l, r30195 196 mtspr ibat3u, r30197 mtspr ibat3l, r30198 199 mtspr dbat0u, r30200 mtspr dbat0l, r30201 202 mtspr dbat1u, r30203 mtspr dbat1l, r30204 205 mtspr dbat2u, r30206 mtspr dbat2l, r30207 208 mtspr dbat3u, r30209 mtspr dbat3l, r30210 211 # create identity mapping212 213 # FIXME: map exactly the size of RAM214 215 lis r31, 0x8000216 ori r31, r31, 0x0ffe217 218 lis r30, 0x0000219 ori r30, r30, 0x0002220 221 mtspr ibat0u, r31222 mtspr ibat0l, r30223 224 mtspr dbat0u, r31225 mtspr dbat0l, r30226 227 # FIXME: temporal framebuffer mapping228 229 lis r31, 0xf000230 ori r31, r31, 0x0ffe231 232 mr r30, r7233 ori r30, r30, 0x0002234 235 mtspr dbat1u, r31236 mtspr dbat1l, r30237 238 192 tlbia 193 tlbsync 239 194 240 195 # start the kernel -
arch/ppc64/loader/asm.h
r0ab829c r6bbb1610 34 34 35 35 #define TRANS_SIZE 1024 36 #define TRANS_ITEM_SIZE 436 #define TRANS_ITEM_SIZE 8 37 37 38 38 #define KERNEL_START_ADDR 0x80004000 … … 45 45 46 46 extern 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));47 extern void jump_to_kernel(void *bootinfo, unsigned long bootinfo_size, void *trans, unsigned long kernel_size, void *real_mode) __attribute__((noreturn)); 48 48 extern void real_mode(); 49 49 -
arch/ppc64/loader/boot.S
r0ab829c r6bbb1610 29 29 #include "regname.h" 30 30 31 .section BOOTSTRAP 31 .section BOOTSTRAP, "ax" 32 32 33 33 .global start -
arch/ppc64/loader/main.c
r0ab829c r6bbb1610 30 30 #include "printf.h" 31 31 #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" 36 33 37 34 #define HEAP_GAP 1024000 … … 77 74 void bootstrap(void) 78 75 { 79 printf("\nHelenOS PPC 64Bootloader\n");76 printf("\nHelenOS PPC Bootloader\n"); 80 77 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"); 84 87 85 88 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"); 87 90 halt(); 88 91 } 89 92 90 93 if (bootinfo.memmap.total == 0) { 91 printf("Error: No memory detected, halting.\n");94 printf("Error: no memory detected, halting.\n"); 92 95 halt(); 93 96 } 94 97 95 98 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"); 97 100 halt(); 98 101 } … … 104 107 void *trans_pa = ofw_translate(&trans); 105 108 void *bootinfo_pa = ofw_translate(&bootinfo); 106 void *fb = (void *) (((unsigned long) bootinfo.screen.addr) & ((unsigned long) ~0 << 17));107 109 108 110 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); 113 116 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; 120 127 } 121 128 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); 125 151 126 152 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); 128 154 } -
arch/ppc64/loader/main.h
r0ab829c r6bbb1610 39 39 #define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1)) 40 40 41 #define TASKMAP_MAX_RECORDS 32 42 41 43 typedef struct { 44 void *addr; 45 unsigned long size; 46 } task_t; 47 48 typedef struct { 49 unsigned int count; 50 task_t tasks[TASKMAP_MAX_RECORDS]; 51 } taskmap_t; 52 53 typedef struct { 54 taskmap_t taskmap; 42 55 memmap_t memmap; 43 56 screen_t screen; 44 57 } bootinfo_t; 45 58 46 extern long _binary_____________kernel_kernel_bin_start;47 extern long _binary_____________kernel_kernel_bin_end;48 59 extern void start(void); 49 60 extern void bootstrap(void); -
arch/ppc64/loader/ofw.c
r0ab829c r6bbb1610 34 34 #define BUF_SIZE 1024 35 35 36 typedef unsigned longofw_arg_t;37 typedef unsigned longihandle;38 typedef unsigned longphandle;36 typedef unsigned int ofw_arg_t; 37 typedef unsigned int ihandle; 38 typedef unsigned int phandle; 39 39 40 40 /** OpenFirmware command structure … … 43 43 typedef struct { 44 44 const char *service; /**< Command name */ 45 unsigned longnargs; /**< Number of in arguments */46 unsigned longnret; /**< Number of out arguments */45 unsigned int nargs; /**< Number of in arguments */ 46 unsigned int nret; /**< Number of out arguments */ 47 47 ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */ 48 48 } ofw_args_t; … … 61 61 62 62 63 static long ofw_call(const char *service, const long nargs, const longnret, ofw_arg_t *rets, ...)63 static int ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...) 64 64 { 65 65 va_list list; 66 66 ofw_args_t args; 67 longi;67 int i; 68 68 69 69 args.service = service; … … 94 94 95 95 96 static long ofw_get_property(const phandle device, const char *name, const void *buf, const longbuflen)96 static int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen) 97 97 { 98 98 return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen); … … 100 100 101 101 102 static unsigned longofw_get_address_cells(const phandle device)103 { 104 unsigned longret;102 static unsigned int ofw_get_address_cells(const phandle device) 103 { 104 unsigned int ret; 105 105 106 106 if (ofw_get_property(device, "#address-cells", &ret, sizeof(ret)) <= 0) … … 112 112 113 113 114 static unsigned longofw_get_size_cells(const phandle device)115 { 116 unsigned longret;114 static unsigned int ofw_get_size_cells(const phandle device) 115 { 116 unsigned int ret; 117 117 118 118 if (ofw_get_property(device, "#size-cells", &ret, sizeof(ret)) <= 0) … … 185 185 186 186 187 long ofw_map(const void *phys, const void *virt, const long size, const longmode)187 int ofw_map(const void *phys, const void *virt, const int size, const int mode) 188 188 { 189 189 return ofw_call("call-method", 6, 1, NULL, "map", ofw_mmu, mode, size, virt, phys); … … 191 191 192 192 193 longofw_memmap(memmap_t *map)194 { 195 unsigned longbuf[BUF_SIZE];196 long ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(unsigned long) * BUF_SIZE);193 int 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); 197 197 if (ret <= 0) 198 198 return false; 199 199 200 unsigned longac = ofw_get_address_cells(ofw_memory);201 unsigned longsc = ofw_get_size_cells(ofw_memory);202 203 longpos;200 unsigned int ac = ofw_get_address_cells(ofw_memory); 201 unsigned int sc = ofw_get_size_cells(ofw_memory); 202 203 int pos; 204 204 map->total = 0; 205 205 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) { 207 207 void * start = (void *) buf[pos + ac - 1]; 208 unsigned longsize = buf[pos + ac + sc - 1];208 unsigned int size = buf[pos + ac + sc - 1]; 209 209 210 210 if (size > 0) { … … 218 218 219 219 220 longofw_screen(screen_t *screen)220 int ofw_screen(screen_t *screen) 221 221 { 222 222 char device_name[BUF_SIZE]; -
arch/ppc64/loader/ofw.h
r0ab829c r6bbb1610 48 48 typedef struct { 49 49 unsigned long total; 50 unsigned longcount;50 unsigned int count; 51 51 memzone_t zones[MEMMAP_MAX_RECORDS]; 52 52 } memmap_t; … … 54 54 typedef struct { 55 55 void *addr; 56 unsigned longwidth;57 unsigned longheight;58 unsigned longbpp;59 unsigned longscanline;56 unsigned int width; 57 unsigned int height; 58 unsigned int bpp; 59 unsigned int scanline; 60 60 } screen_t; 61 61 … … 65 65 66 66 extern void *ofw_translate(const void *virt); 67 extern long ofw_map(const void *phys, const void *virt, const long size, const longmode);68 extern longofw_memmap(memmap_t *map);69 extern longofw_screen(screen_t *screen);67 extern int ofw_map(const void *phys, const void *virt, const long size, const int mode); 68 extern int ofw_memmap(memmap_t *map); 69 extern int ofw_screen(screen_t *screen); 70 70 71 71 #endif -
arch/ppc64/loader/regname.h
r0ab829c r6bbb1610 27 27 */ 28 28 29 #ifndef __ppc 64_REGNAME_H__30 #define __ppc 64_REGNAME_H__29 #ifndef __ppc32_REGNAME_H__ 30 #define __ppc32_REGNAME_H__ 31 31 32 32 /* Condition Register Bit Fields */ … … 190 190 #define sprg3 275 191 191 #define prv 287 192 #define ibat0u 528193 #define ibat0l 529194 #define ibat1u 530195 #define ibat1l 531196 #define ibat2u 532197 #define ibat2l 533198 #define ibat3u 534199 #define ibat3l 535200 #define dbat0u 536201 #define dbat0l 537202 #define dbat1u 538203 #define dbat1l 539204 #define dbat2u 540205 #define dbat2l 541206 #define dbat3u 542207 #define dbat3l 543208 192 #define hid0 1008 209 193
Note:
See TracChangeset
for help on using the changeset viewer.