Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1369 → Rev 1368

/boot/trunk/arch/ppc32/loader/pack
File deleted
Property changes:
Deleted: svn:executable
-*
\ No newline at end of property
/boot/trunk/arch/ppc32/loader/Makefile
56,14 → 56,7
asm.S \
boot.S
 
COMPONENTS = \
$(KERNELDIR)/kernel.bin \
$(USPACEDIR)/ns/ns \
$(USPACEDIR)/init/init \
$(USPACEDIR)/fb/fb
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
 
.PHONY: all clean depend
 
71,18 → 64,21
 
-include Makefile.depend
 
image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) kernel.o
$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
image.boot: depend $(OBJECTS) kernel.o init.o
$(LD) -no-check-sections -N -T _link.ld $(OBJECTS) kernel.o init.o -o $@
 
depend:
-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null
 
clean:
-rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
-rm -f $(OBJECTS) image.boot kernel.o init.o Makefile.depend
 
_components.h _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
./pack $(OBJCOPY) $(COMPONENTS)
kernel.o: $(KERNEL)
$(OBJCOPY) -I binary -O elf32-powerpc -B powerpc:common --rename-section .data=.kernel_image $(KERNEL) $@
 
init.o: $(INIT)
$(OBJCOPY) -I binary -O elf32-powerpc -B powerpc:common --rename-section .data=.init_image $(INIT) $@
 
%.o: %.S
$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
 
/boot/trunk/arch/ppc32/loader/main.c
29,8 → 29,15
#include "main.h"
#include "printf.h"
#include "asm.h"
#include "_components.h"
 
#define KERNEL_START ((void *) &_binary_____________kernel_kernel_bin_start)
#define KERNEL_END ((void *) &_binary_____________kernel_kernel_bin_end)
#define KERNEL_SIZE ((unsigned int) KERNEL_END - (unsigned int) KERNEL_START)
 
#define INIT_START ((void *) &_binary_____________uspace_init_init_start)
#define INIT_END ((void *) &_binary_____________uspace_init_init_end)
#define INIT_SIZE ((unsigned int) INIT_END - (unsigned int) INIT_START)
 
#define HEAP_GAP 1024000
 
bootinfo_t bootinfo;
75,28 → 82,23
{
printf("\nHelenOS PPC Bootloader\n");
init_components();
check_align(KERNEL_START, "Kernel image");
check_align(INIT_START, "Init image");
check_align(&real_mode, "Bootstrap trampoline");
check_align(&trans, "Translation table");
unsigned int i;
for (i = 0; i < COMPONENTS; i++)
check_align(components[i].start, components[i].name);
check_align(&real_mode, "bootstrap trampoline");
check_align(&trans, "translation table");
if (!ofw_memmap(&bootinfo.memmap)) {
printf("Error: unable to get memory map, halting.\n");
printf("Error: Unable to get memory map, halting.\n");
halt();
}
if (bootinfo.memmap.total == 0) {
printf("Error: no memory detected, halting.\n");
printf("Error: No memory detected, halting.\n");
halt();
}
if (!ofw_screen(&bootinfo.screen)) {
printf("Error: unable to get screen properties, halting.\n");
printf("Error: Unable to get screen properties, halting.\n");
halt();
}
109,47 → 111,38
void *fb = (void *) (((unsigned int) bootinfo.screen.addr) & ((unsigned int) ~0 << 17));
printf("\nMemory statistics (total %d MB)\n", bootinfo.memmap.total >> 20);
printf(" %L: boot info structure (physical %L)\n", &bootinfo, bootinfo_pa);
printf(" %L: bootstrap trampoline (physical %L)\n", &real_mode, real_mode_pa);
printf(" %L: translation table (physical %L)\n", &trans, trans_pa);
for (i = 0; i < COMPONENTS; i++)
printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
printf(" kernel image at %L (size %d bytes)\n", KERNEL_START, KERNEL_SIZE);
printf(" init image at %L (size %d bytes)\n", INIT_START, INIT_SIZE);
printf(" boot info structure at %L (physical %L)\n", &bootinfo, bootinfo_pa);
printf(" bootstrap trampoline at %L (physical %L)\n", &real_mode, real_mode_pa);
printf(" translation table at %L (physical %L)\n", &trans, trans_pa);
unsigned int top = 0;
for (i = 0; i < COMPONENTS; i++)
top += ALIGN_UP(components[i].size, PAGE_SIZE);
unsigned int top = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE) + ALIGN_UP(INIT_SIZE, PAGE_SIZE);
unsigned int kernel_pages = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE) >> PAGE_WIDTH;
unsigned int init_pages = ALIGN_UP(INIT_SIZE, PAGE_SIZE) >> PAGE_WIDTH;
unsigned int pages = ALIGN_UP(KERNEL_SIZE, PAGE_SIZE) >> PAGE_WIDTH;
unsigned int i;
for (i = 0; i < pages; i++) {
for (i = 0; i < kernel_pages; i++) {
void *pa = ofw_translate(KERNEL_START + (i << PAGE_WIDTH));
fix_overlap(KERNEL_START + (i << PAGE_WIDTH), &pa, "kernel", &top);
fix_overlap(KERNEL_START + (i << PAGE_WIDTH), &pa, "Kernel image", &top);
trans[i] = pa;
}
bootinfo.taskmap.count = 0;
for (i = 1; i < COMPONENTS; i++) {
unsigned int component_pages = ALIGN_UP(components[i].size, PAGE_SIZE) >> PAGE_WIDTH;
unsigned int j;
for (j = 0; j < component_pages; j++) {
void *pa = ofw_translate(components[i].start + (j << PAGE_WIDTH));
fix_overlap(components[i].start + (j << PAGE_WIDTH), &pa, components[i].name, &top);
trans[pages + j] = pa;
if (j == 0) {
bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = (void *) (pages << PAGE_WIDTH);
bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = components[i].size;
bootinfo.taskmap.count++;
}
for (i = 0; i < init_pages; i++) {
void *pa = ofw_translate(INIT_START + (i << PAGE_WIDTH));
fix_overlap(INIT_START + (i << PAGE_WIDTH), &pa, "Init image", &top);
trans[kernel_pages + i] = pa;
if (i == 0) {
bootinfo.init.addr = (void *) ((kernel_pages + i) << PAGE_WIDTH);
bootinfo.init.size = INIT_SIZE;
}
pages += component_pages;
}
fix_overlap(&real_mode, &real_mode_pa, "bootstrap trampoline", &top);
fix_overlap(&trans, &trans_pa, "translation table", &top);
fix_overlap(&bootinfo, &bootinfo_pa, "boot info", &top);
fix_overlap(&real_mode, &real_mode_pa, "Bootstrap trampoline", &top);
fix_overlap(&trans, &trans_pa, "Translation table", &top);
fix_overlap(&bootinfo, &bootinfo_pa, "Boot info", &top);
printf("\nBooting the kernel...\n");
jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, fb, real_mode_pa);
jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, (kernel_pages + init_pages) << PAGE_WIDTH, fb, real_mode_pa);
}
/boot/trunk/arch/ppc32/loader/_link.ld
0,0 → 1,31
/*
* PPC linker script
*
*/
 
OUTPUT_FORMAT("elf32-powerpc")
OUTPUT_ARCH(powerpc:common)
ENTRY(start)
 
SECTIONS {
.boot 0x10000000: AT (0) {
*(BOOTSTRAP);
*(REALMODE);
*(.text);
*(.rodata);
*(.rodata.*);
*(.data); /* initialized data */
*(.sdata);
*(.sdata2);
*(.sbss);
*(.bss); /* uninitialized static variables */
*(COMMON); /* global variables */
. = ALIGN(4096);
*(.kernel_image);
. = ALIGN(4096);
*(.init_image);
}
}
/boot/trunk/arch/ppc32/loader/main.h
38,24 → 38,23
*/
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
 
#define TASKMAP_MAX_RECORDS 32
 
typedef struct {
void *addr;
unsigned int size;
} task_t;
} utask_t;
 
typedef struct {
unsigned int count;
task_t tasks[TASKMAP_MAX_RECORDS];
} taskmap_t;
 
typedef struct {
taskmap_t taskmap;
utask_t init;
memmap_t memmap;
screen_t screen;
} bootinfo_t;
 
extern int _binary_____________kernel_kernel_bin_start;
extern int _binary_____________kernel_kernel_bin_end;
 
extern int _binary_____________uspace_init_init_start;
extern int _binary_____________uspace_init_init_end;
 
extern void start(void);
extern void bootstrap(void);
 
/boot/trunk/arch/ppc32/Makefile.inc
29,11 → 29,11
build: image.boot
 
image.boot: kernel uspace
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNEL=../../../$(KERNELDIR)/kernel.bin INIT=../../../$(USPACEDIR)/init/init
cp arch/$(ARCH)/loader/image.boot image.boot
 
clean: clean_kernel clean_uspace
make -C arch/$(ARCH)/loader clean KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR)
make -C arch/$(ARCH)/loader clean
-rm -f image.boot
 
arch_distclean: distclean_kernel distclean_uspace