/uspace/trunk/console/gcons.c |
---|
0,0 → 1,505 |
/* |
* 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. |
*/ |
/** @addtogroup console |
* @{ |
*/ |
/** @file |
*/ |
#include <ipc/fb.h> |
#include <ipc/ipc.h> |
#include <async.h> |
#include <stdio.h> |
#include <sys/mman.h> |
#include <string.h> |
#include <align.h> |
#include "console.h" |
#include "gcons.h" |
#define CONSOLE_TOP 66 |
#define CONSOLE_MARGIN 6 |
#define STATUS_START 110 |
#define STATUS_TOP 8 |
#define STATUS_SPACE 4 |
#define STATUS_WIDTH 48 |
#define STATUS_HEIGHT 48 |
#define MAIN_COLOR 0xffffff |
static int use_gcons = 0; |
static ipcarg_t xres,yres; |
enum butstate { |
CONS_DISCONNECTED = 0, |
CONS_SELECTED, |
CONS_IDLE, |
CONS_HAS_DATA, |
CONS_KERNEL, |
CONS_DISCONNECTED_SEL, |
CONS_LAST |
}; |
static int console_vp; |
static int cstatus_vp[CONSOLE_COUNT]; |
static int cstat_row, cstat_col; /* Size of cstatus buttons */ |
static enum butstate console_state[CONSOLE_COUNT]; |
static int fbphone; |
/** List of pixmaps identifying these icons */ |
static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1}; |
static int animation = -1; |
static int active_console = 0; |
static void vp_switch(int vp) |
{ |
async_msg(fbphone,FB_VIEWPORT_SWITCH, vp); |
} |
/** Create view port */ |
static int vp_create(unsigned int x, unsigned int y, |
unsigned int width, unsigned int height) |
{ |
return async_req_2(fbphone, FB_VIEWPORT_CREATE, |
(x << 16) | y, (width << 16) | height, |
NULL, NULL); |
} |
static void clear(void) |
{ |
async_msg(fbphone, FB_CLEAR, 0); |
} |
static void set_style(int fgcolor, int bgcolor) |
{ |
async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor); |
} |
/** Transparent putchar */ |
static void tran_putch(char c, int row, int col) |
{ |
async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col); |
} |
/** Redraw the button showing state of a given console */ |
static void redraw_state(int consnum) |
{ |
char data[5]; |
int i; |
enum butstate state = console_state[consnum]; |
vp_switch(cstatus_vp[consnum]); |
if (ic_pixmaps[state] != -1) |
async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]); |
if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) { |
snprintf(data, 5, "%d", consnum+1); |
for (i=0;data[i];i++) |
tran_putch(data[i], 1, 2+i); |
} |
} |
/** Notification run on changing console (except kernel console) */ |
void gcons_change_console(int consnum) |
{ |
int i; |
if (!use_gcons) |
return; |
if (active_console == KERNEL_CONSOLE) { |
for (i=0; i < CONSOLE_COUNT; i++) |
redraw_state(i); |
if (animation != -1) |
async_msg(fbphone, FB_ANIM_START, animation); |
} else { |
if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
console_state[active_console] = CONS_DISCONNECTED; |
else |
console_state[active_console] = CONS_IDLE; |
redraw_state(active_console); |
} |
active_console = consnum; |
if (console_state[consnum] == CONS_DISCONNECTED) { |
console_state[consnum] = CONS_DISCONNECTED_SEL; |
redraw_state(consnum); |
} else |
console_state[consnum] = CONS_SELECTED; |
redraw_state(consnum); |
vp_switch(console_vp); |
} |
/** Notification function that gets called on new output to virtual console */ |
void gcons_notify_char(int consnum) |
{ |
if (!use_gcons) |
return; |
if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA) |
return; |
console_state[consnum] = CONS_HAS_DATA; |
if (active_console == KERNEL_CONSOLE) |
return; |
redraw_state(consnum); |
vp_switch(console_vp); |
} |
/** Notification function called on service disconnect from console */ |
void gcons_notify_disconnect(int consnum) |
{ |
if (!use_gcons) |
return; |
if (active_console == consnum) |
console_state[consnum] = CONS_DISCONNECTED_SEL; |
else |
console_state[consnum] = CONS_DISCONNECTED; |
if (active_console == KERNEL_CONSOLE) |
return; |
redraw_state(consnum); |
vp_switch(console_vp); |
} |
/** Notification function called on console connect */ |
void gcons_notify_connect(int consnum) |
{ |
if (!use_gcons) |
return; |
if (active_console == consnum) |
console_state[consnum] = CONS_SELECTED; |
else |
console_state[consnum] = CONS_IDLE; |
if (active_console == KERNEL_CONSOLE) |
return; |
redraw_state(consnum); |
vp_switch(console_vp); |
} |
/** Change to kernel console */ |
void gcons_in_kernel(void) |
{ |
if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
console_state[active_console] = CONS_DISCONNECTED; |
else |
console_state[active_console] = CONS_IDLE; |
redraw_state(active_console); |
if (animation != -1) |
async_msg(fbphone, FB_ANIM_STOP, animation); |
active_console = KERNEL_CONSOLE; /* Set to kernel console */ |
vp_switch(0); |
} |
static inline int limit(int a,int left, int right) |
{ |
if (a < left) |
a = left; |
if (a >= right) |
a = right - 1; |
return a; |
} |
int mouse_x, mouse_y; |
int btn_pressed, btn_x, btn_y; |
/** Handle mouse move |
* |
* @param dx Delta X of mouse move |
* @param dy Delta Y of mouse move |
*/ |
void gcons_mouse_move(int dx, int dy) |
{ |
mouse_x = limit(mouse_x+dx, 0, xres); |
mouse_y = limit(mouse_y+dy, 0, yres); |
async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); |
} |
static int gcons_find_conbut(int x, int y) |
{ |
int status_start = STATUS_START + (xres-800) / 2;; |
if (y < STATUS_TOP || y >= STATUS_TOP+STATUS_HEIGHT) |
return -1; |
if (x < status_start) |
return -1; |
if (x >= status_start + (STATUS_WIDTH+STATUS_SPACE)*CONSOLE_COUNT) |
return -1; |
if (((x - status_start) % (STATUS_WIDTH+STATUS_SPACE)) < STATUS_SPACE) |
return -1; |
return (x-status_start) / (STATUS_WIDTH+STATUS_SPACE); |
} |
/** Handle mouse click |
* |
* @param state New state (1-pressed, 0-depressed) |
*/ |
int gcons_mouse_btn(int state) |
{ |
int conbut; |
if (state) { |
conbut = gcons_find_conbut(mouse_x, mouse_y); |
if (conbut != -1) { |
btn_pressed = 1; |
btn_x = mouse_x; |
btn_y = mouse_y; |
} |
return -1; |
} |
if (!state && !btn_pressed) |
return -1; |
btn_pressed = 0; |
conbut = gcons_find_conbut(mouse_x, mouse_y); |
if (conbut == gcons_find_conbut(btn_x, btn_y)) |
return conbut; |
return -1; |
} |
/** Draw a PPM pixmap to framebuffer |
* |
* @param logo Pointer to PPM data |
* @param size Size of PPM data |
* @param x Coordinate of upper left corner |
* @param y Coordinate of upper left corner |
*/ |
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 = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
if (rc) |
goto exit; |
rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
if (rc) |
goto drop; |
/* Draw logo */ |
async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
drop: |
/* Drop area */ |
async_msg(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; |
/** Redraws console graphics */ |
static void gcons_redraw_console(void) |
{ |
int i; |
size_t hsize = (size_t)&_binary_helenos_ppm_size; |
if (!use_gcons) |
return; |
vp_switch(0); |
set_style(MAIN_COLOR, MAIN_COLOR); |
clear(); |
draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2); |
draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17); |
for (i=0;i < CONSOLE_COUNT; i++) |
redraw_state(i); |
vp_switch(console_vp); |
} |
/** Creates a pixmap on framebuffer |
* |
* @param data PPM data |
* @param size PPM data size |
* @return Pixmap identification |
*/ |
static int make_pixmap(char *data, int size) |
{ |
char *shm; |
int rc; |
int pxid = -1; |
/* Create area */ |
shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
if (shm == MAP_FAILED) |
return -1; |
memcpy(shm, data, size); |
/* Send area */ |
rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
if (rc) |
goto exit; |
rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
if (rc) |
goto drop; |
/* Obtain pixmap */ |
rc = async_req(fbphone, FB_SHM2PIXMAP, 0, NULL); |
if (rc < 0) |
goto drop; |
pxid = rc; |
drop: |
/* Drop area */ |
async_msg(fbphone, FB_DROP_SHM, 0); |
exit: |
/* Remove area */ |
munmap(shm, size); |
return pxid; |
} |
extern char _binary_anim_1_ppm_start[0]; |
extern int _binary_anim_1_ppm_size; |
extern char _binary_anim_2_ppm_start[0]; |
extern int _binary_anim_2_ppm_size; |
extern char _binary_anim_3_ppm_start[0]; |
extern int _binary_anim_3_ppm_size; |
extern char _binary_anim_4_ppm_start[0]; |
extern int _binary_anim_4_ppm_size; |
static void make_anim(void) |
{ |
int an; |
int pm; |
an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE], NULL); |
if (an < 0) |
return; |
pm = make_pixmap(_binary_anim_1_ppm_start, (int)&_binary_anim_1_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
pm = make_pixmap(_binary_anim_2_ppm_start, (int)&_binary_anim_2_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
pm = make_pixmap(_binary_anim_3_ppm_start, (int)&_binary_anim_3_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
pm = make_pixmap(_binary_anim_4_ppm_start, (int)&_binary_anim_4_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
async_msg(fbphone, FB_ANIM_START, an); |
animation = an; |
} |
extern char _binary_cons_selected_ppm_start[0]; |
extern int _binary_cons_selected_ppm_size; |
extern char _binary_cons_idle_ppm_start[0]; |
extern int _binary_cons_idle_ppm_size; |
extern char _binary_cons_has_data_ppm_start[0]; |
extern int _binary_cons_has_data_ppm_size; |
extern char _binary_cons_kernel_ppm_start[0]; |
extern int _binary_cons_kernel_ppm_size; |
/** Initialize nice graphical console environment */ |
void gcons_init(int phone) |
{ |
int rc; |
int i; |
int status_start = STATUS_START; |
fbphone = phone; |
rc = async_req_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres); |
if (rc) |
return; |
if (xres < 800 || yres < 600) |
return; |
/* create console viewport */ |
/* Align width & height to character size */ |
console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8), |
ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16)); |
if (console_vp < 0) |
return; |
/* Create status buttons */ |
status_start += (xres-800) / 2; |
for (i=0; i < CONSOLE_COUNT; i++) { |
cstatus_vp[i] = vp_create(status_start+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE), |
STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT); |
if (cstatus_vp[i] < 0) |
return; |
vp_switch(cstatus_vp[i]); |
set_style(0x202020, 0xffffff); |
} |
/* Initialize icons */ |
ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start, |
(int)&_binary_cons_selected_ppm_size); |
ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
(int)&_binary_cons_idle_ppm_size); |
ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start, |
(int)&_binary_cons_has_data_ppm_size); |
ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start, |
(int)&_binary_cons_idle_ppm_size); |
ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
(int)&_binary_cons_kernel_ppm_size); |
ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
make_anim(); |
use_gcons = 1; |
console_state[0] = CONS_DISCONNECTED_SEL; |
console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
gcons_redraw_console(); |
} |
/** @} |
*/ |
/uspace/trunk/console/console.c |
---|
0,0 → 1,534 |
/* |
* Copyright (C) 2006 Josef Cejka |
* 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. |
*/ |
/** @defgroup console Console |
* @brief HelenOS console. |
* @{ |
*/ |
/** @file |
*/ |
/* TODO: remove */ |
#include <stdio.h> |
#include <fb.h> |
#include <ipc/ipc.h> |
#include <keys.h> |
#include <ipc/fb.h> |
#include <ipc/services.h> |
#include <errno.h> |
#include <key_buffer.h> |
#include <console.h> |
#include <unistd.h> |
#include <async.h> |
#include <libadt/fifo.h> |
#include <screenbuffer.h> |
#include <sys/mman.h> |
#include "gcons.h" |
#define MAX_KEYREQUESTS_BUFFERED 32 |
#define NAME "CONSOLE" |
/** Index of currently used virtual console. |
*/ |
int active_console = 0; |
/** Information about framebuffer |
*/ |
struct { |
int phone; /**< Framebuffer phone */ |
ipcarg_t rows; /**< Framebuffer rows */ |
ipcarg_t cols; /**< Framebuffer columns */ |
} fb_info; |
typedef struct { |
keybuffer_t keybuffer; /**< Buffer for incoming keys. */ |
FIFO_CREATE_STATIC(keyrequests, ipc_callid_t , MAX_KEYREQUESTS_BUFFERED); /**< Buffer for unsatisfied request for keys. */ |
int keyrequest_counter; /**< Number of requests in buffer. */ |
int client_phone; /**< Phone to connected client. */ |
int used; /**< 1 if this virtual console is connected to some client.*/ |
screenbuffer_t screenbuffer; /**< Screenbuffer for saving screen contents and related settings. */ |
} connection_t; |
static connection_t connections[CONSOLE_COUNT]; /**< Array of data for virtual consoles */ |
static keyfield_t *interbuffer = NULL; /**< Pointer to memory shared with framebufer used for faster virt. console switching */ |
static int kernel_pixmap = -1; /**< Number of fb pixmap, where kernel console is stored */ |
/** Find unused virtual console. |
* |
*/ |
static int find_free_connection(void) |
{ |
int i = 0; |
for (i=0; i < CONSOLE_COUNT; i++) { |
if (!connections[i].used) |
return i; |
} |
return -1; |
} |
static void clrscr(void) |
{ |
async_msg(fb_info.phone, FB_CLEAR, 0); |
} |
static void curs_visibility(int v) |
{ |
async_msg(fb_info.phone, FB_CURSOR_VISIBILITY, v); |
} |
static void curs_goto(int row, int col) |
{ |
async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col); |
} |
static void set_style(style_t *style) |
{ |
async_msg_2(fb_info.phone, FB_SET_STYLE, style->fg_color, style->bg_color); |
} |
static void set_style_col(int fgcolor, int bgcolor) |
{ |
async_msg_2(fb_info.phone, FB_SET_STYLE, fgcolor, bgcolor); |
} |
static void prtchr(char c, int row, int col) |
{ |
async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col); |
} |
/** Check key and process special keys. |
* |
* */ |
static void write_char(int console, char key) |
{ |
screenbuffer_t *scr = &(connections[console].screenbuffer); |
switch (key) { |
case '\n': |
scr->position_y += 1; |
scr->position_x = 0; |
break; |
case '\r': |
break; |
case '\t': |
scr->position_x += 8; |
scr->position_x -= scr->position_x % 8; |
break; |
case '\b': |
if (scr->position_x == 0) |
break; |
scr->position_x--; |
if (console == active_console) |
prtchr(' ', scr->position_y, scr->position_x); |
screenbuffer_putchar(scr, ' '); |
break; |
default: |
if (console == active_console) |
prtchr(key, scr->position_y, scr->position_x); |
screenbuffer_putchar(scr, key); |
scr->position_x++; |
} |
scr->position_y += (scr->position_x >= scr->size_x); |
if (scr->position_y >= scr->size_y) { |
scr->position_y = scr->size_y - 1; |
screenbuffer_clear_line(scr, scr->top_line); |
scr->top_line = (scr->top_line+1) % scr->size_y; |
if (console == active_console) |
async_msg(fb_info.phone, FB_SCROLL, 1); |
} |
scr->position_x = scr->position_x % scr->size_x; |
if (console == active_console) |
curs_goto(scr->position_y, scr->position_x); |
} |
/** Save current screen to pixmap, draw old pixmap |
* |
* @param oldpixmap Old pixmap |
* @return ID of pixmap of current screen |
*/ |
static int switch_screens(int oldpixmap) |
{ |
int newpmap; |
/* Save screen */ |
newpmap = async_req(fb_info.phone, FB_VP2PIXMAP, 0, NULL); |
if (newpmap < 0) |
return -1; |
if (oldpixmap != -1) { |
/* Show old screen */ |
async_msg_2(fb_info.phone, FB_VP_DRAW_PIXMAP, 0, oldpixmap); |
/* Drop old pixmap */ |
async_msg(fb_info.phone, FB_DROP_PIXMAP, oldpixmap); |
} |
return newpmap; |
} |
/** Switch to new console */ |
static void change_console(int newcons) |
{ |
connection_t *conn; |
static int console_pixmap = -1; |
int i, j, rc; |
keyfield_t *field; |
style_t *style; |
char c; |
if (newcons == active_console) |
return; |
if (newcons == KERNEL_CONSOLE) { |
if (active_console == KERNEL_CONSOLE) |
return; |
active_console = KERNEL_CONSOLE; |
curs_visibility(0); |
async_serialize_start(); |
if (kernel_pixmap == -1) { |
/* store/restore unsupported */ |
set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); |
clrscr(); |
} else { |
gcons_in_kernel(); |
console_pixmap = switch_screens(kernel_pixmap); |
kernel_pixmap = -1; |
} |
async_serialize_end(); |
__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE); |
return; |
} |
async_serialize_start(); |
if (console_pixmap != -1) { |
kernel_pixmap = switch_screens(console_pixmap); |
console_pixmap = -1; |
} |
active_console = newcons; |
gcons_change_console(newcons); |
conn = &connections[active_console]; |
set_style(&conn->screenbuffer.style); |
curs_visibility(0); |
if (interbuffer) { |
for (i = 0; i < conn->screenbuffer.size_x; i++) |
for (j = 0; j < conn->screenbuffer.size_y; j++) |
interbuffer[i + j*conn->screenbuffer.size_x] = *get_field_at(&(conn->screenbuffer),i, j); |
/* This call can preempt, but we are already at the end */ |
rc = async_req_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL); |
}; |
if ((!interbuffer) || (rc != 0)) { |
set_style(&conn->screenbuffer.style); |
clrscr(); |
style = &conn->screenbuffer.style; |
for (j = 0; j < conn->screenbuffer.size_y; j++) |
for (i = 0; i < conn->screenbuffer.size_x; i++) { |
field = get_field_at(&(conn->screenbuffer),i, j); |
if (!style_same(*style, field->style)) |
set_style(&field->style); |
style = &field->style; |
if ((field->character == ' ') && (style_same(field->style, conn->screenbuffer.style))) |
continue; |
prtchr(field->character, j, i); |
} |
} |
curs_goto(conn->screenbuffer.position_y, conn->screenbuffer.position_x); |
curs_visibility(conn->screenbuffer.is_cursor_visible); |
async_serialize_end(); |
} |
/** Handler for keyboard */ |
static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall) |
{ |
ipc_callid_t callid; |
ipc_call_t call; |
int retval; |
int c; |
connection_t *conn; |
int newcon; |
/* Ignore parameters, the connection is alread opened */ |
while (1) { |
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
/* TODO: Handle hangup */ |
return; |
case KBD_MS_LEFT: |
newcon = gcons_mouse_btn(IPC_GET_ARG1(call)); |
if (newcon != -1) |
change_console(newcon); |
break; |
case KBD_MS_MOVE: |
gcons_mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
break; |
case KBD_PUSHCHAR: |
/* got key from keyboard driver */ |
retval = 0; |
c = IPC_GET_ARG1(call); |
/* switch to another virtual console */ |
conn = &connections[active_console]; |
// if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { |
if ((c >= 0x101) && (c < 0x101 + CONSOLE_COUNT)) { |
if (c == 0x112) |
change_console(KERNEL_CONSOLE); |
else |
change_console(c - 0x101); |
break; |
} |
/* if client is awaiting key, send it */ |
if (conn->keyrequest_counter > 0) { |
conn->keyrequest_counter--; |
ipc_answer_fast(fifo_pop(conn->keyrequests), 0, c, 0); |
break; |
} |
/*FIXME: else store key to its buffer */ |
keybuffer_push(&conn->keybuffer, c); |
break; |
default: |
retval = ENOENT; |
} |
ipc_answer_fast(callid, retval, 0, 0); |
} |
} |
/** Default thread for new connections */ |
static void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
ipc_callid_t callid; |
ipc_call_t call; |
int consnum; |
ipcarg_t arg1, arg2; |
connection_t *conn; |
if ((consnum = find_free_connection()) == -1) { |
ipc_answer_fast(iid,ELIMIT,0,0); |
return; |
} |
conn = &connections[consnum]; |
conn->used = 1; |
async_serialize_start(); |
gcons_notify_connect(consnum); |
conn->client_phone = IPC_GET_ARG3(call); |
screenbuffer_clear(&conn->screenbuffer); |
/* Accept the connection */ |
ipc_answer_fast(iid,0,0,0); |
while (1) { |
async_serialize_end(); |
callid = async_get_call(&call); |
async_serialize_start(); |
arg1 = arg2 = 0; |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
gcons_notify_disconnect(consnum); |
/* Answer all pending requests */ |
while (conn->keyrequest_counter > 0) { |
conn->keyrequest_counter--; |
ipc_answer_fast(fifo_pop(conn->keyrequests), ENOENT, 0, 0); |
break; |
} |
conn->used = 0; |
return; |
case CONSOLE_PUTCHAR: |
write_char(consnum, IPC_GET_ARG1(call)); |
gcons_notify_char(consnum); |
break; |
case CONSOLE_CLEAR: |
/* Send message to fb */ |
if (consnum == active_console) { |
async_msg(fb_info.phone, FB_CLEAR, 0); |
} |
screenbuffer_clear(&conn->screenbuffer); |
break; |
case CONSOLE_GOTO: |
screenbuffer_goto(&conn->screenbuffer, IPC_GET_ARG2(call), IPC_GET_ARG1(call)); |
if (consnum == active_console) |
curs_goto(IPC_GET_ARG1(call),IPC_GET_ARG2(call)); |
break; |
case CONSOLE_GETSIZE: |
arg1 = fb_info.rows; |
arg2 = fb_info.cols; |
break; |
case CONSOLE_FLUSH: |
async_req_2(fb_info.phone, FB_FLUSH, 0, 0, NULL, NULL); |
break; |
case CONSOLE_SET_STYLE: |
arg1 = IPC_GET_ARG1(call); |
arg2 = IPC_GET_ARG2(call); |
screenbuffer_set_style(&conn->screenbuffer,arg1, arg2); |
if (consnum == active_console) |
set_style_col(arg1, arg2); |
break; |
case CONSOLE_CURSOR_VISIBILITY: |
arg1 = IPC_GET_ARG1(call); |
conn->screenbuffer.is_cursor_visible = arg1; |
if (consnum == active_console) |
curs_visibility(arg1); |
break; |
case CONSOLE_GETCHAR: |
if (keybuffer_empty(&conn->keybuffer)) { |
/* buffer is empty -> store request */ |
if (conn->keyrequest_counter < MAX_KEYREQUESTS_BUFFERED) { |
fifo_push(conn->keyrequests, callid); |
conn->keyrequest_counter++; |
} else { |
/* no key available and too many requests => fail */ |
ipc_answer_fast(callid, ELIMIT, 0, 0); |
} |
continue; |
}; |
keybuffer_pop(&conn->keybuffer, (int *)&arg1); |
break; |
} |
ipc_answer_fast(callid, 0, arg1, arg2); |
} |
} |
int main(int argc, char *argv[]) |
{ |
ipcarg_t phonehash; |
int kbd_phone, fb_phone; |
ipcarg_t retval, arg1 = 0xdead, arg2 = 0xbeef; |
int i; |
async_set_client_connection(client_connection); |
/* Connect to keyboard driver */ |
while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) { |
usleep(10000); |
}; |
if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
return -1; |
}; |
async_new_connection(phonehash, 0, NULL, keyboard_events); |
/* Connect to framebuffer driver */ |
while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) { |
usleep(10000); |
} |
/* Save old kernel screen */ |
kernel_pixmap = switch_screens(-1); |
/* Initialize gcons */ |
gcons_init(fb_info.phone); |
/* Synchronize, the gcons can have something in queue */ |
async_req(fb_info.phone, FB_FLUSH, 0, NULL); |
/* Enable double buffering */ |
async_msg_2(fb_info.phone, FB_VIEWPORT_DB, (sysarg_t)-1, 1); |
async_req_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols)); |
set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); |
clrscr(); |
/* Init virtual consoles */ |
for (i = 0; i < CONSOLE_COUNT; i++) { |
connections[i].used = 0; |
keybuffer_init(&(connections[i].keybuffer)); |
connections[i].keyrequests.head = connections[i].keyrequests.tail = 0; |
connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED; |
connections[i].keyrequest_counter = 0; |
if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) { |
/*FIXME: handle error */ |
return -1; |
} |
} |
connections[KERNEL_CONSOLE].used = 1; |
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 (async_req_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; |
} |
} |
curs_goto(0,0); |
curs_visibility(connections[active_console].screenbuffer.is_cursor_visible); |
/* Register at NS */ |
if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
return -1; |
}; |
async_manager(); |
return 0; |
} |
/** @} |
*/ |
/uspace/trunk/console/gcons.h |
---|
0,0 → 1,51 |
/* |
* 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. |
*/ |
/** @addtogroup console |
* @{ |
*/ |
/** @file |
*/ |
#ifndef _GCONS_H_ |
#define _GCONS_H_ |
void gcons_init(int phone); |
void gcons_change_console(int consnum); |
void gcons_notify_char(int consnum); |
void gcons_in_kernel(void); |
void gcons_notify_connect(int consnum); |
void gcons_notify_disconnect(int consnum); |
void gcons_mouse_move(int dx, int dy); |
int gcons_mouse_btn(int state); |
#endif |
/** @} |
*/ |
/uspace/trunk/console/console.h |
---|
0,0 → 1,56 |
/* |
* Copyright (C) 2006 Josef Cejka |
* 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. |
*/ |
/** @addtogroup console |
* @{ |
*/ |
/** @file |
*/ |
#ifndef __CONSOLE_H__ |
#define __CONSOLE_H__ |
#define KERNEL_CONSOLE 11 |
#define CONSOLE_COUNT 12 |
#define CONSOLE_GETCHAR 1026 |
#define CONSOLE_PUTCHAR 1027 |
#define CONSOLE_CLEAR 1028 |
#define CONSOLE_GOTO 1029 |
#define CONSOLE_GETSIZE 1030 |
#define CONSOLE_FLUSH 1031 |
#define CONSOLE_SET_STYLE 1032 |
#define CONSOLE_CURSOR_VISIBILITY 1033 |
#endif |
/** @} |
*/ |
/uspace/trunk/console/screenbuffer.c |
---|
0,0 → 1,145 |
/* |
* Copyright (C) 2006 Josef Cejka |
* 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. |
*/ |
/** @addtogroup console |
* @{ |
*/ |
/** @file |
*/ |
#include <screenbuffer.h> |
#include <malloc.h> |
#include <unistd.h> |
/** Store one character to screenbuffer. Its position is determined by scr->position_x and scr->position_y. |
* @param scr screenbuffer |
* @param c stored character |
*/ |
void screenbuffer_putchar(screenbuffer_t *scr, char c) |
{ |
keyfield_t *field; |
field = get_field_at(scr, scr->position_x, scr->position_y); |
field->character = c; |
field->style = scr->style; |
} |
/** Initilize screenbuffer. Allocate space for screen content in accordance to given size. |
* @param scr initialized screenbuffer |
* @param size_x width in characters |
* @param size_y height in characters |
* @return pointer to screenbuffer (same as scr parameter) or NULL |
*/ |
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y) |
{ |
if ((scr->buffer = (keyfield_t *)malloc(sizeof(keyfield_t) * size_x * size_y)) == NULL) { |
return NULL; |
} |
scr->size_x = size_x; |
scr->size_y = size_y; |
scr->style.fg_color = DEFAULT_FOREGROUND; |
scr->style.bg_color = DEFAULT_BACKGROUND; |
scr->is_cursor_visible = 1; |
screenbuffer_clear(scr); |
return scr; |
} |
/** Clear screenbuffer. |
* @param scr screenbuffer |
*/ |
void screenbuffer_clear(screenbuffer_t *scr) |
{ |
unsigned int i; |
for (i = 0; i < (scr->size_x * scr->size_y); i++) { |
scr->buffer[i].character = ' '; |
scr->buffer[i].style = scr->style; |
} |
scr->top_line = 0; |
scr->position_y = 0; |
scr->position_x = 0; |
} |
/** Clear one buffer line. |
* @param scr |
* @param line One buffer line (not a screen line!) |
*/ |
void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line) |
{ |
unsigned int i; |
for (i = 0; i < scr->size_x; i++) { |
scr->buffer[i + line*scr->size_x].character = ' '; |
scr->buffer[i + line*scr->size_x].style = scr->style; |
} |
} |
/** Copy content buffer from screenbuffer to given memory. |
* @param scr source screenbuffer |
* @param dest destination |
*/ |
void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest) |
{ |
unsigned int i; |
for (i = 0; i < scr->size_x * scr->size_y; i++) { |
dest[i] = scr->buffer[i]; |
} |
} |
/** Set new cursor position in screenbuffer. |
* @param scr |
* @param x |
* @param y |
*/ |
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y) |
{ |
scr->position_x = x % scr->size_x; |
scr->position_y = y % scr->size_y; |
} |
/** Set new style. |
* @param scr |
* @param fg_color |
* @param bg_color |
*/ |
void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color) |
{ |
scr->style.fg_color = fg_color; |
scr->style.bg_color = bg_color; |
} |
/** @} |
*/ |
/uspace/trunk/console/screenbuffer.h |
---|
0,0 → 1,100 |
/* |
* Copyright (C) 2006 Josef Cejka |
* 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. |
*/ |
/** @addtogroup console |
* @{ |
*/ |
/** @file |
*/ |
#ifndef __SCREENBUFFER_H__ |
#define __SCREENBUFFER_H__ |
#define DEFAULT_FOREGROUND 0x0 /**< default console foreground color */ |
#define DEFAULT_BACKGROUND 0xf0f0f0 /**< default console background color */ |
typedef struct { |
unsigned int bg_color; /**< background color */ |
unsigned int fg_color; /**< foreground color */ |
} style_t; |
/** One field on screen. It contain one character and its attributes. */ |
typedef struct { |
char character; /**< Character itself */ |
style_t style; /**< Character`s attributes */ |
} keyfield_t; |
/** Structure for buffering state of one virtual console. |
*/ |
typedef struct { |
keyfield_t *buffer; /**< Screen content - characters and its style. Used as cyclyc buffer. */ |
unsigned int size_x, size_y; /**< Number of columns and rows */ |
unsigned int position_x, position_y; /**< Coordinates of last printed character for determining cursor position */ |
style_t style; /**< Current style */ |
unsigned int top_line; /**< Points to buffer[][] line that will be printed at screen as the first line */ |
unsigned char is_cursor_visible; /**< Cursor state - default is visible */ |
} screenbuffer_t; |
/** Returns keyfield for position on screen. Screenbuffer->buffer is cyclic buffer so we must couted in index of the topmost line. |
* @param scr screenbuffer |
* @param x position on screen |
* @param y position on screen |
* @return keyfield structure with character and its attributes on x,y |
*/ |
static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y) |
{ |
return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x; |
} |
/** Compares two styles. |
* @param s1 first style |
* @param s2 second style |
* @return nonzero on equality |
*/ |
static inline int style_same(style_t s1, style_t s2) |
{ |
return s1.fg_color == s2.fg_color && s1.bg_color == s2.bg_color; |
} |
void screenbuffer_putchar(screenbuffer_t *scr, char c); |
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y); |
void screenbuffer_clear(screenbuffer_t *scr); |
void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line); |
void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest); |
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y); |
void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color); |
#endif |
/** @} |
*/ |
/uspace/trunk/console/cons_kernel.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/anim_1.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/anim_2.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/anim_3.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/anim_4.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/Makefile |
---|
0,0 → 1,88 |
# |
# Copyright (C) 2005 Martin Decky |
# 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. |
# |
## Setup toolchain |
# |
LIBC_PREFIX = ../libc |
SOFTINT_PREFIX = ../softint |
include $(LIBC_PREFIX)/Makefile.toolchain |
CFLAGS += -I. -I../kbd/include -I../fb |
LIBS = $(LIBC_PREFIX)/libc.a |
## Sources |
# |
OUTPUT = console |
GENERIC_SOURCES = \ |
console.c \ |
screenbuffer.c \ |
../kbd/generic/key_buffer.c \ |
gcons.c |
IMAGES = helenos.ppm nameic.ppm cons_selected.ppm cons_idle.ppm \ |
cons_has_data.ppm cons_kernel.ppm anim_1.ppm anim_2.ppm anim_3.ppm \ |
anim_4.ppm |
ARCH_SOURCES = |
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) \ |
$(addsuffix .o,$(basename $(IMAGES))) |
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES))) |
.PHONY: all clean depend disasm |
all: $(OUTPUT) disasm |
-include Makefile.depend |
clean: |
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend |
depend: |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(ARCH_OBJECTS) $(GENERIC_OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(GENERIC_OBJECTS) $(ARCH_OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: |
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
%.o: %.s |
$(AS) $(AFLAGS) $< -o $@ |
%.o: %.c |
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@ |
%.o: %.ppm |
$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@ |
/uspace/trunk/console/cons_has_data.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/cons_selected.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/cons_idle.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/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 |