Major rework of how we copy data into kernel space.
We now talk to the memory and mmu instances directly rather than using the OpenFirmware "claim" method.
This commit is contained in:
parent
bff0acee63
commit
8e465298e2
@ -52,11 +52,6 @@ ofw_elf_loadfile(char *filename, vm_offset_t dest,
|
||||
if (r != 0)
|
||||
return (r);
|
||||
|
||||
addr = OF_claim((void *)(*result)->f_addr, (*result)->f_size, 0);
|
||||
|
||||
if (addr == (void *)-1 || addr != (void *)(*result)->f_addr)
|
||||
return (ENOMEM);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,36 @@
|
||||
#include "libofw.h"
|
||||
|
||||
#define READIN_BUF (4 * 1024)
|
||||
#define PAGE_SIZE 0x1000
|
||||
#define PAGE_MASK 0x0fff
|
||||
|
||||
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
|
||||
|
||||
ssize_t
|
||||
ofw_copyin(const void *src, vm_offset_t dest, const size_t len)
|
||||
{
|
||||
void *destp, *addr;
|
||||
size_t dlen;
|
||||
|
||||
destp = (void *)(dest & ~PAGE_MASK);
|
||||
dlen = roundup(len, PAGE_SIZE);
|
||||
|
||||
if (OF_call_method("claim", memory, 3, 1, destp, dlen, 0, &addr)
|
||||
== -1) {
|
||||
printf("ofw_copyin: physical claim failed\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (OF_call_method("claim", mmu, 3, 1, destp, dlen, 0, &addr) == -1) {
|
||||
printf("ofw_copyin: virtual claim failed\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (OF_call_method("map", mmu, 4, 0, destp, destp, dlen, 0) == -1) {
|
||||
printf("ofw_copyin: map failed\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
bcopy(src, (void *)dest, len);
|
||||
return(len);
|
||||
}
|
||||
@ -76,7 +102,7 @@ ofw_readin(const int fd, vm_offset_t dest, const size_t len)
|
||||
break;
|
||||
}
|
||||
|
||||
bcopy(buf, (void *)p, got);
|
||||
ofw_copyin(buf, p, got);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
@ -181,12 +181,8 @@ ofwd_probe_devs(void)
|
||||
static int
|
||||
ofwd_init(void)
|
||||
{
|
||||
#ifdef __sparc64__
|
||||
/* Short-circuit the device probing, since it takes too long. */
|
||||
return 0;
|
||||
#else
|
||||
return ofwd_init_devs();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -47,17 +47,15 @@ struct ofw_mapping {
|
||||
void
|
||||
ofw_memmap(void)
|
||||
{
|
||||
ihandle_t mmui;
|
||||
phandle_t mmu;
|
||||
phandle_t mmup;
|
||||
int nmapping, i;
|
||||
struct ofw_mapping mappings[256];
|
||||
|
||||
OF_getprop(chosen, "mmu", &mmui, 4);
|
||||
mmu = OF_instance_to_package(mmui);
|
||||
mmup = OF_instance_to_package(mmu);
|
||||
|
||||
bzero(mappings, sizeof(mappings));
|
||||
|
||||
nmapping = OF_getprop(mmu, "translations", mappings, sizeof(mappings));
|
||||
nmapping = OF_getprop(mmup, "translations", mappings, sizeof(mappings));
|
||||
if (nmapping == -1) {
|
||||
printf("Could not get memory map (%d)\n",
|
||||
nmapping);
|
||||
@ -79,14 +77,12 @@ ofw_memmap(void)
|
||||
void *
|
||||
ofw_alloc_heap(unsigned int size)
|
||||
{
|
||||
ihandle_t meminstance;
|
||||
phandle_t memory;
|
||||
phandle_t memoryp;
|
||||
struct ofw_reg available;
|
||||
void *base;
|
||||
|
||||
OF_getprop(chosen, "memory", &meminstance, sizeof(meminstance));
|
||||
memory = OF_instance_to_package(meminstance);
|
||||
OF_getprop(memory, "available", &available, sizeof(available));
|
||||
memoryp = OF_instance_to_package(memory);
|
||||
OF_getprop(memoryp, "available", &available, sizeof(available));
|
||||
|
||||
heap_base = OF_claim((void *)available.base, size, sizeof(register_t));
|
||||
|
||||
|
@ -68,8 +68,8 @@ int (*openfirmware)(void *);
|
||||
static ihandle_t stdin;
|
||||
static ihandle_t stdout;
|
||||
|
||||
static ihandle_t mmu;
|
||||
static ihandle_t memory;
|
||||
ihandle_t mmu;
|
||||
ihandle_t memory;
|
||||
|
||||
/* Initialiaser */
|
||||
|
||||
|
@ -71,6 +71,7 @@ typedef unsigned long int cell_t;
|
||||
|
||||
extern int (*openfirmware)(void *);
|
||||
extern phandle_t chosen;
|
||||
extern ihandle_t memory, mmu;
|
||||
|
||||
/*
|
||||
* This isn't actually an OpenFirmware function, but it seemed like the right
|
||||
|
Loading…
x
Reference in New Issue
Block a user