Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1788 → Rev 1789

/trunk/boot/genarch/ofw.h
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __OFW_H__
#define __OFW_H__
#ifndef BOOT_OFW_H_
#define BOOT_OFW_H_
 
#include <types.h>
#include <stdarg.h>
38,7 → 38,7
 
#define MAX_OFW_ARGS 12
 
typedef unsigned long ofw_arg_t;
typedef unative_t ofw_arg_t;
typedef unsigned int ihandle;
typedef unsigned int phandle;
 
64,7 → 64,7
} memmap_t;
 
typedef struct {
uint32_t addr;
void *addr;
unsigned int width;
unsigned int height;
unsigned int bpp;
72,7 → 72,7
} screen_t;
 
typedef struct {
uint32_t addr;
void *addr;
unsigned int size;
} keyboard_t;
 
92,7 → 92,7
 
extern phandle ofw_aliases;
 
extern void init(void);
extern void ofw_init(void);
extern void ofw_write(const char *str, const int len);
 
extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen);
99,6 → 99,8
extern phandle ofw_find_device(const char *name);
 
extern int ofw(ofw_args_t *arg);
extern unsigned int ofw_get_address_cells(const phandle device);
extern unsigned int ofw_get_size_cells(const phandle device);
extern void *ofw_translate(const void *virt);
extern int ofw_translate_failed(ofw_arg_t flag);
extern void *ofw_claim(const void *virt, const int len);
/trunk/boot/genarch/ofw.c
26,7 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ofw.h"
#include <ofw.h>
#include <ofwarch.h>
#include <printf.h>
#include <asm.h>
#include <types.h>
40,6 → 41,40
phandle ofw_memory;
phandle ofw_aliases;
 
void ofw_init(void)
{
ofw_chosen = ofw_find_device("/chosen");
if (ofw_chosen == -1)
halt();
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
ofw_stdout = 0;
ofw_root = ofw_find_device("/");
if (ofw_root == -1) {
puts("\r\nError: Unable to find / device, halted.\r\n");
halt();
}
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();
}
}
 
 
static unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
{
va_list list;
79,25 → 114,25
}
 
 
static unsigned int ofw_get_address_cells(const phandle device)
unsigned int ofw_get_address_cells(const phandle device)
{
unsigned int ret;
unsigned int ret = 1;
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;
ret = OFW_ADDRESS_CELLS;
return ret;
}
 
 
static unsigned int ofw_get_size_cells(const phandle device)
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;
ret = OFW_SIZE_CELLS;
return ret;
}
109,40 → 144,6
}
 
 
void init(void)
{
ofw_chosen = ofw_find_device("/chosen");
if (ofw_chosen == -1)
halt();
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
ofw_stdout = 0;
ofw_root = ofw_find_device("/");
if (ofw_root == -1) {
puts("\r\nError: Unable to find / device, halted.\r\n");
halt();
}
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();
}
}
 
 
void ofw_write(const char *str, const int len)
{
if (ofw_stdout == 0)
169,7 → 170,7
shift = 32;
else
shift = 0;
 
return (void *) ((result[2]<<shift)|result[3]);
}
 
206,19 → 207,19
 
int ofw_memmap(memmap_t *map)
{
unsigned long buf[BUF_SIZE];
unsigned int ac = ofw_get_address_cells(ofw_memory);
unsigned int sc = ofw_get_size_cells(ofw_memory);
 
uint32_t buf[((ac+sc)*MEMMAP_MAX_RECORDS)];
int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
if (ret <= 0)
if (ret <= 0) /* ret is the number of written bytes */
return false;
unsigned int ac = ofw_get_address_cells(ofw_memory);
unsigned int sc = ofw_get_size_cells(ofw_memory);
 
int pos;
map->total = 0;
map->count = 0;
for (pos = 0; (pos < ret / sizeof(unsigned long)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
void * start = (void *) buf[pos + ac - 1];
for (pos = 0; (pos < ret / sizeof(uint32_t)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
void * start = (void *) ((uintptr_t) buf[pos + ac - 1]);
unsigned int size = buf[pos + ac + sc - 1];
if (size > 0) {
228,6 → 229,8
map->total += size;
}
}
return true;
}
 
 
234,6 → 237,7
int ofw_screen(screen_t *screen)
{
char device_name[BUF_SIZE];
uint32_t virtaddr;
if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0)
return false;
242,9 → 246,11
if (device == -1)
return false;
if (ofw_get_property(device, "address", &screen->addr, sizeof(screen->addr)) <= 0)
if (ofw_get_property(device, "address", &virtaddr, sizeof(virtaddr)) <= 0)
return false;
 
screen->addr = (void *) ((uintptr_t) virtaddr);
 
if (ofw_get_property(device, "width", &screen->width, sizeof(screen->width)) <= 0)
return false;
/trunk/boot/generic/align.h
0,0 → 1,39
/*
* Copyright (C) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef BOOT_ALIGN_H_
#define BOOT_ALIGN_H_
 
/** Align to the nearest higher address.
*
* @param addr Address or size to be aligned.
* @param align Size of alignment, must be power of 2.
*/
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
 
#endif
/trunk/boot/generic/gentypes.h
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef GENTYPES_H__
#define GENTYPES_H__
#ifndef BOOT_GENTYPES_H_
#define BOOT_GENTYPES_H_
 
#define NULL 0
#define false 0
/trunk/boot/generic/printf.h
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef PRINTF_H__
#define PRINTF_H__
#ifndef BOOT_PRINTF_H_
#define BOOT_PRINTF_H_
 
#define INT8 1
#define INT16 2
/trunk/boot/arch/sparc64/loader/ofw.c
File deleted
/trunk/boot/arch/sparc64/loader/ofwarch.h
0,0 → 1,35
/*
* Copyright (C) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef BOOT_sparc64_OFWARCH_H_
#define BOOT_sparc64_OFWARCH_H_
 
#define OFW_ADDRESS_CELLS 2
#define OFW_SIZE_CELLS 2
 
#endif
/trunk/boot/arch/sparc64/loader/boot.S
29,6 → 29,7
#define INITIAL_STACK 0x0
 
#define PSTATE_IE_BIT 2
#define PSTATE_AM_BIT 8
 
.register %g2, #scratch
.register %g3, #scratch
55,10 → 56,10
flushw
 
/*
* Disable interrupts.
* Disable interrupts and disable address masking.
*/
rdpr %pstate, %g2
and %g2, ~PSTATE_IE_BIT, %g2 ! mask the Interrupt Enable bit
and %g2, ~(PSTATE_IE_BIT|PSTATE_AM_BIT), %g2
wrpr %g2, 0, %pstate
 
# TODO: set initial stack
65,7 → 66,7
 
set ofw_cif, %l0
call init ! initialize OpenFirmware
call ofw_init ! initialize OpenFirmware
stx %o4, [%l0]
b bootstrap
/trunk/boot/arch/sparc64/loader/main.c
31,6 → 31,7
#include "asm.h"
#include "_components.h"
#include <ofw.h>
#include <align.h>
 
#define KERNEL_VIRTUAL_ADDRESS 0x400000
 
43,13 → 44,39
component_t components[COMPONENTS];
init_components(components);
 
if (!ofw_memmap(&bootinfo.memmap)) {
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, halting.\n");
halt();
}
bootinfo.screen.addr = ofw_translate(bootinfo.screen.addr);
if (!ofw_keyboard(&bootinfo.keyboard)) {
printf("Error: unable to get keyboard properties, halting.\n");
halt();
}
printf("\nDevice statistics\n");
printf(" memory: %dM\n", bootinfo.memmap.total>>20);
printf(" screen at %P, resolution %dx%d, %d bpp (scanline %d bytes)\n", (uintptr_t) bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
printf(" keyboard at %P (size %d bytes)\n", (uintptr_t) bootinfo.keyboard.addr, bootinfo.keyboard.size);
 
printf("\nMemory statistics\n");
printf(" kernel entry point at %L\n", KERNEL_VIRTUAL_ADDRESS);
printf(" %L: boot info structure\n", &bootinfo);
printf(" kernel entry point at %P\n", KERNEL_VIRTUAL_ADDRESS);
printf(" %P: boot info structure\n", &bootinfo);
unsigned int i;
for (i = 0; i < COMPONENTS; i++)
printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
printf(" %P: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
 
printf("\nCopying components\n");
unsigned int top = 0;
/trunk/boot/arch/sparc64/loader/asm.h
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __ASM_H__
#define __ASM_H__
#ifndef BOOT_sparc64_ASM_H_
#define BOOT_sparc64_ASM_H_
 
#define PAGE_SIZE 8192
#define PAGE_WIDTH 13
/trunk/boot/arch/sparc64/loader/main.h
26,15 → 26,10
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __MAIN_H__
#define __MAIN_H__
#ifndef BOOT_sparc64_MAIN_H_
#define BOOT_sparc64_MAIN_H_
 
/** Align to the nearest higher address.
*
* @param addr Address or size to be aligned.
* @param align Size of alignment, must be power of 2.
*/
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
#include <ofw.h>
 
#define TASKMAP_MAX_RECORDS 32
 
46,6 → 41,9
typedef struct {
unsigned int cnt;
task_t tasks[TASKMAP_MAX_RECORDS];
memmap_t memmap;
screen_t screen;
keyboard_t keyboard;
} bootinfo_t;
 
extern void start(void);
/trunk/boot/arch/sparc64/loader/types.h
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef TYPES_H__
#define TYPES_H__
#ifndef BOOT_sparc64_TYPES_H_
#define BOOT_sparc64_TYPES_H_
 
#include <gentypes.h>
 
/trunk/boot/arch/sparc64/loader/ofwarch.c
0,0 → 1,73
/*
* Copyright (C) 2005 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/**
* @file
* @brief Architecture dependent parts of OpenFirmware interface.
*/
 
#include <ofwarch.h>
#include <ofw.h>
#include <printf.h>
 
void write(const char *str, const int len)
{
int i;
for (i = 0; i < len; i++) {
if (str[i] == '\n')
ofw_write("\r", 1);
ofw_write(&str[i], 1);
}
}
 
int ofw_translate_failed(ofw_arg_t flag)
{
return flag != -1;
}
 
int ofw_keyboard(keyboard_t *keyboard)
{
char device_name[BUF_SIZE];
uint32_t virtaddr;
if (ofw_get_property(ofw_aliases, "keyboard", device_name, sizeof(device_name)) <= 0)
return false;
phandle device = ofw_find_device(device_name);
if (device == -1)
return false;
if (ofw_get_property(device, "address", &virtaddr, sizeof(virtaddr)) <= 0)
return false;
if (!(keyboard->addr = ofw_translate((void *) ((uintptr_t) virtaddr))))
return false;
 
return true;
}
/trunk/boot/arch/sparc64/loader/Makefile
52,7 → 52,7
main.c \
../../../generic/printf.c \
../../../genarch/ofw.c \
ofw.c \
ofwarch.c \
asm.S \
boot.S
 
64,7 → 64,7
 
.PHONY: all clean depend
 
all: image.boot
all: image.boot disasm
 
-include Makefile.depend
 
85,3 → 85,6
 
%.o: %.c
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
 
disasm: image.boot
$(OBJDUMP) -d image.boot > boot.disasm
/trunk/boot/arch/ppc32/loader/ofw.c
File deleted
/trunk/boot/arch/ppc32/loader/ofwarch.h
0,0 → 1,35
/*
* Copyright (C) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef BOOT_ppc32_OFWARCH_H_
#define BOOT_ppc32_OFWARCH_H_
 
#define OFW_ADDRESS_CELLS 1
#define OFW_SIZE_CELLS 1
 
#endif
/trunk/boot/arch/ppc32/loader/boot.S
37,6 → 37,6
addi r4, r4, ofw_cif@l
stw r5, 0(r4)
bl init
bl ofw_init
b bootstrap
/trunk/boot/arch/ppc32/loader/main.c
30,6 → 30,8
#include <printf.h>
#include "asm.h"
#include "_components.h"
#include <ofw.h>
#include <align.h>
 
#define HEAP_GAP 1024000
 
/trunk/boot/arch/ppc32/loader/asm.h
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __ASM_H__
#define __ASM_H__
#ifndef BOOT_ppc32_ASM_H_
#define BOOT_ppc32_ASM_H_
 
#define PAGE_SIZE 4096
#define PAGE_WIDTH 12
/trunk/boot/arch/ppc32/loader/main.h
26,18 → 26,11
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __MAIN_H__
#define __MAIN_H__
#ifndef BOOT_ppc32_MAIN_H_
#define BOOT_ppc32_MAIN_H_
 
#include "ofw.h"
 
/** Align to the nearest higher address.
*
* @param addr Address or size to be aligned.
* @param align Size of alignment, must be power of 2.
*/
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
 
#define TASKMAP_MAX_RECORDS 32
 
typedef struct {
/trunk/boot/arch/ppc32/loader/types.h
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef TYPES_H__
#define TYPES_H__
#ifndef BOOT_ppc32_TYPES_H_
#define BOOT_ppc32_TYPES_H_
 
#include <gentypes.h>
 
/trunk/boot/arch/ppc32/loader/ofwarch.c
0,0 → 1,68
/*
* Copyright (C) 2005 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <ofwarch.h>
#include <ofw.h>
#include <printf.h>
 
typedef int (* ofw_entry_t)(ofw_args_t *args);
 
int ofw(ofw_args_t *args)
{
return ((ofw_entry_t) ofw_cif)(args);
}
 
void write(const char *str, const int len)
{
ofw_write(str, len);
}
 
int ofw_keyboard(keyboard_t *keyboard)
{
char device_name[BUF_SIZE];
if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
return false;
phandle device = ofw_find_device(device_name);
if (device == -1)
return false;
pci_reg_t macio;
if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
return false;
keyboard->addr = (void *) macio.addr.addr_lo;
keyboard->size = macio.size_lo;
 
return true;
}
 
int ofw_translate_failed(ofw_arg_t flag)
{
return 0;
}
/trunk/boot/arch/ppc32/loader/Makefile
50,7 → 50,7
 
SOURCES = \
main.c \
ofw.c \
ofwarch.c \
../../../genarch/ofw.c \
../../../generic/printf.c \
asm.S \
/trunk/boot/arch/ppc64/loader/ofw.c
File deleted
/trunk/boot/arch/ppc64/loader/ofwarch.h
0,0 → 1,35
/*
* Copyright (C) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef BOOT_ppc64_OFWARCH_H_
#define BOOT_ppc64_OFWARCH_H_
 
#define OFW_ADDRESS_CELLS 2
#define OFW_SIZE_CELLS 2
 
#endif
/trunk/boot/arch/ppc64/loader/boot.S
37,6 → 37,6
addi r4, r4, ofw_cif@l
stw r5, 0(r4)
bl init
bl ofw_init
b bootstrap
/trunk/boot/arch/ppc64/loader/main.c
30,6 → 30,7
#include <printf.h>
#include "asm.h"
#include "_components.h"
#include <ofw.h>
 
#define HEAP_GAP 1024000
 
/trunk/boot/arch/ppc64/loader/main.h
26,18 → 26,11
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __MAIN_H__
#define __MAIN_H__
#ifndef BOOT_ppc64_MAIN_H_
#define BOOT_ppc64_MAIN_H_
 
#include "ofw.h"
#include <ofw.h>
 
/** Align to the nearest higher address.
*
* @param addr Address or size to be aligned.
* @param align Size of alignment, must be power of 2.
*/
#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
 
#define TASKMAP_MAX_RECORDS 32
 
typedef struct {
/trunk/boot/arch/ppc64/loader/types.h
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef TYPES_H__
#define TYPES_H__
#ifndef BOOT_ppc64_TYPES_H_
#define BOOT_ppc64_TYPES_H_
 
#include <gentypes.h>
 
/trunk/boot/arch/ppc64/loader/ofwarch.c
0,0 → 1,68
/*
* Copyright (C) 2005 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <ofwarch.h>
#include <ofw.h>
#include <printf.h>
 
typedef int (* ofw_entry_t)(ofw_args_t *args);
 
int ofw(ofw_args_t *args)
{
return ((ofw_entry_t) ofw_cif)(args);
}
 
void write(const char *str, const int len)
{
ofw_write(str, len);
}
 
int ofw_keyboard(keyboard_t *keyboard)
{
char device_name[BUF_SIZE];
if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
return false;
phandle device = ofw_find_device(device_name);
if (device == -1)
return false;
pci_reg_t macio;
if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
return false;
keyboard->addr = (void *) macio.addr.addr_lo;
keyboard->size = macio.size_lo;
 
return true;
}
 
int ofw_translate_failed(ofw_arg_t flag)
{
return 0;
}
/trunk/boot/arch/ppc64/loader/Makefile
51,6 → 51,7
 
SOURCES = \
main.c \
ofwarch.c \
../../../genarch/ofw.c \
../../../generic/printf.c \
asm.S \