Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2291 → Rev 2292

/branches/rcu/uspace/ns/ns.c
83,10 → 83,9
static void *clockaddr = NULL;
static void *klogaddr = NULL;
 
static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, char *colstr, void **addr)
static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, void **addr)
{
void *ph_addr;
int ph_color;
 
if (!*addr) {
ph_addr = (void *) sysinfo_value(name);
94,8 → 93,7
ipc_answer_fast(callid, ENOENT, 0, 0);
return;
}
ph_color = (int) sysinfo_value(colstr);
*addr = as_get_mappable_page(PAGE_SIZE, ph_color);
*addr = as_get_mappable_page(PAGE_SIZE);
physmem_map(ph_addr, *addr, 1, AS_AREA_READ | AS_AREA_CACHEABLE);
}
ipc_answer_fast(callid, 0, (ipcarg_t) *addr, AS_AREA_READ);
119,11 → 117,11
switch (IPC_GET_ARG3(call)) {
case SERVICE_MEM_REALTIME:
get_as_area(callid, &call, "clock.faddr",
"clock.fcolor", &clockaddr);
&clockaddr);
break;
case SERVICE_MEM_KLOG:
get_as_area(callid, &call, "klog.faddr",
"klog.fcolor", &klogaddr);
&klogaddr);
break;
default:
ipc_answer_fast(callid, ENOENT, 0, 0);
/branches/rcu/uspace/fb/main.c
43,8 → 43,7
{
void *dest;
 
dest = as_get_mappable_page(IPC_GET_ARG2(*call),
PAGE_COLOR(IPC_GET_ARG1(*call)));
dest = as_get_mappable_page(IPC_GET_ARG2(*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,8 → 755,7
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),
PAGE_COLOR(IPC_GET_ARG1(*call)));
void *dest = as_get_mappable_page(IPC_GET_ARG2(*call));
shm_size = IPC_GET_ARG2(*call);
if (!ipc_answer_fast(callid, 0, (sysarg_t) dest, 0))
shm = dest;
1369,8 → 1368,7
fb_invert_colors = sysinfo_value("fb.invert-colors");
 
asz = fb_scanline * fb_height;
fb_addr = as_get_mappable_page(asz, (int)
sysinfo_value("fb.address.color"));
fb_addr = as_get_mappable_page(asz);
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,8 → 315,7
iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2);
 
sz = scr_width * scr_height * 2;
scr_addr = as_get_mappable_page(sz, (int)
sysinfo_value("fb.address.color"));
scr_addr = as_get_mappable_page(sz);
 
physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >>
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
/branches/rcu/uspace/klog/klog.c
62,7 → 62,7
 
printf("Kernel console output.\n");
mapping = as_get_mappable_page(PAGE_SIZE, sysinfo_value("klog.fcolor"));
mapping = as_get_mappable_page(PAGE_SIZE);
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/rd/rd.c
73,12 → 73,11
{
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, rd_color);
void * rd_addr = as_get_mappable_page(rd_size);
physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
/branches/rcu/uspace/libc/include/as.h
40,13 → 40,11
#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, int color);
extern void * as_get_mappable_page(size_t sz);
 
#endif
 
/branches/rcu/uspace/libc/generic/time.c
72,12 → 72,11
int res;
 
if (!ktime) {
mapping = as_get_mappable_page(PAGE_SIZE, (int)
sysinfo_value("clock.fcolor"));
mapping = as_get_mappable_page(PAGE_SIZE);
/* 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/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,7 → 143,6
/** 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
*
150,7 → 149,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, int color)
void *as_get_mappable_page(size_t sz)
{
void *res;
uint64_t asz;
166,21 → 165,16
set_maxheapsize(MAX_HEAP_SIZE);
/*
* Make sure we allocate from naturally aligned address and a page of
* appropriate color.
* Make sure we allocate from naturally aligned address.
*/
i = 0;
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)));
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);
}
 
res = last_allocated;
last_allocated += ALIGN_UP(sz, PAGE_SIZE);
/branches/rcu/uspace/libc/generic/mman.c
36,10 → 36,11
#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, 0);
start = as_get_mappable_page(length);
// if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
// return MAP_FAILED;
/branches/rcu/uspace/libc/arch/sparc64/_link.ld.in
7,9 → 7,9
}
 
SECTIONS {
. = 0x2000;
. = 0x4000;
 
.init ALIGN(0x2000) : SUBALIGN(0x2000) {
.init ALIGN(0x4000) : SUBALIGN(0x4000) {
*(.init);
} :text
.text : {
17,11 → 17,11
*(.rodata*);
} :text
.got ALIGN(0x2000) : SUBALIGN(0x2000) {
.got ALIGN(0x4000) : SUBALIGN(0x4000) {
_gp = .;
*(.got*);
} :data
.data ALIGN(0x2000) : SUBALIGN(0x2000) {
.data ALIGN(0x4000) : SUBALIGN(0x4000) {
*(.data);
*(.sdata);
} :data
41,7 → 41,7
*(.bss);
} :data
 
. = ALIGN(0x2000);
. = ALIGN(0x4000);
_heap = .;
/DISCARD/ : {
/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 13
#define PAGE_SIZE (1<<PAGE_WIDTH)
#define PAGE_COLOR_BITS 1 /**< Bit 13 is the page color. */
#define PAGE_WIDTH 14
#define PAGE_SIZE (1 << PAGE_WIDTH)
#define PAGE_COLOR_BITS 0 /**< Only one 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.