/uspace/trunk/ns/ns.c |
---|
87,7 → 87,7 |
ipc_answer_fast(callid, ENOENT, 0, 0); |
return; |
} |
addr = (void *)(200*1024*1024); /* TODO: intelligent freemem space */ |
addr = as_get_mappable_page(PAGE_SIZE); |
map_physmem(ph_addr, addr, 1, AS_AREA_READ | AS_AREA_CACHEABLE); |
} |
ipc_answer_fast(callid, 0, (ipcarg_t)addr, AS_AREA_READ | AS_AREA_CACHEABLE); |
/uspace/trunk/fb/fb.c |
---|
359,7 → 359,7 |
* @param scan Bytes per one scanline |
* |
*/ |
static void screen_init(__address addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan) |
static void screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan) |
{ |
switch (bpp) { |
case 8: |
597,25 → 597,26 |
/** Initialization of framebuffer */ |
int fb_init(void) |
{ |
__address fb_ph_addr; |
void *fb_ph_addr; |
unsigned int fb_width; |
unsigned int fb_height; |
unsigned int fb_bpp; |
unsigned int fb_scanline; |
__address fb_addr; |
void *fb_addr; |
size_t asz; |
async_set_client_connection(fb_client_connection); |
fb_ph_addr=sysinfo_value("fb.address.physical"); |
fb_ph_addr=(void *)sysinfo_value("fb.address.physical"); |
fb_width=sysinfo_value("fb.width"); |
fb_height=sysinfo_value("fb.height"); |
fb_bpp=sysinfo_value("fb.bpp"); |
fb_scanline=sysinfo_value("fb.scanline"); |
fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE); |
asz = fb_scanline*fb_height; |
fb_addr = as_get_mappable_page(asz); |
map_physmem((void *)((__address)fb_ph_addr),(void *)fb_addr, |
(fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH, |
map_physmem(fb_ph_addr, fb_addr, ALIGN_UP(asz,PAGE_SIZE) >>PAGE_WIDTH, |
AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); |
screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline); |
/uspace/trunk/fb/ega.c |
---|
111,6 → 111,7 |
int ega_init(void) |
{ |
void *ega_ph_addr; |
size_t sz; |
ega_ph_addr=(void *)sysinfo_value("fb.address.physical"); |
117,15 → 118,12 |
scr_width=sysinfo_value("fb.width"); |
scr_height=sysinfo_value("fb.height"); |
scr_addr=(void *)ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE); |
sz = scr_width*scr_height*2; |
scr_addr = as_get_mappable_page(sz); |
if (ega_ph_addr != ALIGN_DOWN((unsigned long)ega_ph_addr, PAGE_SIZE)) |
return -1; |
map_physmem(ega_ph_addr, scr_addr, (scr_width*scr_height*2+PAGE_SIZE-1)>>PAGE_WIDTH, |
map_physmem(ega_ph_addr, scr_addr, ALIGN_UP(sz,PAGE_SIZE)>>PAGE_WIDTH, |
AS_AREA_READ | AS_AREA_WRITE); |
async_set_client_connection(ega_client_connection); |
clrscr(); |
/uspace/trunk/libc/include/align.h |
---|
42,6 → 42,6 |
* @param s Address or size to be aligned. |
* @param a Size of alignment, must be power of 2. |
*/ |
#define ALIGN_UP(s, a) (((s) + ((a) - 1)) & ~((a) - 1)) |
#define ALIGN_UP(s, a) ((long)((s) + ((a) - 1)) & ~((long) (a) - 1)) |
#endif |
/uspace/trunk/libc/include/as.h |
---|
40,5 → 40,6 |
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); |
#endif |
/uspace/trunk/libc/generic/time.c |
---|
56,7 → 56,6 |
* useconds again. This provides assurance, that at least the |
* sequence of subsequent gettimeofday calls is ordered. |
*/ |
#define TMAREA (100*1024*1024) |
int gettimeofday(struct timeval *tv, struct timezone *tz) |
{ |
void *mapping; |
65,12 → 64,10 |
int res; |
if (!ktime) { |
/* TODO: specify better, where to map the area */ |
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, |
TMAREA, |
PAGE_SIZE, |
0, |
mapping, PAGE_SIZE, 0, |
NULL,&rights,NULL); |
if (res) { |
printf("Failed to initialize timeofday memarea\n"); |
79,10 → 76,10 |
if (rights != (AS_AREA_READ | AS_AREA_CACHEABLE)) { |
printf("Received bad rights on time area: %X\n", |
rights); |
as_area_destroy(TMAREA); |
as_area_destroy(mapping); |
_exit(1); |
} |
ktime = (void *) (TMAREA); |
ktime = mapping; |
} |
if (tz) { |
tz->tz_minuteswest = 0; |
/uspace/trunk/libc/generic/as.c |
---|
26,10 → 26,24 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <stdlib.h> |
#include <unistd.h> |
#include <string.h> |
#include <ddi.h> |
#include <sysinfo.h> |
#include <align.h> |
#include <as.h> |
#include <ipc/fb.h> |
#include <ipc/ipc.h> |
#include <ipc/ns.h> |
#include <ipc/services.h> |
#include <kernel/errno.h> |
#include <as.h> |
#include <libc.h> |
#include <unistd.h> |
#include <task.h> |
#include <align.h> |
/** Create address space area. |
* |
70,6 → 84,9 |
static size_t heapsize = 0; |
static size_t maxheapsize = (size_t)(-1); |
static void * last_allocated = 0; |
/* Start of heap linker symbol */ |
extern char _heap; |
107,6 → 124,7 |
return res; |
} |
/** Set maximum heap size and return pointer just after the heap */ |
void *set_maxheapsize(size_t mhs) |
{ |
maxheapsize=mhs; |
114,3 → 132,25 |
return (void *)&_heap + maxheapsize; |
} |
/** Return pointer to some unmapped area, where fits new as_area |
* |
* 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 *res; |
/* Set heapsize to some meaningful value */ |
if (maxheapsize == -1) |
set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH>>1,PAGE_SIZE)); |
if (!last_allocated) |
last_allocated = ALIGN_UP((void *)&_heap + maxheapsize, PAGE_SIZE); |
sz = ALIGN_UP(sz, PAGE_SIZE); |
res = last_allocated; |
last_allocated += sz; |
return res; |
} |