/branches/dd/kernel/generic/src/ipc/sysipc.c |
---|
358,12 → 358,15 |
if (cloned_phone < phone) { |
mutex_lock(&cloned_phone->lock); |
mutex_lock(&phone->lock); |
} else if (cloned_phone > phone) { |
mutex_lock(&phone->lock); |
mutex_lock(&cloned_phone->lock); |
} else { |
mutex_lock(&phone->lock); |
mutex_lock(&cloned_phone->lock); |
} |
if ((cloned_phone->state != IPC_PHONE_CONNECTED) || |
phone->state != IPC_PHONE_CONNECTED) { |
if (cloned_phone != phone) |
mutex_unlock(&cloned_phone->lock); |
mutex_unlock(&phone->lock); |
return EINVAL; |
376,6 → 379,7 |
*/ |
newphid = phone_alloc(phone->callee->task); |
if (newphid < 0) { |
if (cloned_phone != phone) |
mutex_unlock(&cloned_phone->lock); |
mutex_unlock(&phone->lock); |
return ELIMIT; |
382,6 → 386,7 |
} |
ipc_phone_connect(&phone->callee->task->phones[newphid], |
cloned_phone->callee); |
if (cloned_phone != phone) |
mutex_unlock(&cloned_phone->lock); |
mutex_unlock(&phone->lock); |
/* Set the new phone for the callee. */ |
/branches/dd/uspace/lib/libfs/libfs.c |
---|
127,7 → 127,8 |
memset(fn, 0, sizeof(fs_node_t)); |
} |
void libfs_mount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *request) |
void libfs_mount(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid, |
ipc_call_t *request) |
{ |
dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); |
fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request); |
198,7 → 199,8 |
/* |
* Do not release the FS node so that it stays in memory. |
*/ |
ipc_answer_0(rid, rc); |
ipc_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer), |
IPC_GET_ARG3(answer)); |
} |
/** Lookup VFS triplet by name in the file system name space. |
/branches/dd/uspace/lib/libfs/libfs.h |
---|
81,7 → 81,7 |
extern void fs_node_initialize(fs_node_t *); |
extern void libfs_mount(libfs_ops_t *, ipc_callid_t, ipc_call_t *); |
extern void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *); |
extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *); |
#endif |
/branches/dd/uspace/lib/libblock/libblock.c |
---|
68,7 → 68,7 |
typedef struct { |
link_t link; |
int dev_handle; |
dev_handle_t dev_handle; |
int dev_phone; |
void *com_area; |
size_t com_size; |
445,8 → 445,8 |
* @return EOK on success or a negative return code on failure. |
*/ |
int |
block_read(int dev_handle, off_t *bufpos, size_t *buflen, off_t *pos, void *dst, |
size_t size, size_t block_size) |
block_read(dev_handle_t dev_handle, off_t *bufpos, size_t *buflen, off_t *pos, |
void *dst, size_t size, size_t block_size) |
{ |
off_t offset = 0; |
size_t left = size; |
/branches/dd/uspace/lib/libblock/libblock.h |
---|
96,7 → 96,8 |
extern block_t *block_get(dev_handle_t, bn_t, int flags); |
extern void block_put(block_t *); |
extern int block_read(int, off_t *, size_t *, off_t *, void *, size_t, size_t); |
extern int block_read(dev_handle_t, off_t *, size_t *, off_t *, void *, size_t, |
size_t); |
#endif |
/branches/dd/uspace/srv/rd/rd.c |
---|
File deleted |
/branches/dd/uspace/srv/rd/Makefile |
---|
File deleted |
/branches/dd/uspace/srv/console/nameic.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/anim_4.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/anim_3.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/anim_2.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/anim_1.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/helenos.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/cons_selected.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/cons_idle.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/cons_kernel.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/cons_has_data.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/branches/dd/uspace/srv/console/screenbuffer.h |
---|
32,8 → 32,8 |
/** @file |
*/ |
#ifndef __SCREENBUFFER_H__ |
#define __SCREENBUFFER_H__ |
#ifndef SCREENBUFFER_H__ |
#define SCREENBUFFER_H__ |
#include <stdint.h> |
#include <sys/types.h> |
78,19 → 78,32 |
/** Structure for buffering state of one virtual console. |
*/ |
typedef struct { |
keyfield_t *buffer; /**< Screen content - characters and their attributes. Used as a circular 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 */ |
keyfield_t *buffer; /**< Screen content - characters and |
their attributes (used as a circular buffer) */ |
unsigned int size_x; /**< Number of columns */ |
unsigned int size_y; /**< Number of rows */ |
/** Coordinates of last printed character for determining cursor position */ |
unsigned int position_x; |
unsigned int position_y; |
attrs_t attrs; /**< Current attributes. */ |
unsigned int top_line; /**< Points to buffer[][] line that will be printed at screen as the first line */ |
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 |
/** 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) |
{ |
98,21 → 111,28 |
} |
/** Compares two sets of attributes. |
* @param s1 first style |
* @param s2 second style |
* @return nonzero on equality |
* |
* @param s1 First style |
* @param s2 Second style |
* |
* @return Nonzero on equality |
* |
*/ |
static inline int attrs_same(attrs_t a1, attrs_t a2) |
{ |
if (a1.t != a2.t) return 0; |
if (a1.t != a2.t) |
return 0; |
switch (a1.t) { |
case at_style: return a1.a.s.style == a2.a.s.style; |
case at_idx: return a1.a.i.fg_color == a2.a.i.fg_color && |
a1.a.i.bg_color == a2.a.i.bg_color && |
a1.a.i.flags == a2.a.i.flags; |
case at_rgb: return a1.a.r.fg_color == a2.a.r.fg_color && |
a1.a.r.bg_color == a2.a.r.bg_color; |
case at_style: |
return (a1.a.s.style == a2.a.s.style); |
case at_idx: |
return (a1.a.i.fg_color == a2.a.i.fg_color) |
&& (a1.a.i.bg_color == a2.a.i.bg_color) |
&& (a1.a.i.flags == a2.a.i.flags); |
case at_rgb: |
return (a1.a.r.fg_color == a2.a.r.fg_color) |
&& (a1.a.r.bg_color == a2.a.r.bg_color); |
} |
} |
132,7 → 152,5 |
#endif |
/** @} |
*/ |
/branches/dd/uspace/srv/console/console.c |
---|
55,9 → 55,12 |
#include "console.h" |
#include "gcons.h" |
#define NAME "console" |
#define MAX_KEYREQUESTS_BUFFERED 32 |
#define NAME "console" |
/** Size of cwrite_buf. */ |
#define CWRITE_BUF_SIZE 256 |
/** Index of currently used virtual console. |
*/ |
76,40 → 79,36 |
typedef struct { |
keybuffer_t keybuffer; /**< Buffer for incoming keys. */ |
/** Buffer for unsatisfied request for keys. */ |
FIFO_CREATE_STATIC(keyrequests, ipc_callid_t, |
MAX_KEYREQUESTS_BUFFERED); |
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.*/ |
connected to some client. */ |
screenbuffer_t screenbuffer; /**< Screenbuffer for saving screen |
* contents and related settings. */ |
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 virtual console |
* switching */ |
/** Array of data for virtual consoles */ |
static connection_t connections[CONSOLE_COUNT]; |
/** Pointer to memory shared with framebufer used for |
faster virtual console switching */ |
static keyfield_t *interbuffer = NULL; |
/** Information on row-span yet unsent to FB driver. */ |
struct { |
int row; /**< Row where the span lies. */ |
int col; /**< Leftmost column of the span. */ |
int n; /**< Width of the span. */ |
int cnt; /**< Width of the span. */ |
} fb_pending; |
/** Size of cwrite_buf. */ |
#define CWRITE_BUF_SIZE 256 |
/** Buffer for receiving data via the CONSOLE_WRITE call from the client. */ |
static char cwrite_buf[CWRITE_BUF_SIZE]; |
static void fb_putchar(wchar_t c, int row, int col); |
/** Find unused virtual console. |
* |
*/ |
121,6 → 120,7 |
if (!connections[i].used) |
return i; |
} |
return -1; |
} |
185,12 → 185,10 |
case at_style: |
set_style(attrs->a.s.style); |
break; |
case at_idx: |
set_color(attrs->a.i.fg_color, attrs->a.i.bg_color, |
attrs->a.i.flags); |
break; |
case at_rgb: |
set_rgb_color(attrs->a.r.fg_color, attrs->a.r.bg_color); |
break; |
200,8 → 198,8 |
/** Send an area of screenbuffer to the FB driver. */ |
static void fb_update_area(connection_t *conn, int x, int y, int w, int h) |
{ |
int i, j; |
int rc; |
int i; |
int j; |
attrs_t *attrs; |
keyfield_t *field; |
209,46 → 207,25 |
for (j = 0; j < h; j++) { |
for (i = 0; i < w; i++) { |
interbuffer[i + j * w] = |
*get_field_at(&conn->screenbuffer, |
x + i, y + j); |
*get_field_at(&conn->screenbuffer, x + i, y + j); |
} |
} |
rc = async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA, |
async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA, |
x, y, w, h); |
} else { |
rc = ENOTSUP; |
} |
if (rc != 0) { |
/* |
attrs = &conn->screenbuffer.attrs; |
for (j = 0; j < h; j++) { |
for (i = 0; i < w; i++) { |
field = get_field_at(&conn->screenbuffer, |
x + i, y + j); |
if (!attrs_same(*attrs, field->attrs)) |
set_attrs(&field->attrs); |
attrs = &field->attrs; |
fb_putchar(field->character, y + j, x + i); |
} |
}*/ |
} |
} |
/** Flush pending cells to FB. */ |
static void fb_pending_flush(void) |
{ |
screenbuffer_t *scr; |
screenbuffer_t *scr |
= &(connections[active_console].screenbuffer); |
scr = &(connections[active_console].screenbuffer); |
if (fb_pending.n > 0) { |
if (fb_pending.cnt > 0) { |
fb_update_area(&connections[active_console], fb_pending.col, |
fb_pending.row, fb_pending.n, 1); |
fb_pending.n = 0; |
fb_pending.row, fb_pending.cnt, 1); |
fb_pending.cnt = 0; |
} |
} |
256,25 → 233,25 |
* |
* This adds the cell to the pending rowspan if possible. Otherwise |
* the old span is flushed first. |
* |
*/ |
static void cell_mark_changed(int row, int col) |
{ |
if (fb_pending.n != 0) { |
if (row != fb_pending.row || |
col != fb_pending.col + fb_pending.n) { |
if (fb_pending.cnt != 0) { |
if ((row != fb_pending.row) |
|| (col != fb_pending.col + fb_pending.cnt)) { |
fb_pending_flush(); |
} |
} |
if (fb_pending.n == 0) { |
if (fb_pending.cnt == 0) { |
fb_pending.row = row; |
fb_pending.col = col; |
} |
++fb_pending.n; |
fb_pending.cnt++; |
} |
/** Print a character to the active VC with buffering. */ |
static void fb_putchar(wchar_t c, int row, int col) |
{ |
340,7 → 317,9 |
static void change_console(int newcons) |
{ |
connection_t *conn; |
int i, j, rc; |
int i; |
int j; |
int rc; |
keyfield_t *field; |
attrs_t *attrs; |
408,8 → 387,7 |
set_attrs(&field->attrs); |
attrs = &field->attrs; |
if ((field->character == ' ') && |
(attrs_same(field->attrs, |
conn->screenbuffer.attrs))) |
(attrs_same(field->attrs, conn->screenbuffer.attrs))) |
continue; |
fb_putchar(field->character, j, i); |
435,7 → 413,7 |
int newcon; |
/* Ignore parameters, the connection is alread opened */ |
while (1) { |
while (true) { |
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
460,8 → 438,7 |
ev.mods = IPC_GET_ARG3(call); |
ev.c = IPC_GET_ARG4(call); |
/* switch to another virtual console */ |
/* Switch to another virtual console */ |
conn = &connections[active_console]; |
if ((ev.key >= KC_F1) && (ev.key < KC_F1 + |
473,7 → 450,7 |
break; |
} |
/* if client is awaiting key, send it */ |
/* If client is awaiting key, send it */ |
if (conn->keyrequest_counter > 0) { |
conn->keyrequest_counter--; |
ipc_answer_4(fifo_pop(conn->keyrequests), EOK, |
552,7 → 529,7 |
/* Accept the connection */ |
ipc_answer_0(iid, EOK); |
while (1) { |
while (true) { |
async_serialize_end(); |
callid = async_get_call(&call); |
async_serialize_start(); |
748,7 → 725,7 |
ib_size = sizeof(keyfield_t) * fb_info.cols * fb_info.rows; |
interbuffer = as_get_mappable_page(ib_size); |
fb_pending.n = 0; |
fb_pending.cnt = 0; |
if (as_area_create(interbuffer, ib_size, AS_AREA_READ | |
AS_AREA_WRITE | AS_AREA_CACHEABLE) != interbuffer) { |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/gfx/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 |
/branches/dd/uspace/srv/console/console.h |
---|
35,10 → 35,9 |
#ifndef __CONSOLE_H__ |
#define __CONSOLE_H__ |
#define CONSOLE_COUNT 12 |
#define KERNEL_CONSOLE 11 |
#define CONSOLE_COUNT 12 |
#endif |
/** @} |
/branches/dd/uspace/srv/console/screenbuffer.c |
---|
37,34 → 37,40 |
#include <malloc.h> |
#include <unistd.h> |
/** Store one character to screenbuffer. Its position is determined by |
* scr->position_x and scr->position_y. |
/** Store one character to screenbuffer. |
* |
* @param scr screenbuffer |
* @param c stored character |
* 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, wchar_t ch) |
{ |
keyfield_t *field; |
keyfield_t *field = |
get_field_at(scr, scr->position_x, scr->position_y); |
field = get_field_at(scr, scr->position_x, scr->position_y); |
field->character = ch; |
field->attrs = scr->attrs; |
} |
/** 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 |
/** 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) |
{ |
scr->buffer = (keyfield_t *) malloc(sizeof(keyfield_t) * size_x * size_y); |
if (!scr->buffer) { |
if (!scr->buffer) |
return NULL; |
} |
scr->size_x = size_x; |
scr->size_y = size_y; |
78,7 → 84,9 |
} |
/** Clear screenbuffer. |
* @param scr screenbuffer |
* |
* @param scr Screenbuffer |
* |
*/ |
void screenbuffer_clear(screenbuffer_t *scr) |
{ |
95,8 → 103,10 |
} |
/** 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) |
{ |
109,22 → 119,25 |
} |
/** Copy content buffer from screenbuffer to given memory. |
* @param scr source screenbuffer |
* @param dest destination |
* |
* @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++) { |
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) |
{ |
133,9 → 146,11 |
} |
/** Set new style. |
* |
* @param scr |
* @param fg_color |
* @param bg_color |
* |
*/ |
void screenbuffer_set_style(screenbuffer_t *scr, int style) |
{ |
144,9 → 159,11 |
} |
/** Set new color. |
* |
* @param scr |
* @param fg_color |
* @param bg_color |
* |
*/ |
void screenbuffer_set_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color, unsigned int flags) |
{ |
157,9 → 174,11 |
} |
/** Set new RGB color. |
* |
* @param scr |
* @param fg_color |
* @param bg_color |
* |
*/ |
void screenbuffer_set_rgb_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color) |
{ |
168,6 → 187,5 |
scr->attrs.a.r.bg_color = bg_color; |
} |
/** @} |
*/ |
/branches/dd/uspace/srv/console/gcons.c |
---|
166,8 → 166,8 |
if (!use_gcons) |
return; |
if (consnum == active_console || |
console_state[consnum] == CONS_HAS_DATA) |
if ((consnum == active_console) || |
(console_state[consnum] == CONS_HAS_DATA)) |
return; |
console_state[consnum] = CONS_HAS_DATA; |
185,6 → 185,7 |
{ |
if (!use_gcons) |
return; |
if (active_console == consnum) |
console_state[consnum] = CONS_DISCONNECTED_SEL; |
else |
202,6 → 203,7 |
{ |
if (!use_gcons) |
return; |
if (active_console == consnum) |
console_state[consnum] = CONS_SELECTED; |
else |
254,7 → 256,7 |
{ |
int status_start = STATUS_START + (xres - 800) / 2; |
if (y < STATUS_TOP || y >= STATUS_TOP + STATUS_HEIGHT) |
if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT)) |
return -1; |
if (x < status_start) |
285,13 → 287,16 |
} |
return -1; |
} |
if (!state && !btn_pressed) |
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; |
} |
315,27 → 320,32 |
return; |
memcpy(shm, logo, size); |
/* Send area */ |
rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
if (rc) |
goto exit; |
rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
if (rc) |
goto drop; |
/* Draw logo */ |
async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
drop: |
/* Drop area */ |
async_msg_0(fbphone, FB_DROP_SHM); |
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; |
extern char _binary_gfx_helenos_ppm_start[0]; |
extern int _binary_gfx_helenos_ppm_size; |
extern char _binary_gfx_nameic_ppm_start[0]; |
extern int _binary_gfx_nameic_ppm_size; |
/** Redraws console graphics */ |
void gcons_redraw_console(void) |
348,13 → 358,14 |
vp_switch(0); |
set_rgb_color(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); |
draw_pixmap(_binary_gfx_helenos_ppm_start, |
(size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2); |
draw_pixmap(_binary_gfx_nameic_ppm_start, |
(size_t) &_binary_gfx_nameic_ppm_size, 5, 17); |
for (i = 0; i < CONSOLE_COUNT; i++) |
redraw_state(i); |
vp_switch(console_vp); |
} |
377,10 → 388,12 |
return -1; |
memcpy(shm, data, size); |
/* Send area */ |
rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
if (rc) |
goto exit; |
rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
if (rc) |
goto drop; |
389,10 → 402,13 |
rc = async_req_0_0(fbphone, FB_SHM2PIXMAP); |
if (rc < 0) |
goto drop; |
pxid = rc; |
drop: |
/* Drop area */ |
async_msg_0(fbphone, FB_DROP_SHM); |
exit: |
/* Remove area */ |
munmap(shm, size); |
400,38 → 416,35 |
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; |
extern char _binary_gfx_anim_1_ppm_start[0]; |
extern int _binary_gfx_anim_1_ppm_size; |
extern char _binary_gfx_anim_2_ppm_start[0]; |
extern int _binary_gfx_anim_2_ppm_size; |
extern char _binary_gfx_anim_3_ppm_start[0]; |
extern int _binary_gfx_anim_3_ppm_size; |
extern char _binary_gfx_anim_4_ppm_start[0]; |
extern int _binary_gfx_anim_4_ppm_size; |
static void make_anim(void) |
{ |
int an; |
int pm; |
an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); |
int an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); |
if (an < 0) |
return; |
pm = make_pixmap(_binary_anim_1_ppm_start, |
(int) &_binary_anim_1_ppm_size); |
int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, |
(int) &_binary_gfx_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); |
pm = make_pixmap(_binary_gfx_anim_2_ppm_start, |
(int) &_binary_gfx_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); |
pm = make_pixmap(_binary_gfx_anim_3_ppm_start, |
(int) &_binary_gfx_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); |
pm = make_pixmap(_binary_gfx_anim_4_ppm_start, |
(int) &_binary_gfx_anim_4_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
async_msg_1(fbphone, FB_ANIM_START, an); |
439,14 → 452,14 |
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; |
extern char _binary_gfx_cons_selected_ppm_start[0]; |
extern int _binary_gfx_cons_selected_ppm_size; |
extern char _binary_gfx_cons_idle_ppm_start[0]; |
extern int _binary_gfx_cons_idle_ppm_size; |
extern char _binary_gfx_cons_has_data_ppm_start[0]; |
extern int _binary_gfx_cons_has_data_ppm_size; |
extern char _binary_gfx_cons_kernel_ppm_start[0]; |
extern int _binary_gfx_cons_kernel_ppm_size; |
/** Initialize nice graphical console environment */ |
void gcons_init(int phone) |
464,7 → 477,8 |
if ((xres < 800) || (yres < 600)) |
return; |
/* create console viewport */ |
/* Create console viewport */ |
/* Align width & height to character size */ |
console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
ALIGN_DOWN(xres - 2 * CONSOLE_MARGIN, 8), |
486,18 → 500,20 |
/* 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); |
make_pixmap(_binary_gfx_cons_selected_ppm_start, |
(int) &_binary_gfx_cons_selected_ppm_size); |
ic_pixmaps[CONS_IDLE] = |
make_pixmap(_binary_gfx_cons_idle_ppm_start, |
(int) &_binary_gfx_cons_idle_ppm_size); |
ic_pixmaps[CONS_HAS_DATA] = |
make_pixmap(_binary_cons_has_data_ppm_start, |
(int) &_binary_cons_has_data_ppm_size); |
make_pixmap(_binary_gfx_cons_has_data_ppm_start, |
(int) &_binary_gfx_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); |
make_pixmap(_binary_gfx_cons_idle_ppm_start, |
(int) &_binary_gfx_cons_idle_ppm_size); |
ic_pixmaps[CONS_KERNEL] = |
make_pixmap(_binary_gfx_cons_kernel_ppm_start, |
(int) &_binary_gfx_cons_kernel_ppm_size); |
ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
make_anim(); |
/branches/dd/uspace/srv/console/Makefile |
---|
42,6 → 42,7 |
# |
OUTPUT = console |
GENERIC_SOURCES = \ |
console.c \ |
screenbuffer.c \ |
48,17 → 49,22 |
../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 |
IMAGES = \ |
gfx/helenos.ppm \ |
gfx/nameic.ppm \ |
gfx/cons_selected.ppm \ |
gfx/cons_idle.ppm \ |
gfx/cons_has_data.ppm \ |
gfx/cons_kernel.ppm \ |
gfx/anim_1.ppm \ |
gfx/anim_2.ppm \ |
gfx/anim_3.ppm \ |
gfx/anim_4.ppm |
ARCH_SOURCES = |
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) \ |
$(addsuffix .o,$(basename $(IMAGES))) |
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES))) |
OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS) |
OBJECTS := $(GENERIC_OBJECTS) |
.PHONY: all clean depend disasm |
/branches/dd/uspace/srv/bd/rd/Makefile |
---|
0,0 → 1,76 |
# |
# Copyright (c) 2006 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 = ../../../lib/libc |
SOFTINT_PREFIX = ../../../lib/softint |
include $(LIBC_PREFIX)/Makefile.toolchain |
LIBS = $(LIBC_PREFIX)/libc.a |
## Sources |
# |
OUTPUT = rd |
SOURCES = \ |
rd.c |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
.PHONY: all clean depend disasm |
all: $(OUTPUT) $(OUTPUT).disasm |
-include Makefile.depend |
clean: |
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend $(OBJECTS) |
depend: |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
%.o: %.s |
$(AS) $(AFLAGS) $< -o $@ |
%.o: %.c |
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@ |
/branches/dd/uspace/srv/bd/rd/rd.c |
---|
0,0 → 1,239 |
/* |
* Copyright (c) 2007 Michal Konopa |
* Copyright (c) 2007 Martin Jelen |
* Copyright (c) 2007 Peter Majer |
* Copyright (c) 2007 Jakub Jermar |
* 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 rd |
* @{ |
*/ |
/** |
* @file rd.c |
* @brief Initial RAM disk for HelenOS. |
*/ |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
#include <ipc/ns.h> |
#include <sysinfo.h> |
#include <as.h> |
#include <ddi.h> |
#include <align.h> |
#include <bool.h> |
#include <errno.h> |
#include <async.h> |
#include <align.h> |
#include <async.h> |
#include <futex.h> |
#include <stdio.h> |
#include <devmap.h> |
#include <ipc/bd.h> |
#define NAME "rd" |
/** Pointer to the ramdisk's image. */ |
static void *rd_addr; |
/** Size of the ramdisk. */ |
static size_t rd_size; |
/** |
* This futex protects the ramdisk's data. |
* If we were to serve multiple requests (read + write or several writes) |
* concurrently (i.e. from two or more threads), each read and write needs to be |
* protected by this futex. |
*/ |
atomic_t rd_futex = FUTEX_INITIALIZER; |
/** Handle one connection to ramdisk. |
* |
* @param iid Hash of the request that opened the connection. |
* @param icall Call data of the request that opened the connection. |
*/ |
static void rd_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
ipc_callid_t callid; |
ipc_call_t call; |
int retval; |
void *fs_va = NULL; |
off_t offset; |
size_t block_size; |
size_t maxblock_size; |
/* |
* Answer the first IPC_M_CONNECT_ME_TO call. |
*/ |
ipc_answer_0(iid, EOK); |
/* |
* Now we wait for the client to send us its communication as_area. |
*/ |
int flags; |
if (ipc_share_out_receive(&callid, &maxblock_size, &flags)) { |
fs_va = as_get_mappable_page(maxblock_size); |
if (fs_va) { |
(void) ipc_share_out_finalize(callid, fs_va); |
} else { |
ipc_answer_0(callid, EHANGUP); |
return; |
} |
} else { |
/* |
* The client doesn't speak the same protocol. |
* At this point we can't handle protocol variations. |
* Close the connection. |
*/ |
ipc_answer_0(callid, EHANGUP); |
return; |
} |
while (true) { |
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
/* |
* The other side has hung up. |
* Answer the message and exit the fibril. |
*/ |
ipc_answer_0(callid, EOK); |
return; |
case BD_READ_BLOCK: |
offset = IPC_GET_ARG1(call); |
block_size = IPC_GET_ARG2(call); |
if (block_size > maxblock_size) { |
/* |
* Maximum block size exceeded. |
*/ |
retval = ELIMIT; |
break; |
} |
if (offset * block_size > rd_size - block_size) { |
/* |
* Reading past the end of the device. |
*/ |
retval = ELIMIT; |
break; |
} |
futex_down(&rd_futex); |
memcpy(fs_va, rd_addr + offset * block_size, block_size); |
futex_up(&rd_futex); |
retval = EOK; |
break; |
case BD_WRITE_BLOCK: |
offset = IPC_GET_ARG1(call); |
block_size = IPC_GET_ARG2(call); |
if (block_size > maxblock_size) { |
/* |
* Maximum block size exceeded. |
*/ |
retval = ELIMIT; |
break; |
} |
if (offset * block_size > rd_size - block_size) { |
/* |
* Writing past the end of the device. |
*/ |
retval = ELIMIT; |
break; |
} |
futex_up(&rd_futex); |
memcpy(rd_addr + offset * block_size, fs_va, block_size); |
futex_down(&rd_futex); |
retval = EOK; |
break; |
default: |
/* |
* The client doesn't speak the same protocol. |
* Instead of closing the connection, we just ignore |
* the call. This can be useful if the client uses a |
* newer version of the protocol. |
*/ |
retval = EINVAL; |
break; |
} |
ipc_answer_0(callid, retval); |
} |
} |
/** Prepare the ramdisk image for operation. */ |
static bool rd_init(void) |
{ |
rd_size = sysinfo_value("rd.size"); |
void *rd_ph_addr = (void *) sysinfo_value("rd.address.physical"); |
if (rd_size == 0) { |
printf(NAME ": No RAM disk found\n"); |
return false; |
} |
rd_addr = as_get_mappable_page(rd_size); |
int flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE; |
int retval = physmem_map(rd_ph_addr, rd_addr, |
ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags); |
if (retval < 0) { |
printf(NAME ": Error mapping RAM disk\n"); |
return false; |
} |
printf(NAME ": Found RAM disk at %p, %d bytes\n", rd_ph_addr, rd_size); |
int rc = devmap_driver_register(NAME, rd_connection); |
if (rc < 0) { |
printf(NAME ": Unable to register driver (%d)\n", rc); |
return false; |
} |
dev_handle_t dev_handle; |
if (devmap_device_register("initrd", &dev_handle) != EOK) { |
devmap_hangup_phone(DEVMAP_DRIVER); |
printf(NAME ": Unable to register device\n"); |
return false; |
} |
return true; |
} |
int main(int argc, char **argv) |
{ |
printf(NAME ": HelenOS RAM disk server\n"); |
if (!rd_init()) |
return -1; |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
/* Never reached */ |
return 0; |
} |
/** |
* @} |
*/ |
/branches/dd/uspace/srv/bd/gxe_bd/gxe_bd.c |
---|
84,7 → 84,9 |
uint8_t buffer[512]; |
} gxe_buf_t; |
static size_t maxblock_size = 512; |
static const size_t block_size = 512; |
static size_t comm_size; |
static uintptr_t dev_physical = 0x13000000; |
static gxe_bd_t *dev; |
static gxe_buf_t *devbuf; |
95,9 → 97,9 |
static int gxe_bd_init(void); |
static void gxe_bd_connection(ipc_callid_t iid, ipc_call_t *icall); |
static int gxe_bd_read_block(uint64_t offset, size_t block_size, void *buf); |
static int gxe_bd_write_block(uint64_t offset, size_t block_size, |
const void *buf); |
static int gx_bd_rdwr(ipcarg_t method, off_t offset, off_t size, void *buf); |
static int gxe_bd_read_block(uint64_t offset, size_t size, void *buf); |
static int gxe_bd_write_block(uint64_t offset, size_t size, const void *buf); |
int main(int argc, char **argv) |
{ |
156,21 → 158,21 |
void *fs_va = NULL; |
ipc_callid_t callid; |
ipc_call_t call; |
ipcarg_t method; |
int flags; |
int retval; |
off_t offset; |
size_t block_size; |
off_t idx; |
off_t size; |
/* Answer the IPC_M_CONNECT_ME_TO call. */ |
ipc_answer_0(iid, EOK); |
if (!ipc_share_out_receive(&callid, &maxblock_size, &flags)) { |
if (!ipc_share_out_receive(&callid, &comm_size, &flags)) { |
ipc_answer_0(callid, EHANGUP); |
return; |
} |
maxblock_size = 512; |
fs_va = as_get_mappable_page(maxblock_size); |
fs_va = as_get_mappable_page(comm_size); |
if (fs_va == NULL) { |
ipc_answer_0(callid, EHANGUP); |
return; |
180,21 → 182,22 |
while (1) { |
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
method = IPC_GET_METHOD(call); |
switch (method) { |
case IPC_M_PHONE_HUNGUP: |
/* The other side has hung up. */ |
ipc_answer_0(callid, EOK); |
return; |
case BD_READ_BLOCK: |
offset = IPC_GET_ARG1(call); |
block_size = IPC_GET_ARG2(call); |
retval = gxe_bd_read_block(offset, block_size, fs_va); |
break; |
case BD_WRITE_BLOCK: |
offset = IPC_GET_ARG1(call); |
block_size = IPC_GET_ARG2(call); |
retval = gxe_bd_write_block(offset, block_size, fs_va); |
idx = IPC_GET_ARG1(call); |
size = IPC_GET_ARG2(call); |
if (size > comm_size) { |
retval = EINVAL; |
break; |
} |
retval = gx_bd_rdwr(method, idx * size, size, fs_va); |
break; |
default: |
retval = EINVAL; |
break; |
203,18 → 206,40 |
} |
} |
static int gxe_bd_read_block(uint64_t offset, size_t block_size, void *buf) |
static int gx_bd_rdwr(ipcarg_t method, off_t offset, off_t size, void *buf) |
{ |
int rc; |
size_t now; |
while (size > 0) { |
now = size < block_size ? size : block_size; |
if (method == BD_READ_BLOCK) |
rc = gxe_bd_read_block(offset, now, buf); |
else |
rc = gxe_bd_write_block(offset, now, buf); |
if (rc != EOK) |
return rc; |
buf += block_size; |
offset += block_size; |
if (size > block_size) |
size -= block_size; |
else |
size = 0; |
} |
return EOK; |
} |
static int gxe_bd_read_block(uint64_t offset, size_t size, void *buf) |
{ |
uint32_t status; |
size_t i; |
uint32_t w; |
if (block_size != maxblock_size) { |
printf("Failed: bs = %d, mbs = %d\n", block_size, |
maxblock_size); |
return EINVAL; |
} |
futex_down(&dev_futex); |
pio_write_32(&dev->offset_lo, (uint32_t) offset); |
pio_write_32(&dev->offset_hi, offset >> 32); |
226,7 → 251,7 |
return EIO; |
} |
for (i = 0; i < maxblock_size; i++) { |
for (i = 0; i < size; i++) { |
((uint8_t *) buf)[i] = w = |
pio_read_8(&devbuf->buffer[i]); |
} |
235,20 → 260,13 |
return EOK; |
} |
static int gxe_bd_write_block(uint64_t offset, size_t block_size, |
const void *buf) |
static int gxe_bd_write_block(uint64_t offset, size_t size, const void *buf) |
{ |
uint32_t status; |
size_t i; |
uint32_t w; |
if (block_size != maxblock_size) { |
printf("Failed: bs = %d, mbs = %d\n", block_size, |
maxblock_size); |
return EINVAL; |
} |
for (i = 0; i < maxblock_size; i++) { |
for (i = 0; i < size; i++) { |
pio_write_8(&devbuf->buffer[i], ((const uint8_t *) buf)[i]); |
} |
/branches/dd/uspace/srv/fs/tmpfs/tmpfs_dump.c |
---|
54,8 → 54,8 |
} __attribute__((packed)); |
static bool |
tmpfs_restore_recursion(int dev, off_t *bufpos, size_t *buflen, off_t *pos, |
fs_node_t *pfn) |
tmpfs_restore_recursion(dev_handle_t dev, off_t *bufpos, size_t *buflen, |
off_t *pos, fs_node_t *pfn) |
{ |
struct rdentry entry; |
libfs_ops_t *ops = &tmpfs_libfs_ops; |
/branches/dd/uspace/srv/fs/tmpfs/tmpfs_ops.c |
---|
409,12 → 409,7 |
void tmpfs_mount(ipc_callid_t rid, ipc_call_t *request) |
{ |
dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); |
fs_index_t mp_index = (fs_index_t) IPC_GET_ARG2(*request); |
fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request); |
dev_handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request); |
ipc_answer_0(rid, ENOTSUP); |
libfs_mount(&tmpfs_libfs_ops, tmpfs_reg.fs_handle, rid, request); |
} |
void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request) |
/branches/dd/uspace/srv/fs/fat/fat_ops.c |
---|
888,7 → 888,7 |
void fat_mount(ipc_callid_t rid, ipc_call_t *request) |
{ |
libfs_mount(&fat_libfs_ops, rid, request); |
libfs_mount(&fat_libfs_ops, fat_reg.fs_handle, rid, request); |
} |
void fat_lookup(ipc_callid_t rid, ipc_call_t *request) |
/branches/dd/uspace/srv/vfs/vfs_ops.c |
---|
74,7 → 74,6 |
*/ |
RWLOCK_INITIALIZE(namespace_rwlock); |
futex_t rootfs_futex = FUTEX_INITIALIZER; |
vfs_pair_t rootfs = { |
.fs_handle = 0, |
.dev_handle = 0 |
95,17 → 94,14 |
aid_t msg; |
ipc_call_t answer; |
/* Resolve the path to the mountpoint. */ |
futex_down(&rootfs_futex); |
rwlock_write_lock(&namespace_rwlock); |
if (rootfs.fs_handle) { |
/* We already have the root FS. */ |
rwlock_write_lock(&namespace_rwlock); |
if (str_cmp(mp, "/") == 0) { |
/* Trying to mount root FS over root FS */ |
ipc_answer_0(rid, EBUSY); |
rwlock_write_unlock(&namespace_rwlock); |
futex_up(&rootfs_futex); |
ipc_answer_0(rid, EBUSY); |
return; |
} |
112,17 → 108,15 |
rc = vfs_lookup_internal(mp, L_DIRECTORY, &mp_res, NULL); |
if (rc != EOK) { |
/* The lookup failed for some reason. */ |
ipc_answer_0(rid, rc); |
rwlock_write_unlock(&namespace_rwlock); |
futex_up(&rootfs_futex); |
ipc_answer_0(rid, rc); |
return; |
} |
mp_node = vfs_node_get(&mp_res); |
if (!mp_node) { |
ipc_answer_0(rid, ENOMEM); |
rwlock_write_unlock(&namespace_rwlock); |
futex_up(&rootfs_futex); |
ipc_answer_0(rid, ENOMEM); |
return; |
} |
131,7 → 125,6 |
* It will be dropped upon the corresponding VFS_UNMOUNT. |
* This prevents the mount point from being deleted. |
*/ |
rwlock_write_unlock(&namespace_rwlock); |
} else { |
/* We still don't have the root file system mounted. */ |
if (str_cmp(mp, "/") == 0) { |
150,8 → 143,8 |
if (rc != EOK) { |
async_wait_for(msg, NULL); |
vfs_release_phone(phone); |
futex_up(&rootfs_futex); |
ipc_answer_0(rid, rc); |
rwlock_write_unlock(&namespace_rwlock); |
return; |
} |
async_wait_for(msg, &rc); |
158,8 → 151,8 |
vfs_release_phone(phone); |
if (rc != EOK) { |
futex_up(&rootfs_futex); |
ipc_answer_0(rid, rc); |
rwlock_write_unlock(&namespace_rwlock); |
return; |
} |
176,7 → 169,6 |
rootfs.fs_handle = fs_handle; |
rootfs.dev_handle = dev_handle; |
futex_up(&rootfs_futex); |
/* Add reference to the mounted root. */ |
mr_node = vfs_node_get(&mr_res); |
183,6 → 175,7 |
assert(mr_node); |
ipc_answer_0(rid, rc); |
rwlock_write_unlock(&namespace_rwlock); |
return; |
} else { |
/* |
189,12 → 182,11 |
* We can't resolve this without the root filesystem |
* being mounted first. |
*/ |
futex_up(&rootfs_futex); |
ipc_answer_0(rid, ENOENT); |
rwlock_write_unlock(&namespace_rwlock); |
return; |
} |
} |
futex_up(&rootfs_futex); |
/* |
* At this point, we have all necessary pieces: file system and device |
221,6 → 213,7 |
if (mp_node) |
vfs_node_put(mp_node); |
ipc_answer_0(rid, rc); |
rwlock_write_unlock(&namespace_rwlock); |
return; |
} |
233,17 → 226,13 |
if (mp_node) |
vfs_node_put(mp_node); |
ipc_answer_0(rid, rc); |
rwlock_write_unlock(&namespace_rwlock); |
return; |
} |
async_wait_for(msg, &rc); |
vfs_release_phone(phone); |
if (rc != EOK) { |
/* Mount failed, drop reference to mp_node. */ |
if (mp_node) |
vfs_node_put(mp_node); |
} |
if (rc == EOK) { |
rindex = (fs_index_t) IPC_GET_ARG1(answer); |
rsize = (size_t) IPC_GET_ARG2(answer); |
rlnkcnt = (unsigned) IPC_GET_ARG3(answer); |
258,12 → 247,18 |
/* Add reference to the mounted root. */ |
mr_node = vfs_node_get(&mr_res); |
assert(mr_node); |
} else { |
/* Mount failed, drop reference to mp_node. */ |
if (mp_node) |
vfs_node_put(mp_node); |
} |
ipc_answer_0(rid, rc); |
rwlock_write_unlock(&namespace_rwlock); |
} |
/** Process pending mount requests */ |
void vfs_process_pending_mount() |
void vfs_process_pending_mount(void) |
{ |
link_t *cur; |
1030,7 → 1025,7 |
free(new); |
return; |
} |
char *lastsl = str_rchr(parentc + 1, L'/'); |
char *lastsl = str_rchr(parentc + 1, '/'); |
if (lastsl) |
*lastsl = '\0'; |
else |
/branches/dd/uspace/srv/vfs/vfs_file.c |
---|
78,19 → 78,23 |
*/ |
int vfs_fd_alloc(void) |
{ |
int i; |
if (!vfs_files_init()) |
return ENOMEM; |
unsigned int i; |
for (i = 0; i < MAX_OPEN_FILES; i++) { |
if (!files[i]) { |
files[i] = (vfs_file_t *) malloc(sizeof(vfs_file_t)); |
if (!files[i]) |
return ENOMEM; |
memset(files[i], 0, sizeof(vfs_file_t)); |
futex_initialize(&files[i]->lock, 1); |
vfs_file_addref(files[i]); |
return i; |
return (int) i; |
} |
} |
return EMFILE; |
} |
103,10 → 107,15 |
*/ |
int vfs_fd_free(int fd) |
{ |
if (!vfs_files_init()) |
return ENOMEM; |
if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (files[fd] == NULL)) |
return EBADF; |
vfs_file_delref(files[fd]); |
files[fd] = NULL; |
return EOK; |
} |
150,8 → 159,12 |
*/ |
vfs_file_t *vfs_file_get(int fd) |
{ |
if (!vfs_files_init()) |
return NULL; |
if ((fd >= 0) && (fd < MAX_OPEN_FILES)) |
return files[fd]; |
return NULL; |
} |
/branches/dd/uspace/Makefile |
---|
38,12 → 38,12 |
lib/softint \ |
lib/softfloat \ |
srv/bd/gxe_bd \ |
srv/bd/rd \ |
srv/ns \ |
srv/loader \ |
srv/fb \ |
srv/kbd \ |
srv/console \ |
srv/rd \ |
srv/fs/fat \ |
srv/fs/tmpfs \ |
srv/fs/devfs \ |
/branches/dd/HelenOS.config |
---|
282,7 → 282,7 |
## Kernel features options |
% Support for SMP |
! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ia64|(PLATFORM=mips32&MACHINE=msim)] CONFIG_SMP (y/n) |
! [(PLATFORM=ia32&PROCESSOR!=athlon_xp)|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ia64|(PLATFORM=mips32&MACHINE=msim)] CONFIG_SMP (y/n) |
% Debug build |
! CONFIG_DEBUG (y/n) |
/branches/dd/boot/arch/sparc64/loader/Makefile |
---|
80,7 → 80,7 |
$(USPACEDIR)/app/init/init \ |
$(USPACEDIR)/srv/loader/loader \ |
$(USPACEDIR)/srv/devmap/devmap \ |
$(USPACEDIR)/srv/rd/rd \ |
$(USPACEDIR)/srv/bd/rd/rd \ |
$(USPACEDIR)/srv/vfs/vfs |
ifeq ($(RDFMT),tmpfs) |
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs |
/branches/dd/boot/arch/ia64/loader/Makefile |
---|
87,7 → 87,7 |
$(USPACEDIR)/srv/loader/loader \ |
$(USPACEDIR)/app/init/init \ |
$(USPACEDIR)/srv/devmap/devmap \ |
$(USPACEDIR)/srv/rd/rd \ |
$(USPACEDIR)/srv/bd/rd/rd \ |
$(USPACEDIR)/srv/vfs/vfs |
ifeq ($(RDFMT),tmpfs) |
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs |
/branches/dd/boot/arch/arm32/loader/main.c |
---|
87,20 → 87,13 |
printf(" kernel entry point at %L\n", KERNEL_VIRTUAL_ADDRESS); |
printf(" %L: boot info structure\n", &bootinfo); |
unsigned int top = 0; |
bootinfo.cnt = 0; |
unsigned int i, j; |
for (i = 0; i < COMPONENTS; i++) { |
printf(" %L: %s image (size %d bytes)\n", |
components[i].start, components[i].name, components[i].size); |
} |
printf("\nCopying components\n"); |
unsigned int top = 0; |
bootinfo.cnt = 0; |
for (i = 0; i < COMPONENTS; i++) { |
printf(" %s...", components[i].name); |
top = ALIGN_UP(top, KERNEL_PAGE_SIZE); |
memcpy(((void *) KERNEL_VIRTUAL_ADDRESS) + top, components[i].start, components[i].size); |
if (i > 0) { |
bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top; |
bootinfo.tasks[bootinfo.cnt].size = components[i].size; |
109,9 → 102,23 |
bootinfo.cnt++; |
} |
top += components[i].size; |
} |
j = bootinfo.cnt - 1; |
printf("\nCopying components\n"); |
for (i = COMPONENTS - 1; i > 0; i--, j--) { |
printf(" %s...", components[i].name); |
memcpy((void *)bootinfo.tasks[j].addr, components[i].start, |
components[i].size); |
printf("done.\n"); |
} |
printf("\nCopying kernel..."); |
memcpy((void *)KERNEL_VIRTUAL_ADDRESS, components[0].start, |
components[0].size); |
printf("done.\n"); |
printf("\nBooting the kernel...\n"); |
jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo); |
} |
/branches/dd/boot/arch/arm32/loader/Makefile |
---|
76,7 → 76,7 |
$(USPACEDIR)/srv/loader/loader \ |
$(USPACEDIR)/app/init/init \ |
$(USPACEDIR)/srv/devmap/devmap \ |
$(USPACEDIR)/srv/rd/rd \ |
$(USPACEDIR)/srv/bd/rd/rd \ |
$(USPACEDIR)/srv/vfs/vfs |
ifeq ($(RDFMT),tmpfs) |
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs |
/branches/dd/boot/arch/ppc32/loader/Makefile |
---|
75,7 → 75,7 |
$(USPACEDIR)/srv/loader/loader \ |
$(USPACEDIR)/app/init/init \ |
$(USPACEDIR)/srv/devmap/devmap \ |
$(USPACEDIR)/srv/rd/rd \ |
$(USPACEDIR)/srv/bd/rd/rd \ |
$(USPACEDIR)/srv/vfs/vfs |
ifeq ($(RDFMT),tmpfs) |
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs |
/branches/dd/boot/arch/amd64/Makefile.inc |
---|
33,7 → 33,7 |
$(USPACEDIR)/srv/loader/loader \ |
$(USPACEDIR)/app/init/init \ |
$(USPACEDIR)/srv/devmap/devmap \ |
$(USPACEDIR)/srv/rd/rd \ |
$(USPACEDIR)/srv/bd/rd/rd \ |
$(USPACEDIR)/srv/vfs/vfs |
ifeq ($(RDFMT),tmpfs) |
INIT_TASKS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs |
/branches/dd/boot/arch/mips32/loader/Makefile |
---|
88,7 → 88,7 |
$(USPACEDIR)/srv/loader/loader \ |
$(USPACEDIR)/app/init/init \ |
$(USPACEDIR)/srv/devmap/devmap \ |
$(USPACEDIR)/srv/rd/rd \ |
$(USPACEDIR)/srv/bd/rd/rd \ |
$(USPACEDIR)/srv/vfs/vfs |
ifeq ($(RDFMT),tmpfs) |
COMPONENTS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs |
/branches/dd/boot/arch/ia32/Makefile.inc |
---|
33,7 → 33,7 |
$(USPACEDIR)/srv/loader/loader \ |
$(USPACEDIR)/app/init/init \ |
$(USPACEDIR)/srv/devmap/devmap \ |
$(USPACEDIR)/srv/rd/rd \ |
$(USPACEDIR)/srv/bd/rd/rd \ |
$(USPACEDIR)/srv/vfs/vfs |
ifeq ($(RDFMT),tmpfs) |
INIT_TASKS += $(USPACEDIR)/srv/fs/tmpfs/tmpfs |