Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1145 → Rev 1146

/boot/trunk/arch/ppc32/loader/asm.S
112,9 → 112,10
# r4 = bootinfo_size
# r5 = trans (pa)
# r6 = kernel size
# r7 = real_mode (pa)
# r7 = framebuffer (pa)
# r8 = real_mode (pa)
mtspr srr0, r7
mtspr srr0, r8
# jumps to real_mode
135,6 → 136,7
#
# r5 = trans (pa)
# r6 = kernel size
# r7 = framebuffer (pa)
li r31, PAGE_SIZE >> 2
li r30, 0
229,7 → 231,7
lis r31, 0xf000
ori r31, r31, 0x0ffe
lis r30, 0x8400
mr r30, r7
ori r30, r30, 0x0002
mtspr dbat1u, r31
250,6 → 252,8
ori r31, r31, (msr_ir | msr_dr)@l
mtspr srr1, r31
sync
isync
rfi
 
.align PAGE_WIDTH
/boot/trunk/arch/ppc32/loader/ofw.h
52,7 → 52,7
} memmap_t;
 
typedef struct {
unsigned int addr;
void *addr;
unsigned int width;
unsigned int height;
unsigned int bpp;
/boot/trunk/arch/ppc32/loader/main.c
42,7 → 42,7
static void check_align(const void *addr, const char *desc)
{
if ((unsigned int) addr % PAGE_SIZE != 0) {
printf("Error: %s not on page boundary\n", desc);
printf("Error: %s not on page boundary, halting.\n", desc);
halt();
}
}
58,12 → 58,12
*top += PAGE_SIZE;
if (ofw_map(new_pa, new_va, PAGE_SIZE, 0) != 0) {
printf("Error: Unable to map page aligned memory at %L (physical %L)\n", new_va, new_pa);
printf("Error: Unable to map page aligned memory at %L (physical %L), halting.\n", new_va, new_pa);
halt();
}
if ((unsigned int) new_pa + PAGE_SIZE < KERNEL_SIZE) {
printf("Error: %s cannot be relocated\n", desc);
printf("Error: %s cannot be relocated, halting.\n", desc);
halt();
}
83,12 → 83,17
check_align(&trans, "Translation table");
if (!ofw_memmap(&bootinfo.memmap)) {
printf("Error: Unable to get memory map\n");
printf("Error: Unable to get memory map, halting.\n");
halt();
}
if (bootinfo.memmap.total == 0) {
printf("Error: No memory detected, halting.\n");
halt();
}
if (!ofw_screen(&bootinfo.screen)) {
printf("Error: Unable to get screen properties\n");
printf("Error: Unable to get screen properties, halting.\n");
halt();
}
98,6 → 103,7
void *real_mode_pa = ofw_translate(&real_mode);
void *trans_pa = ofw_translate(&trans);
void *bootinfo_pa = ofw_translate(&bootinfo);
void *fb = (void *) (((unsigned int) bootinfo.screen.addr) & ((unsigned int) ~0 << 17));
printf("\nMemory statistics (total %d MB)\n", bootinfo.memmap.total >> 20);
printf(" kernel image at %L (size %d bytes)\n", KERNEL_START, KERNEL_SIZE);
118,5 → 124,5
fix_overlap(&bootinfo, &bootinfo_pa, "Boot info", &top);
printf("\nBooting the kernel...\n");
jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, KERNEL_SIZE, real_mode_pa);
jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, KERNEL_SIZE, fb, real_mode_pa);
}
/boot/trunk/arch/ppc32/loader/asm.h
44,7 → 44,7
extern void *trans[TRANS_SIZE];
 
extern void halt();
extern void jump_to_kernel(void *bootinfo, unsigned int bootinfo_size, void *trans, unsigned int kernel_size, void *real_mode) __attribute__((noreturn));
extern void jump_to_kernel(void *bootinfo, unsigned int bootinfo_size, void *trans, unsigned int kernel_size, void *framebuffer, void *real_mode) __attribute__((noreturn));
extern void real_mode();
 
#endif
/boot/trunk/arch/ppc32/loader/ofw.c
31,7 → 31,7
#include "printf.h"
 
#define MAX_OFW_ARGS 10
#define STRING_SIZE 1024
#define BUF_SIZE 1024
 
typedef unsigned int ofw_arg_t;
typedef unsigned int ihandle;
53,12 → 53,14
ofw_entry ofw;
 
phandle ofw_chosen;
ihandle ofw_stdout;
phandle ofw_root;
ihandle ofw_mmu;
phandle ofw_memory;
phandle ofw_aliases;
ihandle ofw_mmu;
ihandle ofw_stdout;
 
 
static int ofw_call(const char *service, const int nargs, const int nret, ...)
static int ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
{
va_list list;
ofw_args_t args;
68,7 → 70,7
args.nargs = nargs;
args.nret = nret;
va_start(list, nret);
va_start(list, rets);
for (i = 0; i < nargs; i++)
args.args[i] = va_arg(list, ofw_arg_t);
va_end(list);
78,6 → 80,9
ofw(&args);
for (i = 1; i < nret; i++)
rets[i - 1] = args.args[i + nargs];
return args.args[nargs];
}
 
84,18 → 89,43
 
static phandle ofw_find_device(const char *name)
{
return ofw_call("finddevice", 1, 1, name);
return ofw_call("finddevice", 1, 1, NULL, name);
}
 
 
static int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
{
return ofw_call("getprop", 4, 1, device, name, buf, buflen);
return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
}
 
 
static unsigned int ofw_get_address_cells(const phandle device)
{
unsigned int ret;
if (ofw_get_property(device, "#address-cells", &ret, sizeof(ret)) <= 0)
if (ofw_get_property(ofw_root, "#address-cells", &ret, sizeof(ret)) <= 0)
ret = 1;
return ret;
}
 
 
static unsigned int ofw_get_size_cells(const phandle device)
{
unsigned int ret;
if (ofw_get_property(device, "#size-cells", &ret, sizeof(ret)) <= 0)
if (ofw_get_property(ofw_root, "#size-cells", &ret, sizeof(ret)) <= 0)
ret = 1;
return ret;
}
 
 
static ihandle ofw_open(const char *name)
{
return ofw_call("open", 1, 1, name);
return ofw_call("open", 1, 1, NULL, name);
}
 
 
105,20 → 135,31
if (ofw_chosen == -1)
halt();
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
ofw_stdout = 0;
ofw_aliases = ofw_find_device("/aliases");
if (ofw_aliases == -1) {
puts("\nUnable to find /aliases device\n");
ofw_root = ofw_find_device("/");
if (ofw_root == -1) {
puts("\r\nError: Unable to find / device, halted.\r\n");
halt();
}
ofw_mmu = ofw_open("/mmu");
if (ofw_mmu == -1) {
puts("\nUnable to open /mmu node\n");
if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, sizeof(ofw_mmu)) <= 0) {
puts("\r\nError: Unable to get mmu property, halted.\r\n");
halt();
}
ofw_memory = ofw_find_device("/memory");
if (ofw_memory == -1) {
puts("\r\nError: Unable to find /memory device, halted.\r\n");
halt();
}
ofw_aliases = ofw_find_device("/aliases");
if (ofw_aliases == -1) {
puts("\r\nError: Unable to find /aliases device, halted.\r\n");
halt();
}
}
 
 
127,42 → 168,51
if (ofw_stdout == 0)
return;
ofw_call("write", 3, 1, ofw_stdout, str, len);
ofw_call("write", 3, 1, NULL, ofw_stdout, str, len);
}
 
 
void *ofw_translate(const void *virt)
{
return (void *) ofw_call("call-method", 7, 1, "translate", ofw_mmu, virt, 0, 0, 0, 0);
ofw_arg_t result[3];
if (ofw_call("call-method", 4, 4, result, "translate", ofw_mmu, virt, 1) != 0) {
puts("Error: MMU method translate() failed, halting.\n");
halt();
}
return (void *) result[2];
}
 
 
int ofw_map(const void *phys, const void *virt, const int size, const int mode)
{
return ofw_call("call-method", 6, 1, "map", ofw_mmu, mode, size, virt, phys);
return ofw_call("call-method", 6, 1, NULL, "map", ofw_mmu, mode, size, virt, phys);
}
 
 
int ofw_memmap(memmap_t *map)
{
int i;
int ret;
 
phandle handle = ofw_find_device("/memory");
if (handle == -1)
unsigned int buf[BUF_SIZE];
int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(unsigned int) * BUF_SIZE);
if (ret <= 0)
return false;
unsigned int ac = ofw_get_address_cells(ofw_memory);
unsigned int sc = ofw_get_size_cells(ofw_memory);
ret = ofw_get_property(handle, "reg", &map->zones, sizeof(map->zones));
if (ret == -1)
return false;
int pos;
map->total = 0;
map->count = 0;
for (i = 0; i < MEMMAP_MAX_RECORDS; i++) {
if (map->zones[i].size == 0)
break;
map->count++;
map->total += map->zones[i].size;
for (pos = 0; (pos < ret / sizeof(unsigned int)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
void * start = (void *) buf[pos + ac - 1];
unsigned int size = buf[pos + ac + sc - 1];
if (size > 0) {
map->zones[map->count].start = start;
map->zones[map->count].size = size;
map->count++;
map->total += size;
}
}
}
 
169,9 → 219,9
 
int ofw_screen(screen_t *screen)
{
char device_name[STRING_SIZE];
char device_name[BUF_SIZE];
if (ofw_get_property(ofw_aliases, "screen", device_name, STRING_SIZE) <= 0)
if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(char) * BUF_SIZE) <= 0)
return false;
phandle device = ofw_find_device(device_name);