Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 420 → Rev 421

/SPARTAN/trunk/genarch/include/firmware/ofw/ofw.h
0,0 → 1,63
/*
* 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.
*/
 
#ifndef __ppc32_OFW_H__
#define __ppc32_OFW_H__
 
#include <arch/types.h>
 
#define MAX_OFW_ARGS 10
 
typedef __u32 ofw_arg_t;
typedef __u32 ihandle;
typedef __u32 phandle;
 
/** OpenFirmware command structure
*
*/
typedef struct {
const char *service; /**< Command name */
__u32 nargs; /**< Number of in arguments */
__u32 nret; /**< Number of out arguments */
ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */
} ofw_args_t;
 
typedef void (*ofw_entry)(ofw_args_t *);
 
extern ofw_entry ofw;
 
extern void ofw_init(void);
extern void ofw_done(void);
extern __address ofw_call(const char *service, const int nargs, const int nret, ...);
extern void ofw_putchar(const char ch);
extern phandle ofw_find_device(const char *name);
extern int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen);
extern void *ofw_claim(const void *addr, const int size, const int align);
extern void putchar(const char ch);
 
#endif
/SPARTAN/trunk/genarch/Makefile.inc
0,0 → 1,14
# Open Firmware
OFW=no
 
ifeq ($(ARCH),ppc32)
OFW=yes
endif
 
ifeq ($(ARCH),sparc64)
OFW=yes
endif
 
ifeq ($(OFW),yes)
genarch_sources+=src/genarch/firmware/ofw/ofw.c
endif
/SPARTAN/trunk/genarch/src/firmware/ofw/ofw.c
0,0 → 1,105
/*
* 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 <genarch/firmware/ofw/ofw.h>
#include <arch/asm.h>
#include <stdarg.h>
#include <cpu.h>
#include <arch/types.h>
 
ofw_entry ofw;
 
phandle ofw_chosen;
ihandle ofw_stdout;
 
void ofw_init(void)
{
ofw_chosen = ofw_find_device("/chosen");
if (ofw_chosen == -1)
ofw_done();
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
ofw_stdout = 0;
}
 
void ofw_done(void)
{
ofw_call("exit", 0, 0);
cpu_halt();
}
 
__address ofw_call(const char *service, const int nargs, const int nret, ...)
{
va_list list;
ofw_args_t args;
int i;
args.service = service;
args.nargs = nargs;
args.nret = nret;
va_start(list, nret);
for (i = 0; i < nargs; i++)
args.args[i] = va_arg(list, ofw_arg_t);
va_end(list);
for (i = 0; i < nret; i++)
args.args[i + nargs] = 0;
ofw(&args);
return args.args[nargs];
}
 
void ofw_putchar(const char ch)
{
if (ofw_stdout == 0)
return;
ofw_call("write", 3, 1, ofw_stdout, &ch, 1);
}
 
phandle ofw_find_device(const char *name)
{
return ofw_call("finddevice", 1, 1, name);
}
 
int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)
{
return ofw_call("getprop", 4, 1, device, name, buf, buflen);
}
 
void *ofw_claim(const void *addr, const int size, const int align)
{
return (void *) ofw_call("claim", 3, 1, addr, size, align);
}
 
void putchar(const char ch)
{
ofw_putchar(ch);
}
/SPARTAN/trunk/arch/sparc64/boot/boot.S
1,5 → 1,5
#
# Copyright (C) 2005 Martin Decky
# Copyright (C) 2005 Jakub Jermar
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
/SPARTAN/trunk/arch/sparc64/src/dummy.s
55,7 → 55,6
.global memsetb
.global page_arch_init
.global panic_printf
.global putchar
.global userspace
 
.global dummy
87,7 → 86,6
memsetb:
page_arch_init:
panic_printf:
putchar:
userspace:
 
 
/SPARTAN/trunk/arch/ppc32/include/arch.h
29,7 → 29,7
#ifndef __ppc32_ARCH_H__
#define __ppc32_ARCH_H__
 
#include <arch/drivers/ofw.h>
#include <genarch/firmware/ofw/ofw.h>
 
#ifdef early_mapping
#undef early_mapping
/SPARTAN/trunk/arch/ppc32/include/drivers/ofw.h
File deleted
/SPARTAN/trunk/arch/ppc32/Makefile.inc
29,5 → 29,4
src/arch/mm/frame.c \
src/arch/mm/memory_init.c \
src/arch/mm/page.c \
src/arch/drivers/ofw.c \
src/arch/fmath.c
/SPARTAN/trunk/arch/ppc32/src/mm/memory_init.c
27,7 → 27,7
*/
 
#include <arch/mm/memory_init.h>
#include <arch/drivers/ofw.h>
#include <genarch/firmware/ofw/ofw.h>
#include <panic.h>
 
#define MEMMAP_MAX_RECORDS 32
/SPARTAN/trunk/arch/ppc32/src/drivers/ofw.c
File deleted
/SPARTAN/trunk/Makefile
1,5 → 1,6
include Makefile.config
include arch/$(ARCH)/Makefile.inc
include genarch/Makefile.inc
 
sources=src/cpu/cpu.c \
src/main/main.c \
50,6 → 51,7
CFLAGS+=-D$(TEST)
endif
arch_objects:=$(addsuffix .o,$(basename $(arch_sources)))
genarch_objects:=$(addsuffix .o,$(basename $(genarch_sources)))
objects:=$(addsuffix .o,$(basename $(sources)))
 
.PHONY : all config depend build clean dist-clean boot
60,28 → 62,32
 
config:
find src/ include/ -name arch -type l -exec rm \{\} \;
find src/ include/ -name genarch -type l -exec rm \{\} \;
ln -s ../arch/$(ARCH)/src/ src/arch
ln -s ../arch/$(ARCH)/include/ include/arch
ln -s ../genarch/src/ src/genarch
ln -s ../genarch/include/ include/genarch
 
depend:
$(CC) $(CFLAGS) -M $(arch_sources) $(sources) >Makefile.depend
$(CC) $(CFLAGS) -M $(arch_sources) $(genarch_sources) $(sources) >Makefile.depend
 
build: kernel.bin boot
 
clean:
find src/ arch/$(ARCH)/src/ test/ -name '*.o' -exec rm \{\} \;
find src/ arch/$(ARCH)/src/ genarch/src/ test/ -name '*.o' -exec rm \{\} \;
-rm *.bin kernel.map kernel.map.pre kernel.objdump src/debug/real_map.bin
$(MAKE) -C arch/$(ARCH)/boot/ clean
 
dist-clean:
find src/ include/ -name arch -type l -exec rm \{\} \;
find src/ include/ -name genarch -type l -exec rm \{\} \;
-rm Makefile.depend
-$(MAKE) clean
 
src/debug/real_map.bin: $(arch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld
src/debug/real_map.bin: $(arch_objects) $(genarch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld
$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab Makefile src/debug/empty_map.o
$(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(objects) $(test_objects) src/debug/empty_map.o -o $@ -Map kernel.map.pre
$(OBJDUMP) -t $(arch_objects) $(objects) $(test_objects) > kernel.objdump
$(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(genarch_objects) $(objects) $(test_objects) src/debug/empty_map.o -o $@ -Map kernel.map.pre
$(OBJDUMP) -t $(arch_objects) $(genarch_objects) $(objects) $(test_objects) > kernel.objdump
tools/genmap.py kernel.map.pre kernel.objdump src/debug/real_map.bin
 
src/debug/real_map.o: src/debug/real_map.bin
88,8 → 94,8
$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab $< $@
 
 
kernel.bin: $(arch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld src/debug/real_map.o
$(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(objects) $(test_objects) src/debug/real_map.o -o $@ -Map kernel.map
kernel.bin: $(arch_objects) $(genarch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld src/debug/real_map.o
$(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(genarch_objects) $(objects) $(test_objects) src/debug/real_map.o -o $@ -Map kernel.map
 
%.o: %.S
$(CC) $(ASFLAGS) $(CFLAGS) -c $< -o $@