Subversion Repositories HelenOS-historic

Compare Revisions

Regard whitespace Rev 1782 → Rev 1783

/boot/trunk/genarch/ofw.h
36,7 → 36,23
 
#define MEMMAP_MAX_RECORDS 32
 
#define MAX_OFW_ARGS 12
 
typedef unsigned long ofw_arg_t;
typedef unsigned int ihandle;
typedef unsigned int phandle;
 
/** OpenFirmware command structure
*
*/
typedef struct {
const char *service; /**< Command name */
unsigned long nargs; /**< Number of in arguments */
unsigned long nret; /**< Number of out arguments */
ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */
} ofw_args_t;
 
typedef struct {
void *start;
unsigned int size;
} memzone_t;
48,7 → 64,7
} memmap_t;
 
typedef struct {
void *addr;
uint32_t addr;
unsigned int width;
unsigned int height;
unsigned int bpp;
56,7 → 72,7
} screen_t;
 
typedef struct {
void *addr;
uint32_t addr;
unsigned int size;
} keyboard_t;
 
72,9 → 88,7
unsigned int size_lo;
} pci_reg_t;
 
typedef unsigned long ofw_arg_t;
typedef unsigned int ihandle;
typedef unsigned int phandle;
extern uintptr_t ofw_cif;
 
extern phandle ofw_aliases;
 
84,7 → 98,10
extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen);
extern phandle ofw_find_device(const char *name);
 
extern int ofw(ofw_args_t *arg);
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);
extern int ofw_map(const void *phys, const void *virt, const int size, const int mode);
extern int ofw_memmap(memmap_t *map);
extern int ofw_screen(screen_t *screen);
/boot/trunk/genarch/ofw.c
31,22 → 31,8
#include <asm.h>
#include <types.h>
 
#define MAX_OFW_ARGS 10
uintptr_t ofw_cif;
 
/** OpenFirmware command structure
*
*/
typedef struct {
const char *service; /**< Command name */
unsigned long nargs; /**< Number of in arguments */
unsigned long 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 *);
 
ofw_entry ofw;
 
phandle ofw_chosen;
ihandle ofw_stdout;
phandle ofw_root;
72,7 → 58,7
for (i = 0; i < nret; i++)
args.args[i + nargs] = 0;
ofw(&args);
(void) ofw(&args);
for (i = 1; i < nret; i++)
rets[i - 1] = args.args[i + nargs];
176,15 → 162,30
halt();
}
 
if (ofw_translate_failed(result[0]))
return NULL;
 
if (sizeof(unative_t) == 8)
shift = 32;
else
shift = 0;
return (void *) (((result[2]&0xffffffff)<<shift)|((result[3])&0xffffffff));
return (void *) ((result[2]<<shift)|result[3]);
}
 
void *ofw_claim(const void *virt, const int len)
{
ofw_arg_t retaddr;
int shift;
 
if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len, virt) != 0) {
puts("Error: MMU method claim() failed, halting.\n");
halt();
}
 
return (void *) retaddr;
}
 
int ofw_map(const void *phys, const void *virt, const int size, const int mode)
{
uintptr_t phys_hi, phys_lo;
/boot/trunk/arch/sparc64/loader/asm.S
26,6 → 26,10
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
#define STACK_WINDOW_SAVE_AREA_SIZE (16*8)
 
#define PSTATE_AM_BIT 8
 
.text
 
.global halt
94,6 → 98,24
mov %o1, %o0
 
jump_to_kernel:
set ofw, %l0
set ofw_cif, %l0
jmp %o0 ! jump to kernel
ldx [%l0], %o4 ! pass OpenFirmware address in %o4
 
.global ofw
ofw:
save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
set ofw_cif, %l0
ldx [%l0], %l0
 
rdpr %pstate, %l1
and %l1, ~PSTATE_AM_BIT, %l2
wrpr %l2, 0, %pstate
jmpl %l0, %o7
mov %i0, %o0
 
wrpr %l1, 0, %pstate
 
ret
restore %o0, 0, %o0
/boot/trunk/arch/sparc64/loader/boot.S
28,6 → 28,8
 
#define INITIAL_STACK 0x0
 
#define PSTATE_IE_BIT 2
 
.register %g2, #scratch
.register %g3, #scratch
.register %g6, #scratch
52,9 → 54,16
1:
flushw
 
/*
* Disable interrupts.
*/
rdpr %pstate, %g2
and %g2, ~PSTATE_IE_BIT, %g2 ! mask the Interrupt Enable bit
wrpr %g2, 0, %pstate
 
# TODO: set initial stack
 
set ofw, %l0
set ofw_cif, %l0
call init ! initialize OpenFirmware
stx %o4, [%l0]
/boot/trunk/arch/sparc64/loader/main.c
51,12 → 51,6
for (i = 0; i < COMPONENTS; i++)
printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
 
screen_t scr;
ofw_screen(&scr);
printf("\n%P: fb, %dx%dx%d\n", ofw_translate(scr.addr), scr.width, scr.height, scr.bpp);
 
printf("\nCopying components\n");
unsigned int top = 0;
bootinfo.cnt = 0;
/boot/trunk/arch/sparc64/loader/ofw.c
39,3 → 39,8
ofw_write(&str[i], 1);
}
}
 
int ofw_translate_failed(ofw_arg_t flag)
{
return flag != -1;
}
/boot/trunk/arch/ppc32/loader/boot.S
33,8 → 33,8
.global start
 
start:
lis r4, ofw@ha
addi r4, r4, ofw@l
lis r4, ofw_cif@ha
addi r4, r4, ofw_cif@l
stw r5, 0(r4)
bl init
/boot/trunk/arch/ppc32/loader/main.c
156,5 → 156,5
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, real_mode_pa, bootinfo.screen.addr, bootinfo.screen.scanline);
jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa, (void *) bootinfo.screen.addr, bootinfo.screen.scanline);
}
/boot/trunk/arch/ppc32/loader/ofw.c
29,6 → 29,13
#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);
48,8 → 55,13
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->addr = macio.addr.addr_lo;
keyboard->size = macio.size_lo;
 
return true;
}
 
int ofw_translate_failed(ofw_arg_t flag)
{
return 0;
}
/boot/trunk/arch/ppc64/loader/boot.S
33,8 → 33,8
.global start
 
start:
lis r4, ofw@ha
addi r4, r4, ofw@l
lis r4, ofw_cif@ha
addi r4, r4, ofw_cif@l
stw r5, 0(r4)
bl init
/boot/trunk/arch/ppc64/loader/ofw.c
29,6 → 29,13
#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);
53,3 → 60,8
 
return true;
}
 
int ofw_translate_failed(ofw_arg_t flag)
{
return 0;
}