/branches/rcu/uspace/libc/include/as.h |
---|
40,11 → 40,13 |
#include <kernel/mm/as.h> |
#include <libarch/config.h> |
#define PAGE_COLOR(va) (((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1)) |
extern void *as_area_create(void *address, size_t size, int flags); |
extern int as_area_resize(void *address, size_t size, int flags); |
extern int as_area_destroy(void *address); |
extern void *set_maxheapsize(size_t mhs); |
extern void * as_get_mappable_page(size_t sz); |
extern void * as_get_mappable_page(size_t sz, int color); |
#endif |
/branches/rcu/uspace/libc/arch/sparc64/include/config.h |
---|
35,9 → 35,9 |
#ifndef LIBC_sparc64_CONFIG_H_ |
#define LIBC_sparc64_CONFIG_H_ |
#define PAGE_WIDTH 14 |
#define PAGE_SIZE (1 << PAGE_WIDTH) |
#define PAGE_COLOR_BITS 0 /**< Only one page color. */ |
#define PAGE_WIDTH 13 |
#define PAGE_SIZE (1<<PAGE_WIDTH) |
#define PAGE_COLOR_BITS 1 /**< Bit 13 is the page color. */ |
#endif |
/branches/rcu/uspace/libc/arch/sparc64/include/stack.h |
---|
43,7 → 43,7 |
/** |
* 16-extended-word save area for %i[0-7] and %l[0-7] registers. |
*/ |
#define STACK_WINDOW_SAVE_AREA_SIZE (16 * STACK_ITEM_SIZE) |
#define STACK_WINDOW_SAVE_AREA_SIZE (16*STACK_ITEM_SIZE) |
/** |
* By convention, the actual top of the stack is %sp + STACK_BIAS. |
/branches/rcu/uspace/libc/arch/sparc64/_link.ld.in |
---|
7,9 → 7,9 |
} |
SECTIONS { |
. = 0x4000; |
. = 0x2000; |
.init ALIGN(0x4000) : SUBALIGN(0x4000) { |
.init ALIGN(0x2000) : SUBALIGN(0x2000) { |
*(.init); |
} :text |
.text : { |
17,11 → 17,11 |
*(.rodata*); |
} :text |
.got ALIGN(0x4000) : SUBALIGN(0x4000) { |
.got ALIGN(0x2000) : SUBALIGN(0x2000) { |
_gp = .; |
*(.got*); |
} :data |
.data ALIGN(0x4000) : SUBALIGN(0x4000) { |
.data ALIGN(0x2000) : SUBALIGN(0x2000) { |
*(.data); |
*(.sdata); |
} :data |
41,7 → 41,7 |
*(.bss); |
} :data |
. = ALIGN(0x4000); |
. = ALIGN(0x2000); |
_heap = .; |
/DISCARD/ : { |
/branches/rcu/uspace/libc/generic/as.c |
---|
55,7 → 55,7 |
void *as_area_create(void *address, size_t size, int flags) |
{ |
return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address, |
(sysarg_t) size, (sysarg_t) flags); |
(sysarg_t) size, (sysarg_t) flags); |
} |
/** Resize address space area. |
69,8 → 69,8 |
*/ |
int as_area_resize(void *address, size_t size, int flags) |
{ |
return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, |
(sysarg_t) size, (sysarg_t) flags); |
return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, (sysarg_t) |
size, (sysarg_t) flags); |
} |
/** Destroy address space area. |
143,6 → 143,7 |
/** Return pointer to some unmapped area, where fits new as_area |
* |
* @param sz Requested size of the allocation. |
* @param color Requested virtual color of the allocation. |
* |
* @return Pointer to the beginning |
* |
149,7 → 150,7 |
* TODO: make some first_fit/... algorithm, we are now just incrementing |
* the pointer to last area |
*/ |
void *as_get_mappable_page(size_t sz) |
void *as_get_mappable_page(size_t sz, int color) |
{ |
void *res; |
uint64_t asz; |
165,16 → 166,21 |
set_maxheapsize(MAX_HEAP_SIZE); |
/* |
* Make sure we allocate from naturally aligned address. |
* Make sure we allocate from naturally aligned address and a page of |
* appropriate color. |
*/ |
i = 0; |
if (!last_allocated) { |
last_allocated = (void *) ALIGN_UP((void *) &_heap + |
maxheapsize, asz); |
} else { |
last_allocated = (void *) ALIGN_UP(((uintptr_t) |
last_allocated) + (int) (i > 0), asz); |
} |
do { |
if (!last_allocated) { |
last_allocated = (void *) ALIGN_UP((void *) &_heap + |
maxheapsize, asz); |
} else { |
last_allocated = (void *) ALIGN_UP(((uintptr_t) |
last_allocated) + (int) (i > 0), asz); |
} |
} while ((asz < (1 << (PAGE_COLOR_BITS + PAGE_WIDTH))) && |
(PAGE_COLOR((uintptr_t) last_allocated) != color) && |
(++i < (1 << PAGE_COLOR_BITS))); |
res = last_allocated; |
last_allocated += ALIGN_UP(sz, PAGE_SIZE); |
/branches/rcu/uspace/libc/generic/time.c |
---|
72,11 → 72,12 |
int res; |
if (!ktime) { |
mapping = as_get_mappable_page(PAGE_SIZE); |
mapping = as_get_mappable_page(PAGE_SIZE, (int) |
sysinfo_value("clock.fcolor")); |
/* Get the mapping of kernel clock */ |
res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, |
(sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, |
&rights, NULL); |
res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t) |
mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights, |
NULL); |
if (res) { |
printf("Failed to initialize timeofday memarea\n"); |
_exit(1); |
/branches/rcu/uspace/libc/generic/mman.c |
---|
36,11 → 36,10 |
#include <as.h> |
#include <unistd.h> |
void *mmap(void *start, size_t length, int prot, int flags, int fd, |
off_t offset) |
void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) |
{ |
if (!start) |
start = as_get_mappable_page(length); |
start = as_get_mappable_page(length, 0); |
// if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE))) |
// return MAP_FAILED; |
/branches/rcu/uspace/klog/klog.c |
---|
62,7 → 62,7 |
printf("Kernel console output.\n"); |
mapping = as_get_mappable_page(PAGE_SIZE); |
mapping = as_get_mappable_page(PAGE_SIZE, sysinfo_value("klog.fcolor")); |
res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, |
(sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG, |
NULL, NULL, NULL); |
/branches/rcu/uspace/ns/ns.c |
---|
83,9 → 83,10 |
static void *clockaddr = NULL; |
static void *klogaddr = NULL; |
static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, void **addr) |
static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, char *colstr, void **addr) |
{ |
void *ph_addr; |
int ph_color; |
if (!*addr) { |
ph_addr = (void *) sysinfo_value(name); |
93,7 → 94,8 |
ipc_answer_fast(callid, ENOENT, 0, 0); |
return; |
} |
*addr = as_get_mappable_page(PAGE_SIZE); |
ph_color = (int) sysinfo_value(colstr); |
*addr = as_get_mappable_page(PAGE_SIZE, ph_color); |
physmem_map(ph_addr, *addr, 1, AS_AREA_READ | AS_AREA_CACHEABLE); |
} |
ipc_answer_fast(callid, 0, (ipcarg_t) *addr, AS_AREA_READ); |
117,11 → 119,11 |
switch (IPC_GET_ARG3(call)) { |
case SERVICE_MEM_REALTIME: |
get_as_area(callid, &call, "clock.faddr", |
&clockaddr); |
"clock.fcolor", &clockaddr); |
break; |
case SERVICE_MEM_KLOG: |
get_as_area(callid, &call, "klog.faddr", |
&klogaddr); |
"klog.fcolor", &klogaddr); |
break; |
default: |
ipc_answer_fast(callid, ENOENT, 0, 0); |
/branches/rcu/uspace/fb/main.c |
---|
43,7 → 43,8 |
{ |
void *dest; |
dest = as_get_mappable_page(IPC_GET_ARG2(*call)); |
dest = as_get_mappable_page(IPC_GET_ARG2(*call), |
PAGE_COLOR(IPC_GET_ARG1(*call))); |
if (ipc_answer_fast(callid, 0, (sysarg_t) dest, 0) == 0) { |
if (*area) |
as_area_destroy(*area); |
/branches/rcu/uspace/fb/fb.c |
---|
755,7 → 755,8 |
case IPC_M_AS_AREA_SEND: |
/* We accept one area for data interchange */ |
if (IPC_GET_ARG1(*call) == shm_id) { |
void *dest = as_get_mappable_page(IPC_GET_ARG2(*call)); |
void *dest = as_get_mappable_page(IPC_GET_ARG2(*call), |
PAGE_COLOR(IPC_GET_ARG1(*call))); |
shm_size = IPC_GET_ARG2(*call); |
if (!ipc_answer_fast(callid, 0, (sysarg_t) dest, 0)) |
shm = dest; |
1368,7 → 1369,8 |
fb_invert_colors = sysinfo_value("fb.invert-colors"); |
asz = fb_scanline * fb_height; |
fb_addr = as_get_mappable_page(asz); |
fb_addr = as_get_mappable_page(asz, (int) |
sysinfo_value("fb.address.color")); |
physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >> |
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
/branches/rcu/uspace/fb/ega.c |
---|
315,7 → 315,8 |
iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2); |
sz = scr_width * scr_height * 2; |
scr_addr = as_get_mappable_page(sz); |
scr_addr = as_get_mappable_page(sz, (int) |
sysinfo_value("fb.address.color")); |
physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> |
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |
/branches/rcu/uspace/rd/rd.c |
---|
73,11 → 73,12 |
{ |
size_t rd_size = sysinfo_value("rd.size"); |
void * rd_ph_addr = (void *) sysinfo_value("rd.address.physical"); |
int rd_color = (int) sysinfo_value("rd.address.color"); |
if (rd_size == 0) |
return false; |
void * rd_addr = as_get_mappable_page(rd_size); |
void * rd_addr = as_get_mappable_page(rd_size, rd_color); |
physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); |