/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 |