/uspace/trunk/ns/ns.c |
---|
88,8 → 88,7 |
return; |
} |
addr = (void *)(200*1024*1024); /* TODO: intelligent freemem space */ |
map_physmem(task_get_id(), ph_addr, addr, 1, |
AS_AREA_READ | AS_AREA_CACHEABLE); |
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/ega.h |
---|
0,0 → 1,34 |
/* |
* Copyright (C) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef _EGA_H_ |
#define _EGA_H_ |
int ega_init(void); |
#endif |
/uspace/trunk/fb/main.c |
---|
33,6 → 33,7 |
#include "fb.h" |
#include "sysio.h" |
#include "ega.h" |
int main(int argc, char *argv[]) |
{ |
42,7 → 43,11 |
if (sysinfo_value("fb.kind") == 1) { |
if (fb_init() == 0) |
initialized = 1; |
} else if (sysinfo_value("fb.kind") == 2) { |
if (ega_init() == 0) |
initialized = 1; |
} |
if (!initialized) |
sysio_init(); |
/uspace/trunk/fb/fb.c |
---|
564,7 → 564,7 |
fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE); |
map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr, |
map_physmem((void *)((__address)fb_ph_addr),(void *)fb_addr, |
(fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH, |
AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); |
/uspace/trunk/fb/Makefile |
---|
48,7 → 48,8 |
fb.c \ |
font-8x16.c \ |
main.c \ |
sysio.c |
sysio.c \ |
ega.c |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
/uspace/trunk/fb/ega.c |
---|
0,0 → 1,134 |
/* |
* Copyright (C) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <align.h> |
#include <async.h> |
#include <ipc/ipc.h> |
#include <errno.h> |
#include <stdio.h> |
#include <ddi.h> |
#include <sysinfo.h> |
#include <as.h> |
#include <ipc/fb.h> |
#include <ipc/ipc.h> |
#include <ipc/ns.h> |
#include <ipc/services.h> |
#include "ega.h" |
/* Allow only 1 connection */ |
static int client_connected = 0; |
static unsigned int scr_width; |
static unsigned int scr_height; |
static char *scr_addr; |
static void clrscr(void) |
{ |
int i; |
for (i=0; i < scr_width*scr_height; i++) |
scr_addr[i*2] = ' '; |
} |
static void printchar(char c, unsigned int row, unsigned int col) |
{ |
scr_addr[(row*scr_width + col)*2] = c; |
} |
static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
int retval; |
ipc_callid_t callid; |
ipc_call_t call; |
char c; |
unsigned int row, col; |
if (client_connected) { |
ipc_answer_fast(iid, ELIMIT, 0,0); |
return; |
} |
client_connected = 1; |
ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
while (1) { |
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
client_connected = 0; |
ipc_answer_fast(callid,0,0,0); |
return; /* Exit thread */ |
case FB_GET_CSIZE: |
ipc_answer_fast(callid, 0, scr_width, scr_height); |
continue; |
case FB_CLEAR: |
clrscr(); |
retval = 0; |
break; |
case FB_PUTCHAR: |
c = IPC_GET_ARG1(call); |
row = IPC_GET_ARG2(call); |
col = IPC_GET_ARG3(call); |
if (row >= scr_width || col >= scr_height) { |
retval = EINVAL; |
break; |
} |
printchar(c,row,col); |
retval = 0; |
break; |
default: |
retval = ENOENT; |
} |
ipc_answer_fast(callid,retval,0,0); |
} |
} |
int ega_init(void) |
{ |
void *ega_ph_addr; |
ega_ph_addr=(void *)sysinfo_value("fb.address.physical"); |
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); |
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+PAGE_SIZE-1)>>PAGE_WIDTH, |
AS_AREA_READ | AS_AREA_WRITE); |
async_set_client_connection(ega_client_connection); |
clrscr(); |
return 0; |
} |
/uspace/trunk/libc/include/ddi.h |
---|
31,7 → 31,7 |
#include <task.h> |
extern int map_physmem(task_id_t id, void *pf, void *vp, unsigned long pages, int flags); |
extern int map_physmem(void *pf, void *vp, unsigned long pages, int flags); |
extern int iospace_enable(task_id_t id, void *ioaddr, unsigned long size); |
extern int preemption_control(int enable); |
/uspace/trunk/libc/generic/ddi.c |
---|
45,18 → 45,9 |
* ENOENT if there is no task with specified ID and ENOMEM if there |
* was some problem in creating address space area. |
*/ |
int map_physmem(task_id_t id, void *pf, void *vp, unsigned long pages, int flags) |
int map_physmem(void *pf, void *vp, unsigned long pages, int flags) |
{ |
task_id_t task_id; |
ddi_memarg_t arg; |
arg.task_id = id; |
arg.phys_base = pf; |
arg.virt_base = vp; |
arg.pages = pages; |
arg.flags = flags; |
return __SYSCALL1(SYS_MAP_PHYSMEM, (sysarg_t) &arg); |
return __SYSCALL4(SYS_MAP_PHYSMEM, (sysarg_t) pf, (sysarg_t)vp, pages, flags); |
} |
/** Enable I/O space range to task. |