Subversion Repositories HelenOS-historic

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1546 → Rev 1547

/uspace/trunk/kbd/arch/mips32eb
0,0 → 1,0
link mips32
Property changes:
Added: svn:special
+*
\ No newline at end of property
/uspace/trunk/ns/ns.c
90,7 → 90,7
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);
ipc_answer_fast(callid, 0, (ipcarg_t)addr, AS_AREA_READ);
}
 
int main(int argc, char **argv)
/uspace/trunk/console/console.c
388,7 → 388,7
}
if ((interbuffer = mmap(NULL, sizeof(keyfield_t) * fb_info.cols * fb_info.rows , PROTO_READ|PROTO_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0 ,0 )) != NULL) {
if (ipc_call_sync_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t)interbuffer, 0, AS_AREA_READ | AS_AREA_CACHEABLE, NULL, NULL, NULL) != 0) {
if (ipc_call_sync_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t)interbuffer, 0, AS_AREA_READ, NULL, NULL, NULL) != 0) {
munmap(interbuffer, sizeof(keyfield_t) * fb_info.cols * fb_info.rows);
interbuffer = NULL;
}
/uspace/trunk/console/nameic.ppm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/uspace/trunk/console/helenos.ppm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/uspace/trunk/console/gcons.c
30,18 → 30,21
#include <ipc/ipc.h>
#include <async.h>
#include <stdio.h>
#include <sys/mman.h>
#include <string.h>
 
#include "console.h"
#include "gcons.h"
 
#define CONSOLE_TOP 50
#define CONSOLE_TOP 65
#define CONSOLE_MARGIN 10
 
#define STATUS_SPACE 20
#define STATUS_START 120
#define STATUS_SPACE 5
#define STATUS_WIDTH 40
#define STATUS_HEIGHT 30
 
#define MAIN_COLOR 0x118811
#define MAIN_COLOR 0xffffff
 
static int use_gcons = 0;
static ipcarg_t xres,yres;
145,9 → 148,42
vp_switch(console_vp);
}
 
static void draw_pixmap(char *logo, size_t size, int x, int y)
{
char *shm;
int rc;
 
/* Create area */
shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
if (shm == MAP_FAILED)
return;
 
memcpy(shm, logo, size);
/* Send area */
rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
if (rc)
goto exit;
rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
if (rc)
goto drop;
/* Draw logo */
send_call_2(fbphone, FB_DRAW_PPM, x, y);
drop:
/* Drop area */
nsend_call(fbphone, FB_DROP_SHM, 0);
exit:
/* Remove area */
munmap(shm, size);
}
 
extern char _binary_helenos_ppm_start[0];
extern int _binary_helenos_ppm_size;
extern char _binary_nameic_ppm_start[0];
extern int _binary_nameic_ppm_size;
void gcons_redraw_console(void)
{
int i;
size_t hsize = (size_t)&_binary_helenos_ppm_size;
 
if (!use_gcons)
return;
155,7 → 191,10
vp_switch(0);
set_style(MAIN_COLOR, MAIN_COLOR);
clear();
draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-64, 0);
draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 10);
 
 
for (i=0;i < CONSOLE_COUNT; i++)
draw_stat(i, i == active_console ? CONS_ACTIVE : CONS_DISCONNECTED);
vp_switch(console_vp);
184,7 → 223,7
/* Create status buttons */
for (i=0; i < CONSOLE_COUNT; i++) {
cstatus_vp[i] = vp_create(CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
cstatus_vp[i] = vp_create(STATUS_START+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
CONSOLE_MARGIN, STATUS_WIDTH, STATUS_HEIGHT);
if (cstatus_vp[i] < 0)
return;
/uspace/trunk/console/Makefile
47,9 → 47,12
../kbd/generic/key_buffer.c \
gcons.c
 
IMAGES = helenos.ppm nameic.ppm
 
ARCH_SOURCES =
 
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) \
$(addsuffix .o,$(basename $(IMAGES)))
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
 
.PHONY: all clean depend disasm
78,3 → 81,6
 
%.o: %.c
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
 
%.o: %.ppm
$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@
/uspace/trunk/fb/ppm.h
0,0 → 1,37
/*
* 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 _PPM_H_
#define _PPM_H_
 
int draw_ppm(unsigned char *data, size_t datasz, unsigned int sx,
unsigned int sy,
unsigned int maxwidth, unsigned int maxheight,
void (*putpixel)(int,unsigned int, unsigned int, int),int vp);
 
#endif
/uspace/trunk/fb/main.c
39,23 → 39,16
#include "ega.h"
#include "main.h"
 
void receive_comm_area(ipc_callid_t callid, ipc_call_t *call, void **area,
size_t maxsize)
void receive_comm_area(ipc_callid_t callid, ipc_call_t *call, void **area)
{
void *dest;
 
if (*area) {
ipc_answer_fast(callid, ELIMIT, 0, 0);
return;
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);
*area = dest;
}
if (IPC_GET_ARG2(*call) > ALIGN_UP(maxsize, PAGE_SIZE)) {
ipc_answer_fast(callid, EINVAL, 0, 0);
return;
}
dest = as_get_mappable_page(maxsize);
if (ipc_answer_fast(callid, 0, (sysarg_t)dest, 0) == 0)
*area = dest;
}
 
int main(int argc, char *argv[])
/uspace/trunk/fb/fb.c
46,6 → 46,7
#include "fb.h"
#include "main.h"
#include "../console/screenbuffer.h"
#include "ppm.h"
 
#define DEFAULT_BGCOLOR 0x000080
#define DEFAULT_FGCOLOR 0xffff00
474,7 → 475,89
cursor_print(vp);
}
 
static int shm_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
{
static keyfield_t *interbuffer = NULL;
static size_t intersize = 0;
 
static char *pixmap = NULL;
static ipcarg_t pixmap_id = 0;
static size_t pixmap_size;
 
int handled = 1;
int retval = 0;
viewport_t *vport = &viewports[vp];
unsigned int x,y;
 
switch (IPC_GET_METHOD(*call)) {
case IPC_M_AS_AREA_SEND:
/* We accept one area for data interchange */
if (IPC_GET_ARG1(*call) == pixmap_id) {
void *dest = as_get_mappable_page(IPC_GET_ARG2(*call));
pixmap_size = IPC_GET_ARG2(*call);
if (!ipc_answer_fast(callid, 0, (sysarg_t)dest, 0))
pixmap = dest;
else
pixmap_id = 0;
if (pixmap[0] != 'P')
while (1)
;
return 1;
} else {
intersize = IPC_GET_ARG2(*call);
receive_comm_area(callid,call,(void **)&interbuffer);
}
return 1;
case FB_PREPARE_SHM:
if (pixmap_id)
retval = EBUSY;
else
pixmap_id = IPC_GET_ARG1(*call);
break;
case FB_DROP_SHM:
if (pixmap) {
as_area_destroy(pixmap);
pixmap = NULL;
}
pixmap_id = 0;
break;
case FB_DRAW_PPM:
if (!pixmap) {
retval = EINVAL;
break;
}
x = IPC_GET_ARG1(*call);
y = IPC_GET_ARG2(*call);
if (x > vport->width || y > vport->height) {
retval = EINVAL;
break;
}
draw_ppm(pixmap, pixmap_size, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call),
vport->width - x, vport->height - y, putpixel, vp);
break;
case FB_DRAW_TEXT_DATA:
if (!interbuffer) {
retval = EINVAL;
break;
}
if (intersize < vport->cols*vport->rows*sizeof(*interbuffer)) {
retval = EINVAL;
break;
}
draw_text_data(vp, interbuffer);
break;
default:
handled = 0;
}
if (handled)
ipc_answer_fast(callid, retval, 0, 0);
return handled;
}
 
/** Function for handling connections to FB
*
*/
486,8 → 569,6
int i;
unsigned int row,col;
char c;
keyfield_t *interbuffer = NULL;
size_t intersize = 0;
 
int vp = 0;
viewport_t *vport = &viewports[0];
505,6 → 586,9
cursor_blink(vp);
continue;
}
if (shm_handle(callid, &call, vp))
continue;
 
switch (IPC_GET_METHOD(call)) {
case IPC_M_PHONE_HUNGUP:
client_connected = 0;
513,25 → 597,7
vport->initialized = 0;
ipc_answer_fast(callid,0,0,0);
return; /* Exit thread */
case IPC_M_AS_AREA_SEND:
/* We accept one area for data interchange */
intersize = IPC_GET_ARG2(call);
receive_comm_area(callid,&call,(void **)&interbuffer,
sizeof(*interbuffer)*viewports[0].cols*viewports[0].rows);
continue;
 
case FB_DRAW_TEXT_DATA:
if (!interbuffer) {
retval = EINVAL;
break;
}
if (intersize < vport->cols*vport->rows*sizeof(*interbuffer)) {
retval = EINVAL;
break;
}
draw_text_data(vp, interbuffer);
retval = 0;
break;
case FB_PUTCHAR:
c = IPC_GET_ARG1(call);
row = IPC_GET_ARG2(call);
/uspace/trunk/fb/main.h
29,7 → 29,6
#ifndef __MAIN_H_
#define __MAIN_H_
 
void receive_comm_area(ipc_callid_t callid, ipc_call_t *call, void **area,
size_t maxsize);
void receive_comm_area(ipc_callid_t callid, ipc_call_t *call, void **area);
 
#endif
/uspace/trunk/fb/Makefile
49,7 → 49,8
font-8x16.c \
main.c \
sysio.c \
ega.c
ega.c \
ppm.c
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
/uspace/trunk/fb/ega.c
110,7 → 110,7
/* We accept one area for data interchange */
intersize = IPC_GET_ARG2(call);
if (intersize >= scr_width*scr_height*sizeof(*interbuf)) {
receive_comm_area(callid,&call,(void **)&interbuf, scr_width*scr_height*sizeof(*interbuf));
receive_comm_area(callid,&call,(void **)&interbuf);
continue;
}
retval = EINVAL;
/uspace/trunk/fb/ppm.c
0,0 → 1,112
/*
* 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 <types.h>
#include <errno.h>
 
#include "ppm.h"
 
static void skip_whitespace(unsigned char **data)
{
retry:
while (**data == ' ' || **data == '\t' || **data == '\n' || **data == '\r')
(*data)++;
if (**data == '#') {
while (1) {
if (**data == '\n' || **data == '\r')
break;
(*data)++;
}
goto retry;
}
}
 
static void read_num(unsigned char **data, unsigned int *num)
{
*num = 0;
while (**data >= '0' && **data <= '9') {
*num *= 10;
*num += **data - '0';
(*data)++;
}
}
 
/** Draw PPM pixmap
*
* @param data Pointer to PPM data
* @param datasz Maximum data size
* @param x Coordinate of upper left corner
* @param y Coordinate of upper left corner
* @param maxwidth Maximum allowed width for picture
* @param maxheight Maximum allowed height for picture
* @param putpixel Putpixel function used to print bitmap
*/
int draw_ppm(unsigned char *data, size_t datasz, unsigned int sx,
unsigned int sy,
unsigned int maxwidth, unsigned int maxheight,
void (*putpixel)(int,unsigned int, unsigned int, int),int vp)
{
unsigned int width, height;
unsigned int maxcolor;
int i;
void *maxdatap = data + datasz;
unsigned int color;
unsigned int coef;
 
/* Read magic */
if (data[0] != 'P' || data[1] != '6')
return EINVAL;
 
data+=2;
skip_whitespace(&data);
read_num(&data, &width);
skip_whitespace(&data);
read_num(&data,&height);
skip_whitespace(&data);
read_num(&data,&maxcolor);
data++;
 
if (maxcolor == 0 || maxcolor > 255 || width*height > datasz) {
return EINVAL;
}
coef = 255/maxcolor;
if (coef*maxcolor > 255)
coef -= 1;
for (i=0; i < width*height; i++) {
/* Crop picture if we don't fit into region */
if (i % width > maxwidth || i/width > maxheight) {
data += 3;
continue;
}
color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[0]*coef;
(*putpixel)(vp, sx+(i % width), sy+(i / width), color);
data += 3;
}
}
/uspace/trunk/libc/include/async.h
46,6 → 46,8
 
aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
ipc_call_t *dataptr);
aid_t async_send_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
ipcarg_t arg3, ipc_call_t *dataptr);
void async_wait_for(aid_t amsgid, ipcarg_t *result);
int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout);
 
68,8 → 70,25
*r2 = IPC_GET_ARG2(result);
return rc;
}
static inline ipcarg_t sync_send_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, ipcarg_t arg3, ipcarg_t *r1,
ipcarg_t *r2, ipcarg_t *r3)
{
ipc_call_t result;
ipcarg_t rc;
 
aid_t eid = async_send_3(phoneid, method, arg1, arg2, arg3, &result);
async_wait_for(eid, &rc);
if (r1)
*r1 = IPC_GET_ARG1(result);
if (r2)
*r2 = IPC_GET_ARG2(result);
if (r3)
*r3 = IPC_GET_ARG3(result);
return rc;
}
 
 
pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
ipc_call_t *call,
void (*cthread)(ipc_callid_t,ipc_call_t *));
/uspace/trunk/libc/include/ipc/fb.h
20,4 → 20,8
#define FB_DRAW_TEXT_DATA 1036
#define FB_FLUSH 1037
 
#define FB_DRAW_PPM 1038
#define FB_PREPARE_SHM 1039
#define FB_DROP_SHM 1040
 
#endif
/uspace/trunk/libc/include/sys/mman.h
31,6 → 31,8
 
#include <as.h>
 
#define MAP_FAILED ((void *) -1)
 
#define MAP_SHARED (1 << 0)
#define MAP_PRIVATE (1 << 1)
#define MAP_FIXED (1 << 2)
/uspace/trunk/libc/generic/time.c
73,7 → 73,7
printf("Failed to initialize timeofday memarea\n");
_exit(1);
}
if (rights != (AS_AREA_READ | AS_AREA_CACHEABLE)) {
if (! (rights & AS_AREA_READ)) {
printf("Received bad rights on time area: %X\n",
rights);
as_area_destroy(mapping);
/uspace/trunk/libc/generic/async.c
623,6 → 623,27
return (aid_t) msg;
}
 
/** Send message and return id of the sent message
*
* The return value can be used as input for async_wait() to wait
* for completion.
*/
aid_t async_send_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
ipcarg_t arg3, ipc_call_t *dataptr)
{
amsg_t *msg;
 
msg = malloc(sizeof(*msg));
msg->done = 0;
msg->dataptr = dataptr;
 
msg->wdata.active = 1; /* We may sleep in next method, but it
* will use it's own mechanism */
ipc_call_async_3(phoneid,method,arg1,arg2,arg3, msg,reply_received,1);
 
return (aid_t) msg;
}
 
/** Wait for a message sent by async framework
*
* @param amsgid Message ID to wait for
/uspace/trunk/libc/generic/mmap.c
33,15 → 33,15
void *mmap(void *start, size_t length, int prot, int flags, int fd,
off_t offset)
{
int rc;
 
if (!start)
start = as_get_mappable_page(length);
prot |= AS_AREA_CACHEABLE;
// if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
// return NULL;
// return MAP_FAILED;
if (! (flags & MAP_ANONYMOUS))
return NULL;
return MAP_FAILED;
 
return as_area_create(start, length, prot);
}
/uspace/trunk/libc/arch/ia64/Makefile.inc
38,3 → 38,6
ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
arch/$(ARCH)/src/psthread.S \
arch/$(ARCH)/src/thread.c
 
BFD_NAME = elf64-little
BFD_ARCH = ia64-elf64
/uspace/trunk/libc/arch/mips32eb/Makefile.inc
31,9 → 31,13
 
TARGET = mips-sgi-irix5
TOOLCHAIN_DIR = /usr/local/mips/bin
CFLAGS += -mno-abicalls -mips3
CFLAGS += -mips3
 
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
arch/$(ARCH)/src/psthread.S \
arch/$(ARCH)/src/thread.c
 
LFLAGS += -N
 
BFD_ARCH = mips
BFD_NAME = elf32-big
/uspace/trunk/libc/arch/ppc32/Makefile.inc
39,3 → 39,6
CFLAGS += -mcpu=powerpc -msoft-float -m32
AFLAGS += -a32
LFLAGS += -N
 
BFD_NAME = elf32-powerpc
BFD_ARCH = powerpc:common
/uspace/trunk/libc/arch/amd64/Makefile.inc
37,3 → 37,6
arch/$(ARCH)/src/thread.c
 
LFLAGS += -N
 
BFD_NAME = elf64-x86-64
BFD_ARCH = i386:x86-64
/uspace/trunk/libc/arch/mips32/Makefile.inc
37,4 → 37,5
arch/$(ARCH)/src/psthread.S \
arch/$(ARCH)/src/thread.c
 
 
BFD_ARCH = mips
BFD_NAME = elf32-little
/uspace/trunk/libc/arch/ia32/Makefile.inc
37,3 → 37,6
arch/$(ARCH)/src/thread.c
 
LFLAGS += -N
 
BFD_NAME = elf32-i386
BFD_ARCH = i386