/uspace/trunk/fb/main.c |
---|
0,0 → 1,55 |
/* |
* 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 <ipc/ipc.h> |
#include <ipc/services.h> |
#include <sysinfo.h> |
#include <async.h> |
#include "fb.h" |
#include "sysio.h" |
int main(int argc, char *argv[]) |
{ |
ipcarg_t phonead; |
int initialized = 0; |
if (sysinfo_value("fb.kind") == 1) { |
if (fb_init() == 0) |
initialized = 1; |
} |
if (!initialized) |
sysio_init(); |
if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead) != 0) |
return -1; |
async_manager(); |
/* Never reached */ |
return 0; |
} |
/uspace/trunk/fb/sysio.c |
---|
0,0 → 1,83 |
/* |
* 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 <async.h> |
#include <ipc/fb.h> |
#include <ipc/ipc.h> |
#include <libc.h> |
#include <errno.h> |
#include "sysio.h" |
/* Allow only 1 connection */ |
static int client_connected = 0; |
static void sysput(char c) |
{ |
__SYSCALL3(SYS_IO, 1, (sysarg_t)&c, (sysarg_t) 1); |
} |
static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
int retval; |
ipc_callid_t callid; |
ipc_call_t call; |
char c; |
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_PUTCHAR: |
c = IPC_GET_ARG1(call); |
sysput(c); |
retval = 0; |
break; |
case FB_GET_CSIZE: |
ipc_answer_fast(callid, 0, 25, 80); |
continue; |
default: |
retval = ENOENT; |
} |
ipc_answer_fast(callid,retval,0,0); |
} |
} |
void sysio_init(void) |
{ |
async_set_client_connection(sysio_client_connection); |
} |
/uspace/trunk/fb/fb.c |
---|
27,12 → 27,10 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <string.h> |
#include <ddi.h> |
#include <task.h> |
#include <sysinfo.h> |
#include <align.h> |
#include <as.h> |
389,36 → 387,6 |
clear_port(0); |
} |
static int init_fb(void) |
{ |
__address fb_ph_addr; |
unsigned int fb_width; |
unsigned int fb_height; |
unsigned int fb_bpp; |
unsigned int fb_scanline; |
__address fb_addr; |
int a=0; |
int i,j,k; |
int w; |
char text[]="HelenOS Framebuffer driver\non Virtual Framebuffer\nVFB "; |
fb_ph_addr=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); |
map_physmem(task_get_id(),(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); |
screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline); |
return 0; |
} |
static void draw_char(int vp, char c, unsigned int row, unsigned int col) |
{ |
viewport_t *vport = &viewports[vp]; |
442,7 → 410,7 |
invert_char(vp, vport->cur_row, vport->cur_col); |
} |
void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
ipc_callid_t callid; |
ipc_call_t call; |
577,22 → 545,31 |
} |
} |
int main(int argc, char *argv[]) |
int fb_init(void) |
{ |
char connected = 0; |
int res; |
ipcarg_t phonead; |
__address fb_ph_addr; |
unsigned int fb_width; |
unsigned int fb_height; |
unsigned int fb_bpp; |
unsigned int fb_scanline; |
__address fb_addr; |
if(!sysinfo_value("fb")) |
return -1; |
async_set_client_connection(fb_client_connection); |
if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0) |
return -1; |
fb_ph_addr=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); |
if (init_fb() != 0) |
return -1; |
map_physmem(task_get_id(),(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); |
screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline); |
async_manager(); |
/* Never reached */ |
return 0; |
} |
/uspace/trunk/fb/sysio.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 _SYSIO_H_ |
#define _SYSIO_H_ |
void sysio_init(void); |
#endif |
/uspace/trunk/fb/Makefile |
---|
46,7 → 46,9 |
OUTPUT = fb |
SOURCES = \ |
fb.c \ |
font-8x16.c |
font-8x16.c \ |
main.c \ |
sysio.c |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
/uspace/trunk/fb/fb.h |
---|
29,7 → 29,6 |
#ifndef _FB_H_ |
#define _FB_H_ |
#include <types.h> |
#include <arch/types.h> |
int fb_init(void); |
#endif |