Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2249 → Rev 2250

/trunk/boot/genarch/ofw.h
117,7 → 117,8
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);
extern void *ofw_claim_virt(const void *virt, const int len);
extern void *ofw_claim_phys(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);
/trunk/boot/genarch/balloc.h
31,6 → 31,8
 
#include <types.h>
 
#define BALLOC_MAX_SIZE (1024 * 1024)
 
typedef struct {
uintptr_t base;
size_t size;
/trunk/boot/genarch/ofw.c
38,6 → 38,7
ihandle ofw_stdout;
phandle ofw_root;
ihandle ofw_mmu;
ihandle ofw_memory_prop;
phandle ofw_memory;
phandle ofw_aliases;
 
47,7 → 48,7
if (ofw_chosen == -1)
halt();
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
ofw_stdout = 0;
ofw_root = ofw_find_device("/");
56,10 → 57,14
halt();
}
if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, sizeof(ofw_mmu)) <= 0) {
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();
}
if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop, sizeof(ofw_memory_prop)) <= 0) {
puts("\r\nError: Unable to get memory property, halted.\r\n");
halt();
}
 
ofw_memory = ofw_find_device("/memory");
if (ofw_memory == -1) {
200,13 → 205,12
else
shift = 0;
 
return (void *) ((result[2]<<shift)|result[3]);
return (void *) ((result[2] << shift) | result[3]);
}
 
void *ofw_claim(const void *virt, const int len)
void *ofw_claim_virt(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");
216,6 → 220,42
return (void *) retaddr;
}
 
void *ofw_claim_phys(const void *phys, const int len)
{
ofw_arg_t retaddr[2];
int shift;
 
if (sizeof(unative_t) == 8) {
shift = 32;
if (ofw_call("call-method", 6, 3, retaddr, "claim",
ofw_memory_prop, 0, len, ((uintptr_t) phys) >> shift,
((uintptr_t) phys) & ((uint32_t) -1)) != 0) {
/*
* Note that this will help us to discover
* conflicts between OpenFirmware allocations
* and our use of physical memory.
* It is better to detect collisions here
* than to cope with weird errors later.
*
* So this is really not to make the loader
* more generic; it is here for debugging
* purposes.
*/
puts("Error: memory method claim() failed, halting.\n");
halt();
}
} else {
shift = 0;
/*
* FIXME: the number of arguments is probably different...
*/
puts("Error: 32-bit ofw_claim_phys not implemented.\n");
halt();
}
 
return (void *) ((retaddr[0] << shift) | retaddr[1]);
}
 
int ofw_map(const void *phys, const void *virt, const int size, const int mode)
{
uintptr_t phys_hi, phys_lo;
230,7 → 270,7
}
 
return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size, virt,
phys_hi, phys_lo);
phys_hi, phys_lo);
}
 
/** Save OpenFirmware physical memory map.
252,8 → 292,8
int pos;
map->total = 0;
map->count = 0;
for (pos = 0; (pos < ret / sizeof(uint32_t)) && (map->count <
MEMMAP_MAX_RECORDS); pos += ac + sc) {
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];
/trunk/boot/genarch/balloc.c
47,7 → 47,10
alignment = ALIGN_UP(alignment, 4);
addr = ballocs->base + ALIGN_UP(ballocs->size, alignment);
 
if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE)
return NULL;
ballocs->size = ALIGN_UP(ballocs->size, alignment) + size;
return (void *) addr;