/branches/dd/uspace/srv/bd/gxe_bd/gxe_bd.c |
---|
File deleted |
/branches/dd/uspace/srv/bd/gxe_bd/Makefile |
---|
File deleted |
/branches/dd/uspace/srv/fhc/Makefile |
---|
64,7 → 64,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/kbd/include/kbd.h |
---|
38,7 → 38,6 |
#define KBD_KBD_H_ |
#include <key_buffer.h> |
#include <ipc/ipc.h> |
#define KBD_EVENT 1024 |
#define KBD_MS_LEFT 1025 |
46,11 → 45,6 |
#define KBD_MS_MIDDLE 1027 |
#define KBD_MS_MOVE 1028 |
typedef enum { |
KBD_YIELD = IPC_FIRST_USER_METHOD, |
KBD_RECLAIM |
} kbd_request_t; |
extern int cir_service; |
extern int cir_phone; |
/branches/dd/uspace/srv/kbd/include/kbd_port.h |
---|
38,8 → 38,6 |
#define KBD_PORT_H_ |
extern int kbd_port_init(void); |
extern void kbd_port_yield(void); |
extern void kbd_port_reclaim(void); |
#endif |
/branches/dd/uspace/srv/kbd/port/gxemul.c |
---|
69,14 → 69,6 |
return 0; |
} |
void kbd_port_yield(void) |
{ |
} |
void kbd_port_reclaim(void) |
{ |
} |
/** Process data sent when a key is pressed. |
* |
* @param keybuffer Buffer of pressed keys. |
/branches/dd/uspace/srv/kbd/port/ns16550.c |
---|
106,14 → 106,6 |
return pio_enable((void *) ns16550_physical, 8, &vaddr); |
} |
void ns16550_port_yield(void) |
{ |
} |
void ns16550_port_reclaim(void) |
{ |
} |
static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call) |
{ |
int scan_code = IPC_GET_ARG2(*call); |
/branches/dd/uspace/srv/kbd/port/msim.c |
---|
69,17 → 69,22 |
return 0; |
} |
void kbd_port_yield(void) |
static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call) |
{ |
} |
int scan_code = IPC_GET_ARG2(*call); |
// static int esc_count=0; |
void kbd_port_reclaim(void) |
{ |
} |
// if (scan_code == 0x1b) { |
// esc_count++; |
// if (esc_count == 3) |
// __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE); |
// } else { |
// esc_count=0; |
// } |
static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call) |
{ |
int scan_code = IPC_GET_ARG2(*call); |
// if (fb_fb) |
// return kbd_arch_process_fb(keybuffer, scan_code); |
kbd_push_scancode(scan_code); |
} |
/branches/dd/uspace/srv/kbd/port/sun.c |
---|
39,6 → 39,13 |
#include <sun.h> |
#include <sysinfo.h> |
typedef enum { |
KBD_UNKNOWN, |
KBD_Z8530, |
KBD_NS16550, |
KBD_SGCN |
} kbd_type_t; |
/** Sun keyboard virtual port driver. |
* |
* This is a virtual port driver which can use |
49,26 → 56,13 |
*/ |
int kbd_port_init(void) |
{ |
if (sysinfo_value("kbd.type.z8530")) { |
if (z8530_port_init() == 0) |
return 0; |
} |
if (sysinfo_value("kbd.type") == KBD_Z8530) |
return z8530_port_init(); |
else if (sysinfo_value("kbd.type") == KBD_NS16550) |
return ns16550_port_init(); |
if (sysinfo_value("kbd.type.ns16550")) { |
if (ns16550_port_init() == 0) |
return 0; |
} |
return -1; |
} |
void kbd_port_yield(void) |
{ |
} |
void kbd_port_reclaim(void) |
{ |
} |
/** @} |
*/ |
/branches/dd/uspace/srv/kbd/port/i8042.c |
---|
151,14 → 151,6 |
return 0; |
} |
void kbd_port_yield(void) |
{ |
} |
void kbd_port_reclaim(void) |
{ |
} |
static void i8042_irq_handler(ipc_callid_t iid, ipc_call_t *call) |
{ |
int status = IPC_GET_ARG1(*call); |
/branches/dd/uspace/srv/kbd/port/ski.c |
---|
42,7 → 42,6 |
#include <kbd_port.h> |
#include <sys/types.h> |
#include <thread.h> |
#include <bool.h> |
#define SKI_GETCHAR 21 |
51,8 → 50,6 |
static void *ski_thread_impl(void *arg); |
static int32_t ski_getchar(void); |
static volatile bool polling_disabled = false; |
/** Initialize Ski port driver. */ |
int kbd_port_init(void) |
{ |
67,16 → 64,6 |
return 0; |
} |
void kbd_port_yield(void) |
{ |
polling_disabled = true; |
} |
void kbd_port_reclaim(void) |
{ |
polling_disabled = false; |
} |
/** Thread to poll Ski for keypresses. */ |
static void *ski_thread_impl(void *arg) |
{ |
84,7 → 71,7 |
(void) arg; |
while (1) { |
while (polling_disabled == false) { |
while (1) { |
c = ski_getchar(); |
if (c == 0) |
break; |
/branches/dd/uspace/srv/kbd/port/z8530.c |
---|
95,14 → 95,6 |
return 0; |
} |
void z8530_port_yield(void) |
{ |
} |
void z8530_port_reclaim(void) |
{ |
} |
static void z8530_irq_handler(ipc_callid_t iid, ipc_call_t *call) |
{ |
int scan_code = IPC_GET_ARG2(*call); |
/branches/dd/uspace/srv/kbd/port/sgcn.c |
---|
42,7 → 42,6 |
#include <sysinfo.h> |
#include <stdio.h> |
#include <thread.h> |
#include <bool.h> |
#define POLL_INTERVAL 10000 |
93,7 → 92,6 |
/* polling thread */ |
static void *sgcn_thread_impl(void *arg); |
static volatile bool polling_disabled = false; |
/** |
* Initializes the SGCN driver. |
122,16 → 120,6 |
return 0; |
} |
void kbd_port_yield(void) |
{ |
polling_disabled = true; |
} |
void kbd_port_reclaim(void) |
{ |
polling_disabled = false; |
} |
/** |
* Handler of the "key pressed" event. Reads codes of all the pressed keys from |
* the buffer. |
166,11 → 154,11 |
(void) arg; |
while (1) { |
if (polling_disabled == false) |
sgcn_key_pressed(); |
sgcn_key_pressed(); |
usleep(POLL_INTERVAL); |
} |
} |
/** @} |
*/ |
/branches/dd/uspace/srv/kbd/port/dummy.c |
---|
42,13 → 42,5 |
return 0; |
} |
void kbd_port_yield(void) |
{ |
} |
void kbd_port_reclaim(void) |
{ |
} |
/** @} |
*/ |
/branches/dd/uspace/srv/kbd/generic/kbd.c |
---|
193,14 → 193,6 |
phone2cons = IPC_GET_ARG5(call); |
retval = 0; |
break; |
case KBD_YIELD: |
kbd_port_yield(); |
retval = 0; |
break; |
case KBD_RECLAIM: |
kbd_port_reclaim(); |
retval = 0; |
break; |
default: |
retval = EINVAL; |
} |
/branches/dd/uspace/srv/kbd/Makefile |
---|
112,15 → 112,8 |
ifeq ($(MACHINE), bgxemul) |
GENARCH_SOURCES += \ |
port/gxemul.c |
ifeq ($(CONFIG_FB), y) |
GENARCH_SOURCES += \ |
ctl/gxe_fb.c |
else |
GENARCH_SOURCES += \ |
ctl/stty.c |
endif |
port/gxemul.c \ |
ctl/stty.c |
endif |
ifeq ($(UARCH), ppc32) |
167,7 → 160,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/kbd/layout/cz.c |
---|
54,6 → 54,19 |
}; |
static wchar_t map_lcase[] = { |
[KC_2] = L'ě', |
[KC_3] = L'š', |
[KC_4] = L'č', |
[KC_5] = L'ř', |
[KC_6] = L'ž', |
[KC_7] = L'ý', |
[KC_8] = L'á', |
[KC_9] = L'í', |
[KC_0] = L'é', |
[KC_LBRACKET] = L'ú', |
[KC_SEMICOLON] = L'ů', |
[KC_Q] = 'q', |
[KC_W] = 'w', |
[KC_E] = 'e', |
85,6 → 98,19 |
}; |
static wchar_t map_ucase[] = { |
[KC_2] = L'Ě', |
[KC_3] = L'Š', |
[KC_4] = L'Č', |
[KC_5] = L'Ř', |
[KC_6] = L'Ž', |
[KC_7] = L'Ý', |
[KC_8] = L'Á', |
[KC_9] = L'Í', |
[KC_0] = L'É', |
[KC_LBRACKET] = L'Ú', |
[KC_SEMICOLON] = L'Ů', |
[KC_Q] = 'Q', |
[KC_W] = 'W', |
[KC_E] = 'E', |
157,36 → 183,6 |
[KC_SLASH] = '_', |
}; |
static wchar_t map_ns_nocaps[] = { |
[KC_2] = L'ě', |
[KC_3] = L'š', |
[KC_4] = L'č', |
[KC_5] = L'ř', |
[KC_6] = L'ž', |
[KC_7] = L'ý', |
[KC_8] = L'á', |
[KC_9] = L'í', |
[KC_0] = L'é', |
[KC_LBRACKET] = L'ú', |
[KC_SEMICOLON] = L'ů' |
}; |
static wchar_t map_ns_caps[] = { |
[KC_2] = L'Ě', |
[KC_3] = L'Š', |
[KC_4] = L'Č', |
[KC_5] = L'Ř', |
[KC_6] = L'Ž', |
[KC_7] = L'Ý', |
[KC_8] = L'Á', |
[KC_9] = L'Í', |
[KC_0] = L'É', |
[KC_LBRACKET] = L'Ú', |
[KC_SEMICOLON] = L'Ů' |
}; |
static wchar_t map_neutral[] = { |
[KC_BACKSPACE] = '\b', |
[KC_TAB] = '\t', |
329,16 → 325,6 |
if (c != 0) |
return c; |
if ((ev->mods & KM_SHIFT) == 0) { |
if ((ev->mods & KM_CAPS_LOCK) != 0) |
c = translate(ev->key, map_ns_caps, sizeof(map_ns_caps) / sizeof(wchar_t)); |
else |
c = translate(ev->key, map_ns_nocaps, sizeof(map_ns_nocaps) / sizeof(wchar_t)); |
if (c != 0) |
return c; |
} |
if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) |
c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(wchar_t)); |
else |
/branches/dd/uspace/srv/ns/Makefile |
---|
63,7 → 63,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/console/console.c |
---|
64,9 → 64,6 |
int active_console = 0; |
int prev_console = 0; |
/** Phone to the keyboard driver. */ |
static int kbd_phone; |
/** Information about framebuffer */ |
struct { |
int phone; /**< Framebuffer phone */ |
144,26 → 141,6 |
async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col); |
} |
static void screen_yield(void) |
{ |
ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_YIELD); |
} |
static void screen_reclaim(void) |
{ |
ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_RECLAIM); |
} |
static void kbd_yield(void) |
{ |
ipc_call_sync_0_0(kbd_phone, KBD_YIELD); |
} |
static void kbd_reclaim(void) |
{ |
ipc_call_sync_0_0(kbd_phone, KBD_RECLAIM); |
} |
static void set_style(int style) |
{ |
async_msg_1(fb_info.phone, FB_SET_STYLE, style); |
353,10 → 330,7 |
async_serialize_start(); |
curs_hide_sync(); |
gcons_in_kernel(); |
screen_yield(); |
kbd_yield(); |
async_serialize_end(); |
if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) { |
prev_console = active_console; |
368,11 → 342,8 |
if (newcons != KERNEL_CONSOLE) { |
async_serialize_start(); |
if (active_console == KERNEL_CONSOLE) { |
screen_reclaim(); |
kbd_reclaim(); |
if (active_console == KERNEL_CONSOLE) |
gcons_redraw_console(); |
} |
active_console = newcons; |
gcons_change_console(newcons); |
503,7 → 474,6 |
if (!ipc_data_write_receive(&callid, &size)) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
} |
if (size > CWRITE_BUF_SIZE) |
511,8 → 481,6 |
(void) ipc_data_write_finalize(callid, cwrite_buf, size); |
async_serialize_start(); |
off = 0; |
while (off < size) { |
ch = str_decode(cwrite_buf, &off, size); |
519,8 → 487,6 |
write_char(consnum, ch); |
} |
async_serialize_end(); |
gcons_notify_char(consnum); |
ipc_answer_1(rid, EOK, size); |
} |
546,8 → 512,6 |
gcons_notify_connect(consnum); |
conn->client_phone = IPC_GET_ARG5(*icall); |
screenbuffer_clear(&conn->screenbuffer); |
if (consnum == active_console) |
clrscr(); |
/* Accept the connection */ |
ipc_answer_0(iid, EOK); |
580,9 → 544,7 |
gcons_notify_char(consnum); |
break; |
case CONSOLE_WRITE: |
async_serialize_end(); |
cons_write(consnum, callid, &call); |
async_serialize_start(); |
continue; |
case CONSOLE_CLEAR: |
/* Send message to fb */ |
687,6 → 649,7 |
printf(NAME ": HelenOS Console service\n"); |
ipcarg_t phonehash; |
int kbd_phone; |
size_t ib_size; |
int i; |
/branches/dd/uspace/srv/console/Makefile |
---|
78,7 → 78,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/rd/rd.c |
---|
52,8 → 52,8 |
#include <async.h> |
#include <futex.h> |
#include <stdio.h> |
#include <devmap.h> |
#include <ipc/bd.h> |
#include <ipc/devmap.h> |
#include "rd.h" |
#define NAME "rd" |
112,7 → 112,7 |
return; |
} |
while (true) { |
while (1) { |
callid = async_get_call(&call); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
122,7 → 122,7 |
*/ |
ipc_answer_0(callid, EOK); |
return; |
case BD_READ_BLOCK: |
case RD_READ_BLOCK: |
offset = IPC_GET_ARG1(call); |
block_size = IPC_GET_ARG2(call); |
if (block_size > maxblock_size) { |
144,7 → 144,7 |
futex_up(&rd_futex); |
retval = EOK; |
break; |
case BD_WRITE_BLOCK: |
case RD_WRITE_BLOCK: |
offset = IPC_GET_ARG1(call); |
block_size = IPC_GET_ARG2(call); |
if (block_size > maxblock_size) { |
180,6 → 180,66 |
} |
} |
static int driver_register(char *name) |
{ |
ipcarg_t retval; |
aid_t req; |
ipc_call_t answer; |
int phone; |
ipcarg_t callback_phonehash; |
phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER, 0); |
if (phone < 0) { |
printf(NAME ": Failed to connect to device mapper\n"); |
return -1; |
} |
req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer); |
retval = ipc_data_write_start(phone, (char *) name, str_size(name) + 1); |
if (retval != EOK) { |
async_wait_for(req, NULL); |
return -1; |
} |
async_set_client_connection(rd_connection); |
ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash); |
async_wait_for(req, &retval); |
return phone; |
} |
static int device_register(int driver_phone, char *name, int *handle) |
{ |
ipcarg_t retval; |
aid_t req; |
ipc_call_t answer; |
req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer); |
retval = ipc_data_write_start(driver_phone, (char *) name, |
str_size(name) + 1); |
if (retval != EOK) { |
async_wait_for(req, NULL); |
return retval; |
} |
async_wait_for(req, &retval); |
if (handle != NULL) |
*handle = -1; |
if (EOK == retval) { |
if (NULL != handle) |
*handle = (int) IPC_GET_ARG1(answer); |
} |
return retval; |
} |
/** Prepare the ramdisk image for operation. */ |
static bool rd_init(void) |
{ |
204,15 → 264,15 |
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); |
int driver_phone = driver_register(NAME); |
if (driver_phone < 0) { |
printf(NAME ": Unable to register driver\n"); |
return false; |
} |
dev_handle_t dev_handle; |
if (devmap_device_register("initrd", &dev_handle) != EOK) { |
devmap_hangup_phone(DEVMAP_DRIVER); |
int dev_handle; |
if (EOK != device_register(driver_phone, "initrd", &dev_handle)) { |
ipc_hangup(driver_phone); |
printf(NAME ": Unable to register device\n"); |
return false; |
} |
236,4 → 296,4 |
/** |
* @} |
*/ |
*/ |
/branches/dd/uspace/srv/rd/rd.h |
---|
0,0 → 1,50 |
/* |
* 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.h |
* @brief Initial RAM disk for HelenOS - header |
*/ |
/* Basic constants. */ |
#ifndef RD_RD_H_ |
#define RD_RD_H_ |
#define RD_BASE 1024 |
#define RD_READ_BLOCK (RD_BASE + 1) /**< Method for reading block. */ |
#define RD_WRITE_BLOCK (RD_BASE + 2) /**< Method for writing block. */ |
#endif |
/branches/dd/uspace/srv/rd/Makefile |
---|
64,7 → 64,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/loader/main.c |
---|
231,7 → 231,7 |
int rc; |
rc = elf_load_file(pathname, 0, &prog_info); |
if (rc != EE_OK) { |
if (rc < 0) { |
DPRINTF("Failed to load executable '%s'.\n", pathname); |
ipc_answer_0(rid, EINVAL); |
return 1; |
250,7 → 250,7 |
} |
rc = elf_load_file(prog_info.interp, 0, &interp_info); |
if (rc != EE_OK) { |
if (rc < 0) { |
DPRINTF("Failed to load interpreter '%s.'\n", |
prog_info.interp); |
ipc_answer_0(rid, EINVAL); |
/branches/dd/uspace/srv/fb/serial_console.c |
---|
274,6 → 274,9 |
serial_goto(y, x); |
for (i = 0; i < w; i++) { |
unsigned int col = x + i; |
unsigned int row = y + j; |
field = &data[j * w + i]; |
a1 = &field->attrs; |
301,9 → 304,12 |
wchar_t c; |
int col, row, w, h; |
int fgcolor; |
int bgcolor; |
int flags; |
int style; |
int i; |
attrs_t cur_attr; |
if (client_connected) { |
ipc_answer_0(iid, ELIMIT); |
312,9 → 318,6 |
client_connected = 1; |
ipc_answer_0(iid, EOK); |
cur_attr.t = at_style; |
cur_attr.a.s.style = STYLE_NORMAL; |
/* Clear the terminal, set scrolling region |
to 0 - height rows. */ |
385,28 → 388,23 |
retval = 0; |
break; |
case FB_SET_STYLE: |
cur_attr.t = at_style; |
cur_attr.a.s.style = IPC_GET_ARG1(call); |
cur_attr.a.i.bg_color = IPC_GET_ARG2(call); |
serial_set_attrs(&cur_attr); |
style = IPC_GET_ARG1(call); |
serial_set_style(style); |
retval = 0; |
break; |
case FB_SET_COLOR: |
cur_attr.t = at_idx; |
cur_attr.a.i.fg_color = IPC_GET_ARG1(call); |
cur_attr.a.i.bg_color = IPC_GET_ARG2(call); |
cur_attr.a.i.flags = IPC_GET_ARG3(call); |
serial_set_attrs(&cur_attr); |
fgcolor = IPC_GET_ARG1(call); |
bgcolor = IPC_GET_ARG2(call); |
flags = IPC_GET_ARG3(call); |
serial_set_idx(fgcolor, bgcolor, flags); |
retval = 0; |
break; |
case FB_SET_RGB_COLOR: |
cur_attr.t = at_rgb; |
cur_attr.a.i.fg_color = IPC_GET_ARG1(call); |
cur_attr.a.i.bg_color = IPC_GET_ARG2(call); |
serial_set_attrs(&cur_attr); |
fgcolor = IPC_GET_ARG1(call); |
bgcolor = IPC_GET_ARG2(call); |
serial_set_rgb(fgcolor, bgcolor); |
retval = 0; |
break; |
case FB_SCROLL: |
426,18 → 424,6 |
serial_cursor_disable(); |
retval = 0; |
break; |
case FB_SCREEN_YIELD: |
serial_sgr(SGR_RESET); |
serial_puts("\033[2J"); |
serial_goto(0, 0); |
serial_cursor_enable(); |
retval = 0; |
break; |
case FB_SCREEN_RECLAIM: |
serial_clrscr(); |
serial_set_attrs(&cur_attr); |
retval = 0; |
break; |
default: |
retval = ENOENT; |
} |
/branches/dd/uspace/srv/fb/fb.c |
---|
30,7 → 30,7 |
/** |
* @defgroup fb Graphical framebuffer |
* @brief HelenOS graphical framebuffer. |
* @brief HelenOS graphical framebuffer. |
* @ingroup fbs |
* @{ |
*/ |
68,7 → 68,7 |
#define DEFAULT_BGCOLOR 0xf0f0f0 |
#define DEFAULT_FGCOLOR 0x000000 |
#define GLYPH_UNAVAIL '?' |
#define GLYPH_UNAVAIL '?' |
#define MAX_ANIM_LEN 8 |
#define MAX_ANIMATIONS 4 |
78,9 → 78,6 |
/** Function to render a pixel from a RGB value. */ |
typedef void (*rgb_conv_t)(void *, uint32_t); |
/** Function to render a bit mask. */ |
typedef void (*mask_conv_t)(void *, bool); |
/** Function to draw a glyph. */ |
typedef void (*dg_t)(unsigned int x, unsigned int y, bool cursor, |
uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color); |
96,12 → 93,11 |
unsigned int pixelbytes; |
unsigned int glyphbytes; |
/** Pre-rendered mask for rendering glyphs. Specific for the visual. */ |
uint8_t *glyphs; |
rgb_conv_t rgb_conv; |
mask_conv_t mask_conv; |
} screen; |
/** Backbuffer character cell. */ |
125,12 → 121,12 |
/* |
* Style and glyphs for text printing |
*/ |
/** Current attributes. */ |
attr_rgb_t attr; |
uint8_t *bgpixel; |
/** |
* Glyph drawing function for this viewport. Different viewports |
* might use different drawing functions depending on whether their |
174,23 → 170,23 |
static bool client_connected = false; /**< Allow only 1 connection */ |
static uint32_t color_table[16] = { |
[COLOR_BLACK] = 0x000000, |
[COLOR_BLUE] = 0x0000f0, |
[COLOR_GREEN] = 0x00f000, |
[COLOR_CYAN] = 0x00f0f0, |
[COLOR_RED] = 0xf00000, |
[COLOR_MAGENTA] = 0xf000f0, |
[COLOR_YELLOW] = 0xf0f000, |
[COLOR_WHITE] = 0xf0f0f0, |
[8 + COLOR_BLACK] = 0x000000, |
[8 + COLOR_BLUE] = 0x0000ff, |
[8 + COLOR_GREEN] = 0x00ff00, |
[8 + COLOR_CYAN] = 0x00ffff, |
[8 + COLOR_RED] = 0xff0000, |
[8 + COLOR_MAGENTA] = 0xff00ff, |
[8 + COLOR_YELLOW] = 0xffff00, |
[8 + COLOR_WHITE] = 0xffffff, |
[COLOR_BLACK] = 0x000000, |
[COLOR_BLUE] = 0x0000f0, |
[COLOR_GREEN] = 0x00f000, |
[COLOR_CYAN] = 0x00f0f0, |
[COLOR_RED] = 0xf00000, |
[COLOR_MAGENTA] = 0xf000f0, |
[COLOR_YELLOW] = 0xf0f000, |
[COLOR_WHITE] = 0xf0f0f0, |
[8 + COLOR_BLACK] = 0x000000, |
[8 + COLOR_BLUE] = 0x0000ff, |
[8 + COLOR_GREEN] = 0x00ff00, |
[8 + COLOR_CYAN] = 0x00ffff, |
[8 + COLOR_RED] = 0xff0000, |
[8 + COLOR_MAGENTA] = 0xff00ff, |
[8 + COLOR_YELLOW] = 0xffff00, |
[8 + COLOR_WHITE] = 0xffffff, |
}; |
static int rgb_from_attr(attr_rgb_t *rgb, const attrs_t *a); |
230,15 → 226,10 |
*/ |
static void rgb_0888(void *dst, uint32_t rgb) |
{ |
*((uint32_t *) dst) = rgb & 0x00ffffff; |
*((uint32_t *) dst) = rgb & 0xffffff; |
} |
static void mask_0888(void *dst, bool mask) |
{ |
*((uint32_t *) dst) = (mask ? 0x00ffffff : 0); |
} |
/** ABGR 8:8:8:8 conversion |
* |
*/ |
259,20 → 250,7 |
((uint8_t *) dst)[2] = RED(rgb, 8); |
} |
static void mask_888(void *dst, bool mask) |
{ |
if (mask) { |
((uint8_t *) dst)[0] = 0xff; |
((uint8_t *) dst)[1] = 0xff; |
((uint8_t *) dst)[2] = 0xff; |
} else { |
((uint8_t *) dst)[0] = 0; |
((uint8_t *) dst)[1] = 0; |
((uint8_t *) dst)[2] = 0; |
} |
} |
/** BGR 8:8:8 conversion |
* |
*/ |
293,12 → 271,7 |
= (RED(rgb, 5) << 10) | (GREEN(rgb, 5) << 5) | BLUE(rgb, 5); |
} |
static void mask_555(void *dst, bool mask) |
{ |
*((uint16_t *) dst) = (mask ? 0x7fff : 0); |
} |
/** RGB 5:6:5 conversion |
* |
*/ |
308,12 → 281,7 |
= (RED(rgb, 5) << 11) | (GREEN(rgb, 6) << 5) | BLUE(rgb, 5); |
} |
static void mask_565(void *dst, bool mask) |
{ |
*((uint16_t *) dst) = (mask ? 0xffff : 0); |
} |
/** RGB 3:2:3 |
* |
*/ |
323,44 → 291,34 |
= ~((RED(rgb, 3) << 5) | (GREEN(rgb, 2) << 3) | BLUE(rgb, 3)); |
} |
static void mask_323(void *dst, bool mask) |
{ |
*((uint8_t *) dst) = (mask ? 0xff : 0); |
} |
/** Draw a filled rectangle. |
* |
* @note Need real implementation that does not access VRAM twice. |
* |
*/ |
static void draw_filled_rect(unsigned int x0, unsigned int y0, unsigned int x1, |
unsigned int y1, uint32_t color) |
{ |
unsigned int x; |
unsigned int y; |
unsigned int x, y; |
unsigned int copy_bytes; |
uint8_t *sp; |
uint8_t *dp; |
uint8_t *sp, *dp; |
uint8_t cbuf[4]; |
if ((y0 >= y1) || (x0 >= x1)) |
return; |
if (y0 >= y1 || x0 >= x1) return; |
screen.rgb_conv(cbuf, color); |
sp = &screen.fb_addr[FB_POS(x0, y0)]; |
dp = sp; |
/* Draw the first line. */ |
for (x = x0; x < x1; x++) { |
memcpy(dp, cbuf, screen.pixelbytes); |
dp += screen.pixelbytes; |
} |
dp = sp + screen.scanline; |
copy_bytes = (x1 - x0) * screen.pixelbytes; |
/* Draw the remaining lines by copying. */ |
for (y = y0 + 1; y < y1; y++) { |
memcpy(dp, sp, copy_bytes); |
375,15 → 333,14 |
*/ |
static void vport_redraw(viewport_t *vport) |
{ |
unsigned int row; |
unsigned int col; |
unsigned int row, col; |
for (row = 0; row < vport->rows; row++) { |
for (col = 0; col < vport->cols; col++) { |
draw_vp_glyph(vport, false, col, row); |
} |
} |
if (COL2X(vport->cols) < vport->width) { |
draw_filled_rect( |
vport->x + COL2X(vport->cols), vport->y, |
390,7 → 347,7 |
vport->x + vport->width, vport->y + vport->height, |
vport->attr.bg_color); |
} |
if (ROW2Y(vport->rows) < vport->height) { |
draw_filled_rect( |
vport->x, vport->y + ROW2Y(vport->rows), |
402,8 → 359,8 |
static void backbuf_clear(bb_cell_t *backbuf, size_t len, uint32_t fg_color, |
uint32_t bg_color) |
{ |
size_t i; |
unsigned i; |
for (i = 0; i < len; i++) { |
backbuf[i].glyph = 0; |
backbuf[i].fg_color = fg_color; |
431,20 → 388,17 |
*/ |
static void vport_scroll(viewport_t *vport, int lines) |
{ |
unsigned int row; |
unsigned int col; |
unsigned int x; |
unsigned int y; |
unsigned int row, col; |
unsigned int x, y; |
uint32_t glyph; |
uint32_t fg_color; |
uint32_t bg_color; |
bb_cell_t *bbp; |
bb_cell_t *xbp; |
bb_cell_t *bbp, *xbp; |
/* |
* Redraw. |
*/ |
y = vport->y; |
for (row = 0; row < vport->rows; row++) { |
x = vport->x; |
452,14 → 406,14 |
if ((row + lines >= 0) && (row + lines < vport->rows)) { |
xbp = &vport->backbuf[BB_POS(vport, col, row + lines)]; |
bbp = &vport->backbuf[BB_POS(vport, col, row)]; |
glyph = xbp->glyph; |
fg_color = xbp->fg_color; |
bg_color = xbp->bg_color; |
if ((bbp->glyph == glyph) |
&& (bbp->fg_color == xbp->fg_color) |
&& (bbp->bg_color == xbp->bg_color)) { |
if (bbp->glyph == glyph && |
bbp->fg_color == xbp->fg_color && |
bbp->bg_color == xbp->bg_color) { |
x += FONT_WIDTH; |
continue; |
} |
468,7 → 422,7 |
fg_color = vport->attr.fg_color; |
bg_color = vport->attr.bg_color; |
} |
(*vport->dglyph)(x, y, false, screen.glyphs, glyph, |
fg_color, bg_color); |
x += FONT_WIDTH; |
475,11 → 429,11 |
} |
y += FONT_SCANLINES; |
} |
/* |
* Scroll backbuffer. |
*/ |
if (lines > 0) { |
memmove(vport->backbuf, vport->backbuf + vport->cols * lines, |
vport->cols * (vport->rows - lines) * sizeof(bb_cell_t)); |
497,29 → 451,31 |
* |
* Convert glyphs from device independent font |
* description to current visual representation. |
* |
*/ |
static void render_glyphs(void) |
{ |
unsigned int glyph; |
for (glyph = 0; glyph < FONT_GLYPHS; glyph++) { |
unsigned int y; |
for (y = 0; y < FONT_SCANLINES; y++) { |
unsigned int x; |
for (x = 0; x < FONT_WIDTH; x++) { |
screen.mask_conv(&screen.glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes], |
(fb_font[glyph][y] & (1 << (7 - x))) ? true : false); |
screen.mask_conv(&screen.glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], |
(fb_font[glyph][y] & (1 << (7 - x))) ? false : true); |
screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes], |
(fb_font[glyph][y] & (1 << (7 - x))) |
? 0xffffff : 0x000000); |
screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], |
(fb_font[glyph][y] & (1 << (7 - x))) |
? 0x000000 : 0xffffff); |
} |
} |
} |
} |
/** Create new viewport |
* |
* @param x Origin of the viewport (x). |
539,7 → 495,6 |
if (!viewports[i].initialized) |
break; |
} |
if (i == MAX_VIEWPORTS) |
return ELIMIT; |
557,7 → 512,7 |
free(backbuf); |
return ENOMEM; |
} |
backbuf_clear(backbuf, cols * rows, DEFAULT_FGCOLOR, DEFAULT_BGCOLOR); |
memset(bgpixel, 0, screen.pixelbytes); |
573,23 → 528,24 |
viewports[i].attr.fg_color = DEFAULT_FGCOLOR; |
viewports[i].bgpixel = bgpixel; |
/* |
* Conditions necessary to select aligned version: |
* - word size is divisible by pixelbytes |
* - cell scanline size is divisible by word size |
* - cell scanlines are word-aligned |
* Conditions necessary to select aligned version: |
* |
* - word size is divisible by pixelbytes |
* - cell scanline size is divisible by word size |
* - cell scanlines are word-aligned |
*/ |
if (((word_size % screen.pixelbytes) == 0) |
&& ((FONT_WIDTH * screen.pixelbytes) % word_size == 0) |
&& ((x * screen.pixelbytes) % word_size == 0) |
&& (screen.scanline % word_size == 0)) { |
if ((word_size % screen.pixelbytes) == 0 && |
(FONT_WIDTH * screen.pixelbytes) % word_size == 0 && |
(x * screen.pixelbytes) % word_size == 0 && |
screen.scanline % word_size == 0) { |
viewports[i].dglyph = draw_glyph_aligned; |
} else { |
viewports[i].dglyph = draw_glyph_fallback; |
} |
viewports[i].cur_col = 0; |
viewports[i].cur_row = 0; |
viewports[i].cursor_active = false; |
618,53 → 574,45 |
static bool screen_init(void *addr, unsigned int xres, unsigned int yres, |
unsigned int scan, unsigned int visual) |
{ |
unsigned int glyphsize; |
uint8_t *glyphs; |
switch (visual) { |
case VISUAL_INDIRECT_8: |
screen.rgb_conv = rgb_323; |
screen.mask_conv = mask_323; |
screen.pixelbytes = 1; |
break; |
case VISUAL_RGB_5_5_5: |
screen.rgb_conv = rgb_555; |
screen.mask_conv = mask_555; |
screen.pixelbytes = 2; |
break; |
case VISUAL_RGB_5_6_5: |
screen.rgb_conv = rgb_565; |
screen.mask_conv = mask_565; |
screen.pixelbytes = 2; |
break; |
case VISUAL_RGB_8_8_8: |
screen.rgb_conv = rgb_888; |
screen.mask_conv = mask_888; |
screen.pixelbytes = 3; |
break; |
case VISUAL_BGR_8_8_8: |
screen.rgb_conv = bgr_888; |
screen.mask_conv = mask_888; |
screen.pixelbytes = 3; |
break; |
case VISUAL_RGB_8_8_8_0: |
screen.rgb_conv = rgb_888; |
screen.mask_conv = mask_888; |
screen.pixelbytes = 4; |
break; |
case VISUAL_RGB_0_8_8_8: |
screen.rgb_conv = rgb_0888; |
screen.mask_conv = mask_0888; |
screen.pixelbytes = 4; |
break; |
case VISUAL_BGR_0_8_8_8: |
screen.rgb_conv = bgr_0888; |
screen.mask_conv = mask_0888; |
screen.pixelbytes = 4; |
break; |
default: |
return false; |
} |
screen.fb_addr = (unsigned char *) addr; |
screen.xres = xres; |
screen.yres = yres; |
672,15 → 620,15 |
screen.glyphscanline = FONT_WIDTH * screen.pixelbytes; |
screen.glyphbytes = screen.glyphscanline * FONT_SCANLINES; |
size_t glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
uint8_t *glyphs = (uint8_t *) malloc(glyphsize); |
glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
glyphs = (uint8_t *) malloc(glyphsize); |
if (!glyphs) |
return false; |
memset(glyphs, 0, glyphsize); |
screen.glyphs = glyphs; |
render_glyphs(); |
/* Create first viewport */ |
703,47 → 651,46 |
* making it very fast. Most notably this version is not applicable at 24 bits |
* per pixel. |
* |
* @param x x coordinate of top-left corner on screen. |
* @param y y coordinate of top-left corner on screen. |
* @param cursor Draw glyph with cursor |
* @param glyphs Pointer to font bitmap. |
* @param glyph Code of the glyph to draw. |
* @param fg_color Foreground color. |
* @param bg_color Backgroudn color. |
* |
* @param x x coordinate of top-left corner on screen. |
* @param y y coordinate of top-left corner on screen. |
* @param cursor Draw glyph with cursor |
* @param glyphs Pointer to font bitmap. |
* @param glyph Code of the glyph to draw. |
* @param fg_color Foreground color. |
* @param bg_color Backgroudn color. |
*/ |
static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color) |
{ |
unsigned int i; |
unsigned int yd; |
unsigned long fg_buf; |
unsigned long bg_buf; |
unsigned int i, yd; |
unsigned long fg_buf, bg_buf; |
unsigned long *maskp, *dp; |
unsigned long mask; |
unsigned int ww, d_add; |
/* |
* Prepare a pair of words, one filled with foreground-color |
* pattern and the other filled with background-color pattern. |
*/ |
for (i = 0; i < sizeof(unsigned long) / screen.pixelbytes; i++) { |
screen.rgb_conv(&((uint8_t *) &fg_buf)[i * screen.pixelbytes], |
screen.rgb_conv(&((uint8_t *)&fg_buf)[i * screen.pixelbytes], |
fg_color); |
screen.rgb_conv(&((uint8_t *) &bg_buf)[i * screen.pixelbytes], |
screen.rgb_conv(&((uint8_t *)&bg_buf)[i * screen.pixelbytes], |
bg_color); |
} |
/* Pointer to the current position in the mask. */ |
unsigned long *maskp = (unsigned long *) &glyphs[GLYPH_POS(glyph, 0, cursor)]; |
maskp = (unsigned long *) &glyphs[GLYPH_POS(glyph, 0, cursor)]; |
/* Pointer to the current position on the screen. */ |
unsigned long *dp = (unsigned long *) &screen.fb_addr[FB_POS(x, y)]; |
dp = (unsigned long *) &screen.fb_addr[FB_POS(x, y)]; |
/* Width of the character cell in words. */ |
unsigned int ww = FONT_WIDTH * screen.pixelbytes / sizeof(unsigned long); |
ww = FONT_WIDTH * screen.pixelbytes / sizeof(unsigned long); |
/* Offset to add when moving to another screen scanline. */ |
unsigned int d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
for (yd = 0; yd < FONT_SCANLINES; yd++) { |
/* |
* Now process the cell scanline, combining foreground |
753,7 → 700,7 |
mask = *maskp++; |
*dp++ = (fg_buf & mask) | (bg_buf & ~mask); |
} |
/* Move to the beginning of the next scanline of the cell. */ |
dp = (unsigned long *) ((uint8_t *) dp + d_add); |
} |
764,26 → 711,23 |
* This version does not make use of the pre-rendered mask, it uses |
* the font bitmap directly. It works always, but it is slower. |
* |
* @param x x coordinate of top-left corner on screen. |
* @param y y coordinate of top-left corner on screen. |
* @param cursor Draw glyph with cursor |
* @param glyphs Pointer to font bitmap. |
* @param glyph Code of the glyph to draw. |
* @param fg_color Foreground color. |
* @param bg_color Backgroudn color. |
* |
* @param x x coordinate of top-left corner on screen. |
* @param y y coordinate of top-left corner on screen. |
* @param cursor Draw glyph with cursor |
* @param glyphs Pointer to font bitmap. |
* @param glyph Code of the glyph to draw. |
* @param fg_color Foreground color. |
* @param bg_color Backgroudn color. |
*/ |
void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color) |
{ |
unsigned int i; |
unsigned int j; |
unsigned int yd; |
uint8_t fg_buf[4]; |
uint8_t bg_buf[4]; |
uint8_t *sp; |
unsigned int i, j, yd; |
uint8_t fg_buf[4], bg_buf[4]; |
uint8_t *dp, *sp; |
unsigned int d_add; |
uint8_t b; |
/* Pre-render 1x the foreground and background color pixels. */ |
if (cursor) { |
screen.rgb_conv(fg_buf, bg_color); |
792,26 → 736,26 |
screen.rgb_conv(fg_buf, fg_color); |
screen.rgb_conv(bg_buf, bg_color); |
} |
/* Pointer to the current position on the screen. */ |
uint8_t *dp = (uint8_t *) &screen.fb_addr[FB_POS(x, y)]; |
dp = (uint8_t *) &screen.fb_addr[FB_POS(x, y)]; |
/* Offset to add when moving to another screen scanline. */ |
unsigned int d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
for (yd = 0; yd < FONT_SCANLINES; yd++) { |
/* Byte containing bits of the glyph scanline. */ |
b = fb_font[glyph][yd]; |
for (i = 0; i < FONT_WIDTH; i++) { |
/* Choose color based on the current bit. */ |
sp = (b & 0x80) ? fg_buf : bg_buf; |
/* Copy the pixel. */ |
for (j = 0; j < screen.pixelbytes; j++) { |
*dp++ = *sp++; |
} |
/* Move to the next bit. */ |
b = b << 1; |
} |
821,7 → 765,7 |
} |
} |
/** Draw glyph at specified position in viewport. |
/** Draw glyph at specified position in viewport. |
* |
* @param vport Viewport identification |
* @param cursor Draw glyph with cursor |
834,11 → 778,15 |
{ |
unsigned int x = vport->x + COL2X(col); |
unsigned int y = vport->y + ROW2Y(row); |
uint32_t glyph; |
uint32_t fg_color; |
uint32_t bg_color; |
uint32_t glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
uint32_t fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
uint32_t bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
(*vport->dglyph)(x, y, cursor, screen.glyphs, glyph, |
fg_color, bg_color); |
} |
891,17 → 839,17 |
static void draw_char(viewport_t *vport, wchar_t c, unsigned int col, unsigned int row) |
{ |
bb_cell_t *bbp; |
/* Do not hide cursor if we are going to overwrite it */ |
if ((vport->cursor_active) && (vport->cursor_shown) && |
((vport->cur_col != col) || (vport->cur_row != row))) |
cursor_hide(vport); |
bbp = &vport->backbuf[BB_POS(vport, col, row)]; |
bbp->glyph = fb_font_glyph(c); |
bbp->fg_color = vport->attr.fg_color; |
bbp->bg_color = vport->attr.bg_color; |
draw_vp_glyph(vport, false, col, row); |
vport->cur_col = col; |
922,35 → 870,33 |
* |
* @param vport Viewport id |
* @param data Text data. |
* @param x Leftmost column of the area. |
* @param y Topmost row of the area. |
* @param w Number of rows. |
* @param h Number of columns. |
* |
* @param x Leftmost column of the area. |
* @param y Topmost row of the area. |
* @param w Number of rows. |
* @param h Number of columns. |
*/ |
static void draw_text_data(viewport_t *vport, keyfield_t *data, unsigned int x, |
unsigned int y, unsigned int w, unsigned int h) |
{ |
unsigned int i; |
unsigned int j; |
unsigned int i, j; |
bb_cell_t *bbp; |
attrs_t *a; |
attr_rgb_t rgb; |
for (j = 0; j < h; j++) { |
for (i = 0; i < w; i++) { |
unsigned int col = x + i; |
unsigned int row = y + j; |
bbp = &vport->backbuf[BB_POS(vport, col, row)]; |
a = &data[j * w + i].attrs; |
rgb_from_attr(&rgb, a); |
bbp->glyph = fb_font_glyph(data[j * w + i].character); |
bbp->fg_color = rgb.fg_color; |
bbp->bg_color = rgb.bg_color; |
draw_vp_glyph(vport, false, col, row); |
} |
} |
1246,7 → 1192,7 |
counts = (counts + 1) % 8; |
if (counts) |
return; |
for (i = 0; i < MAX_ANIMATIONS; i++) { |
if ((!animations[i].animlen) || (!animations[i].initialized) || |
(!animations[i].enabled)) |
1713,10 → 1659,6 |
mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
retval = EOK; |
break; |
case FB_SCREEN_YIELD: |
case FB_SCREEN_RECLAIM: |
retval = EOK; |
break; |
default: |
retval = ENOENT; |
} |
/branches/dd/uspace/srv/fb/ega.c |
---|
391,10 → 391,7 |
} |
retval = 0; |
break; |
case FB_SCREEN_YIELD: |
case FB_SCREEN_RECLAIM: |
retval = EOK; |
break; |
default: |
retval = EINVAL; |
} |
/branches/dd/uspace/srv/fb/Makefile |
---|
34,8 → 34,10 |
include $(LIBC_PREFIX)/Makefile.toolchain |
LIBS = $(LIBC_PREFIX)/libc.a |
CFLAGS += -I../libipc/include |
LIBS = $(LIBC_PREFIX)/libc.a |
## Sources |
# |
103,7 → 105,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/fs/devfs/devfs.h |
---|
File deleted |
/branches/dd/uspace/srv/fs/devfs/Makefile |
---|
File deleted |
/branches/dd/uspace/srv/fs/devfs/devfs_ops.h |
---|
File deleted |
/branches/dd/uspace/srv/fs/devfs/devfs.c |
---|
File deleted |
/branches/dd/uspace/srv/fs/devfs/devfs_ops.c |
---|
File deleted |
/branches/dd/uspace/srv/fs/tmpfs/tmpfs.h |
---|
44,9 → 44,6 |
#define dprintf(...) printf(__VA_ARGS__) |
#endif |
#define TMPFS_NODE(node) ((node) ? (tmpfs_node_t *)(node)->data : NULL) |
#define FS_NODE(node) ((node) ? (node)->bp : NULL) |
typedef enum { |
TMPFS_NONE, |
TMPFS_FILE, |
53,33 → 50,22 |
TMPFS_DIRECTORY |
} tmpfs_dentry_type_t; |
/* forward declaration */ |
struct tmpfs_node; |
typedef struct tmpfs_dentry { |
link_t link; /**< Linkage for the list of siblings. */ |
struct tmpfs_node *node;/**< Back pointer to TMPFS node. */ |
char *name; /**< Name of dentry. */ |
} tmpfs_dentry_t; |
typedef struct tmpfs_node { |
fs_node_t *bp; /**< Back pointer to the FS node. */ |
fs_index_t index; /**< TMPFS node index. */ |
dev_handle_t dev_handle;/**< Device handle. */ |
link_t nh_link; /**< Nodes hash table link. */ |
link_t dh_link; /**< Dentries hash table link. */ |
struct tmpfs_dentry *sibling; |
struct tmpfs_dentry *child; |
hash_table_t names; /**< All names linking to this TMPFS node. */ |
tmpfs_dentry_type_t type; |
unsigned lnkcnt; /**< Link count. */ |
size_t size; /**< File size if type is TMPFS_FILE. */ |
void *data; /**< File content's if type is TMPFS_FILE. */ |
link_t cs_head; /**< Head of child's siblings list. */ |
} tmpfs_node_t; |
} tmpfs_dentry_t; |
extern fs_reg_t tmpfs_reg; |
extern libfs_ops_t tmpfs_libfs_ops; |
extern bool tmpfs_init(void); |
extern void tmpfs_mounted(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_mount(ipc_callid_t, ipc_call_t *); |
extern void tmpfs_lookup(ipc_callid_t, ipc_call_t *); |
/branches/dd/uspace/srv/fs/tmpfs/tmpfs_dump.c |
---|
55,7 → 55,7 |
static bool |
tmpfs_restore_recursion(int dev, off_t *bufpos, size_t *buflen, off_t *pos, |
fs_node_t *pfn) |
tmpfs_dentry_t *parent) |
{ |
struct rdentry entry; |
libfs_ops_t *ops = &tmpfs_libfs_ops; |
63,8 → 63,7 |
do { |
char *fname; |
fs_node_t *fn; |
tmpfs_node_t *nodep; |
tmpfs_dentry_t *node; |
uint32_t size; |
if (block_read(dev, bufpos, buflen, pos, &entry, sizeof(entry), |
81,8 → 80,8 |
if (fname == NULL) |
return false; |
fn = ops->create(dev, L_FILE); |
if (fn == NULL) { |
node = (tmpfs_dentry_t *) ops->create(dev, L_FILE); |
if (node == NULL) { |
free(fname); |
return false; |
} |
89,15 → 88,15 |
if (block_read(dev, bufpos, buflen, pos, fname, |
entry.len, TMPFS_BLOCK_SIZE) != EOK) { |
ops->destroy(fn); |
ops->destroy((void *) node); |
free(fname); |
return false; |
} |
fname[entry.len] = 0; |
rc = ops->link(pfn, fn, fname); |
rc = ops->link((void *) parent, (void *) node, fname); |
if (rc != EOK) { |
ops->destroy(fn); |
ops->destroy((void *) node); |
free(fname); |
return false; |
} |
109,13 → 108,12 |
size = uint32_t_le2host(size); |
nodep = TMPFS_NODE(fn); |
nodep->data = malloc(size); |
if (nodep->data == NULL) |
node->data = malloc(size); |
if (node->data == NULL) |
return false; |
nodep->size = size; |
if (block_read(dev, bufpos, buflen, pos, nodep->data, |
node->size = size; |
if (block_read(dev, bufpos, buflen, pos, node->data, |
size, TMPFS_BLOCK_SIZE) != EOK) |
return false; |
125,8 → 123,8 |
if (fname == NULL) |
return false; |
fn = ops->create(dev, L_DIRECTORY); |
if (fn == NULL) { |
node = (tmpfs_dentry_t *) ops->create(dev, L_DIRECTORY); |
if (node == NULL) { |
free(fname); |
return false; |
} |
133,15 → 131,15 |
if (block_read(dev, bufpos, buflen, pos, fname, |
entry.len, TMPFS_BLOCK_SIZE) != EOK) { |
ops->destroy(fn); |
ops->destroy((void *) node); |
free(fname); |
return false; |
} |
fname[entry.len] = 0; |
rc = ops->link(pfn, fn, fname); |
rc = ops->link((void *) parent, (void *) node, fname); |
if (rc != EOK) { |
ops->destroy(fn); |
ops->destroy((void *) node); |
free(fname); |
return false; |
} |
148,7 → 146,7 |
free(fname); |
if (!tmpfs_restore_recursion(dev, bufpos, buflen, pos, |
fn)) |
node)) |
return false; |
break; |
/branches/dd/uspace/srv/fs/tmpfs/tmpfs.c |
---|
127,12 → 127,7 |
int main(int argc, char **argv) |
{ |
printf(NAME ": HelenOS TMPFS file system server\n"); |
if (!tmpfs_init()) { |
printf(NAME ": failed to initialize TMPFS\n"); |
return -1; |
} |
int vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0); |
if (vfs_phone < EOK) { |
printf(NAME ": Unable to connect to VFS\n"); |
145,7 → 140,7 |
printf(NAME ": Failed to register file system (%d)\n", rc); |
return rc; |
} |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
/* not reached */ |
/branches/dd/uspace/srv/fs/tmpfs/tmpfs_ops.c |
---|
54,50 → 54,55 |
#define min(a, b) ((a) < (b) ? (a) : (b)) |
#define max(a, b) ((a) > (b) ? (a) : (b)) |
#define NODES_BUCKETS 256 |
#define DENTRIES_BUCKETS 256 |
/** All root nodes have index 0. */ |
#define TMPFS_SOME_ROOT 0 |
/** Global counter for assigning node indices. Shared by all instances. */ |
fs_index_t tmpfs_next_index = 1; |
#define NAMES_BUCKETS 4 |
/* |
* For now, we don't distinguish between different dev_handles/instances. All |
* requests resolve to the only instance, rooted in the following variable. |
*/ |
static tmpfs_dentry_t *root; |
#define TMPFS_DEV 0 /**< Dummy device handle for TMPFS */ |
/* |
* Implementation of the libfs interface. |
*/ |
/* Forward declarations of static functions. */ |
static fs_node_t *tmpfs_match(fs_node_t *, const char *); |
static fs_node_t *tmpfs_node_get(dev_handle_t, fs_index_t); |
static void tmpfs_node_put(fs_node_t *); |
static fs_node_t *tmpfs_create_node(dev_handle_t, int); |
static int tmpfs_link_node(fs_node_t *, fs_node_t *, const char *); |
static int tmpfs_unlink_node(fs_node_t *, fs_node_t *, const char *); |
static int tmpfs_destroy_node(fs_node_t *); |
static void *tmpfs_match(void *, const char *); |
static void *tmpfs_node_get(dev_handle_t, fs_index_t); |
static void tmpfs_node_put(void *); |
static void *tmpfs_create_node(dev_handle_t, int); |
static int tmpfs_link_node(void *, void *, const char *); |
static int tmpfs_unlink_node(void *, void *); |
static int tmpfs_destroy_node(void *); |
/* Implementation of helper functions. */ |
static fs_index_t tmpfs_index_get(fs_node_t *fn) |
static fs_index_t tmpfs_index_get(void *nodep) |
{ |
return TMPFS_NODE(fn)->index; |
return ((tmpfs_dentry_t *) nodep)->index; |
} |
static size_t tmpfs_size_get(fs_node_t *fn) |
static size_t tmpfs_size_get(void *nodep) |
{ |
return TMPFS_NODE(fn)->size; |
return ((tmpfs_dentry_t *) nodep)->size; |
} |
static unsigned tmpfs_lnkcnt_get(fs_node_t *fn) |
static unsigned tmpfs_lnkcnt_get(void *nodep) |
{ |
return TMPFS_NODE(fn)->lnkcnt; |
return ((tmpfs_dentry_t *) nodep)->lnkcnt; |
} |
static bool tmpfs_has_children(fs_node_t *fn) |
static bool tmpfs_has_children(void *nodep) |
{ |
return !list_empty(&TMPFS_NODE(fn)->cs_head); |
return ((tmpfs_dentry_t *) nodep)->child != NULL; |
} |
static fs_node_t *tmpfs_root_get(dev_handle_t dev_handle) |
static void *tmpfs_root_get(dev_handle_t dev_handle) |
{ |
return tmpfs_node_get(dev_handle, TMPFS_SOME_ROOT); |
return root; |
} |
static char tmpfs_plb_get_char(unsigned pos) |
105,14 → 110,14 |
return tmpfs_reg.plb_ro[pos % PLB_SIZE]; |
} |
static bool tmpfs_is_directory(fs_node_t *fn) |
static bool tmpfs_is_directory(void *nodep) |
{ |
return TMPFS_NODE(fn)->type == TMPFS_DIRECTORY; |
return ((tmpfs_dentry_t *) nodep)->type == TMPFS_DIRECTORY; |
} |
static bool tmpfs_is_file(fs_node_t *fn) |
static bool tmpfs_is_file(void *nodep) |
{ |
return TMPFS_NODE(fn)->type == TMPFS_FILE; |
return ((tmpfs_dentry_t *) nodep)->type == TMPFS_FILE; |
} |
/** libfs operations */ |
134,231 → 139,259 |
.is_file = tmpfs_is_file |
}; |
/** Hash table of all TMPFS nodes. */ |
hash_table_t nodes; |
/** Hash table of all directory entries. */ |
hash_table_t dentries; |
#define NODES_KEY_INDEX 0 |
#define NODES_KEY_DEV 1 |
/* Implementation of hash table interface for the dentries hash table. */ |
static hash_index_t dentries_hash(unsigned long *key) |
{ |
return *key % DENTRIES_BUCKETS; |
} |
/* Implementation of hash table interface for the nodes hash table. */ |
static hash_index_t nodes_hash(unsigned long key[]) |
static int dentries_compare(unsigned long *key, hash_count_t keys, |
link_t *item) |
{ |
return key[NODES_KEY_INDEX] % NODES_BUCKETS; |
tmpfs_dentry_t *dentry = hash_table_get_instance(item, tmpfs_dentry_t, |
dh_link); |
return dentry->index == *key; |
} |
static int nodes_compare(unsigned long key[], hash_count_t keys, link_t *item) |
static void dentries_remove_callback(link_t *item) |
{ |
tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t, |
nh_link); |
return (nodep->index == key[NODES_KEY_INDEX] && |
nodep->dev_handle == key[NODES_KEY_DEV]); |
} |
static void nodes_remove_callback(link_t *item) |
/** TMPFS dentries hash table operations. */ |
hash_table_operations_t dentries_ops = { |
.hash = dentries_hash, |
.compare = dentries_compare, |
.remove_callback = dentries_remove_callback |
}; |
fs_index_t tmpfs_next_index = 1; |
typedef struct { |
char *name; |
tmpfs_dentry_t *parent; |
link_t link; |
} tmpfs_name_t; |
/* Implementation of hash table interface for the names hash table. */ |
static hash_index_t names_hash(unsigned long *key) |
{ |
tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) *key; |
return dentry->index % NAMES_BUCKETS; |
} |
/** TMPFS nodes hash table operations. */ |
hash_table_operations_t nodes_ops = { |
.hash = nodes_hash, |
.compare = nodes_compare, |
.remove_callback = nodes_remove_callback |
static int names_compare(unsigned long *key, hash_count_t keys, link_t *item) |
{ |
tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) *key; |
tmpfs_name_t *namep = hash_table_get_instance(item, tmpfs_name_t, |
link); |
return dentry == namep->parent; |
} |
static void names_remove_callback(link_t *item) |
{ |
tmpfs_name_t *namep = hash_table_get_instance(item, tmpfs_name_t, |
link); |
free(namep->name); |
free(namep); |
} |
/** TMPFS node names hash table operations. */ |
static hash_table_operations_t names_ops = { |
.hash = names_hash, |
.compare = names_compare, |
.remove_callback = names_remove_callback |
}; |
static void tmpfs_node_initialize(tmpfs_node_t *nodep) |
static void tmpfs_name_initialize(tmpfs_name_t *namep) |
{ |
nodep->bp = NULL; |
nodep->index = 0; |
nodep->dev_handle = 0; |
nodep->type = TMPFS_NONE; |
nodep->lnkcnt = 0; |
nodep->size = 0; |
nodep->data = NULL; |
link_initialize(&nodep->nh_link); |
list_initialize(&nodep->cs_head); |
namep->name = NULL; |
namep->parent = NULL; |
link_initialize(&namep->link); |
} |
static void tmpfs_dentry_initialize(tmpfs_dentry_t *dentryp) |
static bool tmpfs_dentry_initialize(tmpfs_dentry_t *dentry) |
{ |
link_initialize(&dentryp->link); |
dentryp->name = NULL; |
dentryp->node = NULL; |
dentry->index = 0; |
dentry->sibling = NULL; |
dentry->child = NULL; |
dentry->type = TMPFS_NONE; |
dentry->lnkcnt = 0; |
dentry->size = 0; |
dentry->data = NULL; |
link_initialize(&dentry->dh_link); |
return (bool)hash_table_create(&dentry->names, NAMES_BUCKETS, 1, |
&names_ops); |
} |
bool tmpfs_init(void) |
static bool tmpfs_init(void) |
{ |
if (!hash_table_create(&nodes, NODES_BUCKETS, 2, &nodes_ops)) |
if (!hash_table_create(&dentries, DENTRIES_BUCKETS, 1, &dentries_ops)) |
return false; |
root = (tmpfs_dentry_t *) tmpfs_create_node(TMPFS_DEV, L_DIRECTORY); |
if (!root) { |
hash_table_destroy(&dentries); |
return false; |
} |
root->lnkcnt = 0; /* FS root is not linked */ |
return true; |
} |
static bool tmpfs_instance_init(dev_handle_t dev_handle) |
/** Compare one component of path to a directory entry. |
* |
* @param parentp Pointer to node from which we descended. |
* @param childp Pointer to node to compare the path component with. |
* @param component Array of characters holding component name. |
* |
* @return True on match, false otherwise. |
*/ |
static bool |
tmpfs_match_one(tmpfs_dentry_t *parentp, tmpfs_dentry_t *childp, |
const char *component) |
{ |
fs_node_t *rfn; |
rfn = tmpfs_create_node(dev_handle, L_DIRECTORY); |
if (!rfn) |
return false; |
TMPFS_NODE(rfn)->lnkcnt = 0; /* FS root is not linked */ |
return true; |
unsigned long key = (unsigned long) parentp; |
link_t *hlp = hash_table_find(&childp->names, &key); |
assert(hlp); |
tmpfs_name_t *namep = hash_table_get_instance(hlp, tmpfs_name_t, link); |
return !str_cmp(namep->name, component); |
} |
fs_node_t *tmpfs_match(fs_node_t *pfn, const char *component) |
void *tmpfs_match(void *prnt, const char *component) |
{ |
tmpfs_node_t *parentp = TMPFS_NODE(pfn); |
link_t *lnk; |
tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt; |
tmpfs_dentry_t *childp = parentp->child; |
for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head; |
lnk = lnk->next) { |
tmpfs_dentry_t *dentryp = list_get_instance(lnk, tmpfs_dentry_t, |
link); |
if (!str_cmp(dentryp->name, component)) |
return FS_NODE(dentryp->node); |
} |
while (childp && !tmpfs_match_one(parentp, childp, component)) |
childp = childp->sibling; |
return NULL; |
return (void *) childp; |
} |
fs_node_t *tmpfs_node_get(dev_handle_t dev_handle, fs_index_t index) |
void * |
tmpfs_node_get(dev_handle_t dev_handle, fs_index_t index) |
{ |
unsigned long key[] = { |
[NODES_KEY_INDEX] = index, |
[NODES_KEY_DEV] = dev_handle |
}; |
link_t *lnk = hash_table_find(&nodes, key); |
unsigned long key = index; |
link_t *lnk = hash_table_find(&dentries, &key); |
if (!lnk) |
return NULL; |
return FS_NODE(hash_table_get_instance(lnk, tmpfs_node_t, nh_link)); |
return hash_table_get_instance(lnk, tmpfs_dentry_t, dh_link); |
} |
void tmpfs_node_put(fs_node_t *fn) |
void tmpfs_node_put(void *node) |
{ |
/* nothing to do */ |
} |
fs_node_t *tmpfs_create_node(dev_handle_t dev_handle, int lflag) |
void *tmpfs_create_node(dev_handle_t dev_handle, int lflag) |
{ |
assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY)); |
tmpfs_node_t *nodep = malloc(sizeof(tmpfs_node_t)); |
if (!nodep) |
tmpfs_dentry_t *node = malloc(sizeof(tmpfs_dentry_t)); |
if (!node) |
return NULL; |
tmpfs_node_initialize(nodep); |
nodep->bp = malloc(sizeof(fs_node_t)); |
if (!nodep->bp) { |
free(nodep); |
if (!tmpfs_dentry_initialize(node)) { |
free(node); |
return NULL; |
} |
fs_node_initialize(nodep->bp); |
nodep->bp->data = nodep; /* link the FS and TMPFS nodes */ |
if (!tmpfs_root_get(dev_handle)) |
nodep->index = TMPFS_SOME_ROOT; |
else |
nodep->index = tmpfs_next_index++; |
nodep->dev_handle = dev_handle; |
node->index = tmpfs_next_index++; |
if (lflag & L_DIRECTORY) |
nodep->type = TMPFS_DIRECTORY; |
node->type = TMPFS_DIRECTORY; |
else |
nodep->type = TMPFS_FILE; |
node->type = TMPFS_FILE; |
/* Insert the new node into the nodes hash table. */ |
unsigned long key[] = { |
[NODES_KEY_INDEX] = nodep->index, |
[NODES_KEY_DEV] = nodep->dev_handle |
}; |
hash_table_insert(&nodes, key, &nodep->nh_link); |
return FS_NODE(nodep); |
/* Insert the new node into the dentry hash table. */ |
unsigned long key = node->index; |
hash_table_insert(&dentries, &key, &node->dh_link); |
return (void *) node; |
} |
int tmpfs_link_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm) |
int tmpfs_link_node(void *prnt, void *chld, const char *nm) |
{ |
tmpfs_node_t *parentp = TMPFS_NODE(pfn); |
tmpfs_node_t *childp = TMPFS_NODE(cfn); |
tmpfs_dentry_t *dentryp; |
link_t *lnk; |
tmpfs_dentry_t *parentp = (tmpfs_dentry_t *) prnt; |
tmpfs_dentry_t *childp = (tmpfs_dentry_t *) chld; |
assert(parentp->type == TMPFS_DIRECTORY); |
/* Check for duplicit entries. */ |
for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head; |
lnk = lnk->next) { |
dentryp = list_get_instance(lnk, tmpfs_dentry_t, link); |
if (!str_cmp(dentryp->name, nm)) |
return EEXIST; |
} |
/* Allocate and initialize the dentry. */ |
dentryp = malloc(sizeof(tmpfs_dentry_t)); |
if (!dentryp) |
tmpfs_name_t *namep = malloc(sizeof(tmpfs_name_t)); |
if (!namep) |
return ENOMEM; |
tmpfs_dentry_initialize(dentryp); |
/* Populate and link the new dentry. */ |
tmpfs_name_initialize(namep); |
size_t size = str_size(nm); |
dentryp->name = malloc(size + 1); |
if (!dentryp->name) { |
free(dentryp); |
namep->name = malloc(size + 1); |
if (!namep->name) { |
free(namep); |
return ENOMEM; |
} |
str_cpy(dentryp->name, size + 1, nm); |
dentryp->node = childp; |
str_cpy(namep->name, size + 1, nm); |
namep->parent = parentp; |
childp->lnkcnt++; |
list_append(&dentryp->link, &parentp->cs_head); |
unsigned long key = (unsigned long) parentp; |
hash_table_insert(&childp->names, &key, &namep->link); |
/* Insert the new node into the namespace. */ |
if (parentp->child) { |
tmpfs_dentry_t *tmp = parentp->child; |
while (tmp->sibling) |
tmp = tmp->sibling; |
tmp->sibling = childp; |
} else { |
parentp->child = childp; |
} |
return EOK; |
} |
int tmpfs_unlink_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm) |
int tmpfs_unlink_node(void *prnt, void *chld) |
{ |
tmpfs_node_t *parentp = TMPFS_NODE(pfn); |
tmpfs_node_t *childp = NULL; |
tmpfs_dentry_t *dentryp; |
link_t *lnk; |
tmpfs_dentry_t *parentp = (tmpfs_dentry_t *)prnt; |
tmpfs_dentry_t *childp = (tmpfs_dentry_t *)chld; |
if (!parentp) |
return EBUSY; |
for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head; |
lnk = lnk->next) { |
dentryp = list_get_instance(lnk, tmpfs_dentry_t, link); |
if (!str_cmp(dentryp->name, nm)) { |
childp = dentryp->node; |
assert(FS_NODE(childp) == cfn); |
break; |
} |
} |
if (!childp) |
return ENOENT; |
if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_head)) |
if (childp->child) |
return ENOTEMPTY; |
list_remove(&dentryp->link); |
free(dentryp); |
if (parentp->child == childp) { |
parentp->child = childp->sibling; |
} else { |
/* TODO: consider doubly linked list for organizing siblings. */ |
tmpfs_dentry_t *tmp = parentp->child; |
while (tmp->sibling != childp) |
tmp = tmp->sibling; |
tmp->sibling = childp->sibling; |
} |
childp->sibling = NULL; |
unsigned long key = (unsigned long) parentp; |
hash_table_remove(&childp->names, &key, 1); |
childp->lnkcnt--; |
return EOK; |
} |
int tmpfs_destroy_node(fs_node_t *fn) |
int tmpfs_destroy_node(void *nodep) |
{ |
tmpfs_node_t *nodep = TMPFS_NODE(fn); |
tmpfs_dentry_t *dentry = (tmpfs_dentry_t *) nodep; |
assert(!nodep->lnkcnt); |
assert(list_empty(&nodep->cs_head)); |
assert(!dentry->lnkcnt); |
assert(!dentry->child); |
assert(!dentry->sibling); |
unsigned long key[] = { |
[NODES_KEY_INDEX] = nodep->index, |
[NODES_KEY_DEV] = nodep->dev_handle |
}; |
hash_table_remove(&nodes, key, 2); |
unsigned long key = dentry->index; |
hash_table_remove(&dentries, &key, 1); |
if (nodep->type == TMPFS_FILE) |
free(nodep->data); |
free(nodep->bp); |
free(nodep); |
hash_table_destroy(&dentry->names); |
if (dentry->type == TMPFS_FILE) |
free(dentry->data); |
free(dentry); |
return EOK; |
} |
366,44 → 399,20 |
{ |
dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); |
/* accept the mount options */ |
ipc_callid_t callid; |
size_t size; |
if (!ipc_data_write_receive(&callid, &size)) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
} |
char *opts = malloc(size + 1); |
if (!opts) { |
ipc_answer_0(callid, ENOMEM); |
/* Initialize TMPFS. */ |
if (!root && !tmpfs_init()) { |
ipc_answer_0(rid, ENOMEM); |
return; |
} |
ipcarg_t retval = ipc_data_write_finalize(callid, opts, size); |
if (retval != EOK) { |
ipc_answer_0(rid, retval); |
free(opts); |
return; |
} |
opts[size] = '\0'; |
/* Initialize TMPFS instance. */ |
if (!tmpfs_instance_init(dev_handle)) { |
ipc_answer_0(rid, ENOMEM); |
return; |
} |
tmpfs_node_t *rootp = TMPFS_NODE(tmpfs_root_get(dev_handle)); |
if (str_cmp(opts, "restore") == 0) { |
if (dev_handle >= 0) { |
if (tmpfs_restore(dev_handle)) |
ipc_answer_3(rid, EOK, rootp->index, rootp->size, |
rootp->lnkcnt); |
ipc_answer_3(rid, EOK, root->index, root->size, |
root->lnkcnt); |
else |
ipc_answer_0(rid, ELIMIT); |
} else { |
ipc_answer_3(rid, EOK, rootp->index, rootp->size, |
rootp->lnkcnt); |
ipc_answer_3(rid, EOK, root->index, root->size, root->lnkcnt); |
} |
} |
429,20 → 438,17 |
off_t pos = (off_t)IPC_GET_ARG3(*request); |
/* |
* Lookup the respective TMPFS node. |
* Lookup the respective dentry. |
*/ |
link_t *hlp; |
unsigned long key[] = { |
[NODES_KEY_INDEX] = index, |
[NODES_KEY_DEV] = dev_handle, |
}; |
hlp = hash_table_find(&nodes, key); |
unsigned long key = index; |
hlp = hash_table_find(&dentries, &key); |
if (!hlp) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, |
nh_link); |
tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t, |
dh_link); |
/* |
* Receive the read request. |
456,16 → 462,15 |
} |
size_t bytes; |
if (nodep->type == TMPFS_FILE) { |
bytes = max(0, min(nodep->size - pos, size)); |
(void) ipc_data_read_finalize(callid, nodep->data + pos, |
if (dentry->type == TMPFS_FILE) { |
bytes = max(0, min(dentry->size - pos, size)); |
(void) ipc_data_read_finalize(callid, dentry->data + pos, |
bytes); |
} else { |
tmpfs_dentry_t *dentryp; |
link_t *lnk; |
int i; |
tmpfs_dentry_t *cur; |
assert(nodep->type == TMPFS_DIRECTORY); |
assert(dentry->type == TMPFS_DIRECTORY); |
/* |
* Yes, we really use O(n) algorithm here. |
472,21 → 477,24 |
* If it bothers someone, it could be fixed by introducing a |
* hash table. |
*/ |
for (i = 0, lnk = nodep->cs_head.next; |
i < pos && lnk != &nodep->cs_head; |
i++, lnk = lnk->next) |
for (i = 0, cur = dentry->child; i < pos && cur; i++, |
cur = cur->sibling) |
; |
if (lnk == &nodep->cs_head) { |
if (!cur) { |
ipc_answer_0(callid, ENOENT); |
ipc_answer_1(rid, ENOENT, 0); |
return; |
} |
dentryp = list_get_instance(lnk, tmpfs_dentry_t, link); |
unsigned long key = (unsigned long) dentry; |
link_t *hlp = hash_table_find(&cur->names, &key); |
assert(hlp); |
tmpfs_name_t *namep = hash_table_get_instance(hlp, tmpfs_name_t, |
link); |
(void) ipc_data_read_finalize(callid, dentryp->name, |
str_size(dentryp->name) + 1); |
(void) ipc_data_read_finalize(callid, namep->name, |
str_size(namep->name) + 1); |
bytes = 1; |
} |
503,20 → 511,17 |
off_t pos = (off_t)IPC_GET_ARG3(*request); |
/* |
* Lookup the respective TMPFS node. |
* Lookup the respective dentry. |
*/ |
link_t *hlp; |
unsigned long key[] = { |
[NODES_KEY_INDEX] = index, |
[NODES_KEY_DEV] = dev_handle |
}; |
hlp = hash_table_find(&nodes, key); |
unsigned long key = index; |
hlp = hash_table_find(&dentries, &key); |
if (!hlp) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, |
nh_link); |
tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t, |
dh_link); |
/* |
* Receive the write request. |
532,13 → 537,13 |
/* |
* Check whether the file needs to grow. |
*/ |
if (pos + size <= nodep->size) { |
if (pos + size <= dentry->size) { |
/* The file size is not changing. */ |
(void) ipc_data_write_finalize(callid, nodep->data + pos, size); |
ipc_answer_2(rid, EOK, size, nodep->size); |
(void) ipc_data_write_finalize(callid, dentry->data + pos, size); |
ipc_answer_2(rid, EOK, size, dentry->size); |
return; |
} |
size_t delta = (pos + size) - nodep->size; |
size_t delta = (pos + size) - dentry->size; |
/* |
* At this point, we are deliberately extremely straightforward and |
* simply realloc the contents of the file on every write that grows the |
546,18 → 551,18 |
* our heap allocator can save us and just grow the block whenever |
* possible. |
*/ |
void *newdata = realloc(nodep->data, nodep->size + delta); |
void *newdata = realloc(dentry->data, dentry->size + delta); |
if (!newdata) { |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_2(rid, EOK, 0, nodep->size); |
ipc_answer_2(rid, EOK, 0, dentry->size); |
return; |
} |
/* Clear any newly allocated memory in order to emulate gaps. */ |
memset(newdata + nodep->size, 0, delta); |
nodep->size += delta; |
nodep->data = newdata; |
(void) ipc_data_write_finalize(callid, nodep->data + pos, size); |
ipc_answer_2(rid, EOK, size, nodep->size); |
memset(newdata + dentry->size, 0, delta); |
dentry->size += delta; |
dentry->data = newdata; |
(void) ipc_data_write_finalize(callid, dentry->data + pos, size); |
ipc_answer_2(rid, EOK, size, dentry->size); |
} |
void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request) |
567,37 → 572,34 |
size_t size = (off_t)IPC_GET_ARG3(*request); |
/* |
* Lookup the respective TMPFS node. |
* Lookup the respective dentry. |
*/ |
link_t *hlp; |
unsigned long key[] = { |
[NODES_KEY_INDEX] = index, |
[NODES_KEY_DEV] = dev_handle |
}; |
hlp = hash_table_find(&nodes, key); |
unsigned long key = index; |
hlp = hash_table_find(&dentries, &key); |
if (!hlp) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, |
nh_link); |
tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t, |
dh_link); |
if (size == nodep->size) { |
if (size == dentry->size) { |
ipc_answer_0(rid, EOK); |
return; |
} |
void *newdata = realloc(nodep->data, size); |
void *newdata = realloc(dentry->data, size); |
if (!newdata) { |
ipc_answer_0(rid, ENOMEM); |
return; |
} |
if (size > nodep->size) { |
size_t delta = size - nodep->size; |
memset(newdata + nodep->size, 0, delta); |
if (size > dentry->size) { |
size_t delta = size - dentry->size; |
memset(newdata + dentry->size, 0, delta); |
} |
nodep->size = size; |
nodep->data = newdata; |
dentry->size = size; |
dentry->data = newdata; |
ipc_answer_0(rid, EOK); |
} |
608,18 → 610,15 |
int rc; |
link_t *hlp; |
unsigned long key[] = { |
[NODES_KEY_INDEX] = index, |
[NODES_KEY_DEV] = dev_handle |
}; |
hlp = hash_table_find(&nodes, key); |
unsigned long key = index; |
hlp = hash_table_find(&dentries, &key); |
if (!hlp) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t, |
nh_link); |
rc = tmpfs_destroy_node(FS_NODE(nodep)); |
tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t, |
dh_link); |
rc = tmpfs_destroy_node(dentry); |
ipc_answer_0(rid, rc); |
} |
/branches/dd/uspace/srv/fs/tmpfs/Makefile |
---|
72,7 → 72,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/fs/fat/fat.h |
---|
178,9 → 178,6 |
/** FAT in-core node. */ |
typedef struct fat_node { |
/** Back pointer to the FS node. */ |
fs_node_t *bp; |
futex_t lock; |
fat_node_type_t type; |
fat_idx_t *idx; |
/branches/dd/uspace/srv/fs/fat/fat_dentry.c |
---|
114,51 → 114,37 |
void fat_dentry_name_get(const fat_dentry_t *d, char *buf) |
{ |
unsigned int i; |
int i; |
for (i = 0; i < FAT_NAME_LEN; i++) { |
if (d->name[i] == FAT_PAD) |
break; |
if (d->name[i] == FAT_DENTRY_E5_ESC) |
*buf++ = 0xe5; |
else { |
if (d->lcase & FAT_LCASE_LOWER_NAME) |
*buf++ = tolower(d->name[i]); |
else |
*buf++ = d->name[i]; |
} |
else |
*buf++ = d->name[i]; |
} |
if (d->ext[0] != FAT_PAD) |
*buf++ = '.'; |
for (i = 0; i < FAT_EXT_LEN; i++) { |
if (d->ext[i] == FAT_PAD) { |
*buf = '\0'; |
return; |
} |
if (d->ext[i] == FAT_DENTRY_E5_ESC) |
*buf++ = 0xe5; |
else { |
if (d->lcase & FAT_LCASE_LOWER_EXT) |
*buf++ = tolower(d->ext[i]); |
else |
*buf++ = d->ext[i]; |
} |
else |
*buf++ = d->ext[i]; |
} |
*buf = '\0'; |
} |
void fat_dentry_name_set(fat_dentry_t *d, const char *name) |
{ |
unsigned int i; |
int i; |
const char fake_ext[] = " "; |
bool lower_name = true; |
bool lower_ext = true; |
for (i = 0; i < FAT_NAME_LEN; i++) { |
switch ((uint8_t) *name) { |
case 0xe5: |
170,19 → 156,12 |
d->name[i] = FAT_PAD; |
break; |
default: |
if (isalpha(*name)) { |
if (!islower(*name)) |
lower_name = false; |
} |
d->name[i] = toupper(*name++); |
break; |
} |
} |
if (*name++ != '.') |
name = fake_ext; |
for (i = 0; i < FAT_EXT_LEN; i++) { |
switch ((uint8_t) *name) { |
case 0xe5: |
193,25 → 172,10 |
d->ext[i] = FAT_PAD; |
break; |
default: |
if (isalpha(*name)) { |
if (!islower(*name)) |
lower_ext = false; |
} |
d->ext[i] = toupper(*name++); |
break; |
} |
} |
if (lower_name) |
d->lcase |= FAT_LCASE_LOWER_NAME; |
else |
d->lcase &= ~FAT_LCASE_LOWER_NAME; |
if (lower_ext) |
d->lcase |= FAT_LCASE_LOWER_EXT; |
else |
d->lcase &= ~FAT_LCASE_LOWER_EXT; |
} |
fat_dentry_clsf_t fat_classify_dentry(const fat_dentry_t *d) |
/branches/dd/uspace/srv/fs/fat/fat_dentry.h |
---|
47,9 → 47,6 |
#define FAT_ATTR_VOLLABEL (1 << 3) |
#define FAT_ATTR_SUBDIR (1 << 4) |
#define FAT_LCASE_LOWER_NAME 0x08 |
#define FAT_LCASE_LOWER_EXT 0x10 |
#define FAT_PAD ' ' |
#define FAT_DENTRY_UNUSED 0x00 |
68,7 → 65,7 |
uint8_t name[8]; |
uint8_t ext[3]; |
uint8_t attr; |
uint8_t lcase; |
uint8_t reserved; |
uint8_t ctime_fine; |
uint16_t ctime; |
uint16_t cdate; |
/branches/dd/uspace/srv/fs/fat/fat_ops.c |
---|
55,9 → 55,6 |
#include <sys/mman.h> |
#include <align.h> |
#define FAT_NODE(node) ((node) ? (fat_node_t *) (node)->data : NULL) |
#define FS_NODE(node) ((node) ? (node)->bp : NULL) |
/** Futex protecting the list of cached free FAT nodes. */ |
static futex_t ffn_futex = FUTEX_INITIALIZER; |
67,7 → 64,6 |
static void fat_node_initialize(fat_node_t *node) |
{ |
futex_initialize(&node->lock, 1); |
node->bp = NULL; |
node->idx = NULL; |
node->type = 0; |
link_initialize(&node->ffn_link); |
112,7 → 108,6 |
static fat_node_t *fat_node_get_new(void) |
{ |
fs_node_t *fn; |
fat_node_t *nodep; |
futex_down(&ffn_futex); |
134,24 → 129,15 |
idxp_tmp->nodep = NULL; |
futex_up(&nodep->lock); |
futex_up(&idxp_tmp->lock); |
fn = FS_NODE(nodep); |
} else { |
skip_cache: |
/* Try to allocate a new node structure. */ |
futex_up(&ffn_futex); |
fn = (fs_node_t *)malloc(sizeof(fs_node_t)); |
if (!fn) |
return NULL; |
nodep = (fat_node_t *)malloc(sizeof(fat_node_t)); |
if (!nodep) { |
free(fn); |
if (!nodep) |
return NULL; |
} |
} |
fat_node_initialize(nodep); |
fs_node_initialize(fn); |
fn->data = nodep; |
nodep->bp = fn; |
return nodep; |
} |
160,7 → 146,7 |
* |
* @param idxp Locked index structure. |
*/ |
static fat_node_t *fat_node_get_core(fat_idx_t *idxp) |
static void *fat_node_get_core(fat_idx_t *idxp) |
{ |
block_t *b; |
fat_bs_t *bs; |
237,21 → 223,21 |
/* |
* Forward declarations of FAT libfs operations. |
*/ |
static fs_node_t *fat_node_get(dev_handle_t, fs_index_t); |
static void fat_node_put(fs_node_t *); |
static fs_node_t *fat_create_node(dev_handle_t, int); |
static int fat_destroy_node(fs_node_t *); |
static int fat_link(fs_node_t *, fs_node_t *, const char *); |
static int fat_unlink(fs_node_t *, fs_node_t *, const char *); |
static fs_node_t *fat_match(fs_node_t *, const char *); |
static fs_index_t fat_index_get(fs_node_t *); |
static size_t fat_size_get(fs_node_t *); |
static unsigned fat_lnkcnt_get(fs_node_t *); |
static bool fat_has_children(fs_node_t *); |
static fs_node_t *fat_root_get(dev_handle_t); |
static void *fat_node_get(dev_handle_t, fs_index_t); |
static void fat_node_put(void *); |
static void *fat_create_node(dev_handle_t, int); |
static int fat_destroy_node(void *); |
static int fat_link(void *, void *, const char *); |
static int fat_unlink(void *, void *); |
static void *fat_match(void *, const char *); |
static fs_index_t fat_index_get(void *); |
static size_t fat_size_get(void *); |
static unsigned fat_lnkcnt_get(void *); |
static bool fat_has_children(void *); |
static void *fat_root_get(dev_handle_t); |
static char fat_plb_get_char(unsigned); |
static bool fat_is_directory(fs_node_t *); |
static bool fat_is_file(fs_node_t *node); |
static bool fat_is_directory(void *); |
static bool fat_is_file(void *node); |
/* |
* FAT libfs operations. |
258,9 → 244,9 |
*/ |
/** Instantiate a FAT in-core node. */ |
fs_node_t *fat_node_get(dev_handle_t dev_handle, fs_index_t index) |
void *fat_node_get(dev_handle_t dev_handle, fs_index_t index) |
{ |
fat_node_t *nodep; |
void *node; |
fat_idx_t *idxp; |
idxp = fat_idx_get_by_index(dev_handle, index); |
267,14 → 253,14 |
if (!idxp) |
return NULL; |
/* idxp->lock held */ |
nodep = fat_node_get_core(idxp); |
node = fat_node_get_core(idxp); |
futex_up(&idxp->lock); |
return FS_NODE(nodep); |
return node; |
} |
void fat_node_put(fs_node_t *fn) |
void fat_node_put(void *node) |
{ |
fat_node_t *nodep = FAT_NODE(fn); |
fat_node_t *nodep = (fat_node_t *)node; |
bool destroy = false; |
futex_down(&nodep->lock); |
294,13 → 280,11 |
} |
} |
futex_up(&nodep->lock); |
if (destroy) { |
free(nodep->bp); |
free(nodep); |
} |
if (destroy) |
free(node); |
} |
fs_node_t *fat_create_node(dev_handle_t dev_handle, int flags) |
void *fat_create_node(dev_handle_t dev_handle, int flags) |
{ |
fat_idx_t *idxp; |
fat_node_t *nodep; |
326,7 → 310,7 |
idxp = fat_idx_get_new(dev_handle); |
if (!idxp) { |
fat_free_clusters(bs, dev_handle, mcl); |
fat_node_put(FS_NODE(nodep)); |
fat_node_put(nodep); |
return NULL; |
} |
/* idxp->lock held */ |
361,12 → 345,12 |
idxp->nodep = nodep; |
futex_up(&idxp->lock); |
return FS_NODE(nodep); |
return nodep; |
} |
int fat_destroy_node(fs_node_t *fn) |
int fat_destroy_node(void *node) |
{ |
fat_node_t *nodep = FAT_NODE(fn); |
fat_node_t *nodep = (fat_node_t *)node; |
fat_bs_t *bs; |
/* |
380,7 → 364,7 |
/* |
* The node may not have any children. |
*/ |
assert(fat_has_children(fn) == false); |
assert(fat_has_children(node) == false); |
bs = block_bb_get(nodep->idx->dev_handle); |
if (nodep->firstc != FAT_CLST_RES0) { |
390,15 → 374,14 |
} |
fat_idx_destroy(nodep->idx); |
free(nodep->bp); |
free(nodep); |
return EOK; |
} |
int fat_link(fs_node_t *pfn, fs_node_t *cfn, const char *name) |
int fat_link(void *prnt, void *chld, const char *name) |
{ |
fat_node_t *parentp = FAT_NODE(pfn); |
fat_node_t *childp = FAT_NODE(cfn); |
fat_node_t *parentp = (fat_node_t *)prnt; |
fat_node_t *childp = (fat_node_t *)chld; |
fat_dentry_t *d; |
fat_bs_t *bs; |
block_t *b; |
544,21 → 527,15 |
return EOK; |
} |
int fat_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *nm) |
int fat_unlink(void *prnt, void *chld) |
{ |
fat_node_t *parentp = FAT_NODE(pfn); |
fat_node_t *childp = FAT_NODE(cfn); |
fat_node_t *parentp = (fat_node_t *)prnt; |
fat_node_t *childp = (fat_node_t *)chld; |
fat_bs_t *bs; |
fat_dentry_t *d; |
uint16_t bps; |
block_t *b; |
if (!parentp) |
return EBUSY; |
if (fat_has_children(cfn)) |
return ENOTEMPTY; |
futex_down(&parentp->lock); |
futex_down(&childp->lock); |
assert(childp->lnkcnt == 1); |
590,10 → 567,10 |
return EOK; |
} |
fs_node_t *fat_match(fs_node_t *pfn, const char *component) |
void *fat_match(void *prnt, const char *component) |
{ |
fat_bs_t *bs; |
fat_node_t *parentp = FAT_NODE(pfn); |
fat_node_t *parentp = (fat_node_t *)prnt; |
char name[FAT_NAME_LEN + 1 + FAT_EXT_LEN + 1]; |
unsigned i, j; |
unsigned bps; /* bytes per sector */ |
626,7 → 603,7 |
} |
if (fat_dentry_namecmp(name, component) == 0) { |
/* hit */ |
fat_node_t *nodep; |
void *node; |
/* |
* Assume tree hierarchy for locking. We |
* already have the parent and now we are going |
645,10 → 622,10 |
block_put(b); |
return NULL; |
} |
nodep = fat_node_get_core(idx); |
node = fat_node_get_core(idx); |
futex_up(&idx->lock); |
block_put(b); |
return FS_NODE(nodep); |
return node; |
} |
} |
block_put(b); |
658,25 → 635,28 |
return NULL; |
} |
fs_index_t fat_index_get(fs_node_t *fn) |
fs_index_t fat_index_get(void *node) |
{ |
return FAT_NODE(fn)->idx->index; |
fat_node_t *fnodep = (fat_node_t *)node; |
if (!fnodep) |
return 0; |
return fnodep->idx->index; |
} |
size_t fat_size_get(fs_node_t *fn) |
size_t fat_size_get(void *node) |
{ |
return FAT_NODE(fn)->size; |
return ((fat_node_t *)node)->size; |
} |
unsigned fat_lnkcnt_get(fs_node_t *fn) |
unsigned fat_lnkcnt_get(void *node) |
{ |
return FAT_NODE(fn)->lnkcnt; |
return ((fat_node_t *)node)->lnkcnt; |
} |
bool fat_has_children(fs_node_t *fn) |
bool fat_has_children(void *node) |
{ |
fat_bs_t *bs; |
fat_node_t *nodep = FAT_NODE(fn); |
fat_node_t *nodep = (fat_node_t *)node; |
unsigned bps; |
unsigned dps; |
unsigned blocks; |
724,7 → 704,7 |
return false; |
} |
fs_node_t *fat_root_get(dev_handle_t dev_handle) |
void *fat_root_get(dev_handle_t dev_handle) |
{ |
return fat_node_get(dev_handle, 0); |
} |
734,14 → 714,14 |
return fat_reg.plb_ro[pos % PLB_SIZE]; |
} |
bool fat_is_directory(fs_node_t *fn) |
bool fat_is_directory(void *node) |
{ |
return FAT_NODE(fn)->type == FAT_DIRECTORY; |
return ((fat_node_t *)node)->type == FAT_DIRECTORY; |
} |
bool fat_is_file(fs_node_t *fn) |
bool fat_is_file(void *node) |
{ |
return FAT_NODE(fn)->type == FAT_FILE; |
return ((fat_node_t *)node)->type == FAT_FILE; |
} |
/** libfs operations */ |
775,28 → 755,6 |
uint16_t rde; |
int rc; |
/* accept the mount options */ |
ipc_callid_t callid; |
size_t size; |
if (!ipc_data_write_receive(&callid, &size)) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
} |
char *opts = malloc(size + 1); |
if (!opts) { |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_0(rid, ENOMEM); |
return; |
} |
ipcarg_t retval = ipc_data_write_finalize(callid, opts, size); |
if (retval != EOK) { |
ipc_answer_0(rid, retval); |
free(opts); |
return; |
} |
opts[size] = '\0'; |
/* initialize libblock */ |
rc = block_init(dev_handle, BS_SIZE); |
if (rc != EOK) { |
841,17 → 799,8 |
} |
/* Initialize the root node. */ |
fs_node_t *rfn = (fs_node_t *)malloc(sizeof(fs_node_t)); |
if (!rfn) { |
block_fini(dev_handle); |
fat_idx_fini_by_dev_handle(dev_handle); |
ipc_answer_0(rid, ENOMEM); |
return; |
} |
fs_node_initialize(rfn); |
fat_node_t *rootp = (fat_node_t *)malloc(sizeof(fat_node_t)); |
if (!rootp) { |
free(rfn); |
block_fini(dev_handle); |
fat_idx_fini_by_dev_handle(dev_handle); |
ipc_answer_0(rid, ENOMEM); |
861,9 → 810,8 |
fat_idx_t *ridxp = fat_idx_get_by_pos(dev_handle, FAT_CLST_ROOTPAR, 0); |
if (!ridxp) { |
free(rfn); |
block_fini(dev_handle); |
free(rootp); |
block_fini(dev_handle); |
fat_idx_fini_by_dev_handle(dev_handle); |
ipc_answer_0(rid, ENOMEM); |
return; |
878,8 → 826,6 |
rootp->size = rde * sizeof(fat_dentry_t); |
rootp->idx = ridxp; |
ridxp->nodep = rootp; |
rootp->bp = rfn; |
rfn->data = rootp; |
futex_up(&ridxp->lock); |
888,7 → 834,7 |
void fat_mount(ipc_callid_t rid, ipc_call_t *request) |
{ |
libfs_mount(&fat_libfs_ops, rid, request); |
ipc_answer_0(rid, ENOTSUP); |
} |
void fat_lookup(ipc_callid_t rid, ipc_call_t *request) |
901,23 → 847,21 |
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); |
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); |
off_t pos = (off_t)IPC_GET_ARG3(*request); |
fs_node_t *fn = fat_node_get(dev_handle, index); |
fat_node_t *nodep; |
fat_node_t *nodep = (fat_node_t *)fat_node_get(dev_handle, index); |
fat_bs_t *bs; |
uint16_t bps; |
size_t bytes; |
block_t *b; |
if (!fn) { |
if (!nodep) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
nodep = FAT_NODE(fn); |
ipc_callid_t callid; |
size_t len; |
if (!ipc_data_read_receive(&callid, &len)) { |
fat_node_put(fn); |
fat_node_put(nodep); |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
988,7 → 932,7 |
bnum++; |
} |
miss: |
fat_node_put(fn); |
fat_node_put(nodep); |
ipc_answer_0(callid, ENOENT); |
ipc_answer_1(rid, ENOENT, 0); |
return; |
997,7 → 941,7 |
bytes = (pos - spos) + 1; |
} |
fat_node_put(fn); |
fat_node_put(nodep); |
ipc_answer_1(rid, EOK, (ipcarg_t)bytes); |
} |
1006,8 → 950,7 |
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); |
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); |
off_t pos = (off_t)IPC_GET_ARG3(*request); |
fs_node_t *fn = fat_node_get(dev_handle, index); |
fat_node_t *nodep; |
fat_node_t *nodep = (fat_node_t *)fat_node_get(dev_handle, index); |
fat_bs_t *bs; |
size_t bytes; |
block_t *b; |
1017,16 → 960,15 |
off_t boundary; |
int flags = BLOCK_FLAGS_NONE; |
if (!fn) { |
if (!nodep) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
nodep = FAT_NODE(fn); |
ipc_callid_t callid; |
size_t len; |
if (!ipc_data_write_receive(&callid, &len)) { |
fat_node_put(fn); |
fat_node_put(nodep); |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
1067,7 → 1009,7 |
nodep->dirty = true; /* need to sync node */ |
} |
ipc_answer_2(rid, EOK, bytes, nodep->size); |
fat_node_put(fn); |
fat_node_put(nodep); |
return; |
} else { |
/* |
1083,7 → 1025,7 |
status = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl); |
if (status != EOK) { |
/* could not allocate a chain of nclsts clusters */ |
fat_node_put(fn); |
fat_node_put(nodep); |
ipc_answer_0(callid, status); |
ipc_answer_0(rid, status); |
return; |
1104,7 → 1046,7 |
nodep->size = pos + bytes; |
nodep->dirty = true; /* need to sync node */ |
ipc_answer_2(rid, EOK, bytes, nodep->size); |
fat_node_put(fn); |
fat_node_put(nodep); |
return; |
} |
} |
1114,8 → 1056,7 |
dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); |
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); |
size_t size = (off_t)IPC_GET_ARG3(*request); |
fs_node_t *fn = fat_node_get(dev_handle, index); |
fat_node_t *nodep; |
fat_node_t *nodep = (fat_node_t *)fat_node_get(dev_handle, index); |
fat_bs_t *bs; |
uint16_t bps; |
uint8_t spc; |
1122,11 → 1063,10 |
unsigned bpc; /* bytes per cluster */ |
int rc; |
if (!fn) { |
if (!nodep) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
nodep = FAT_NODE(fn); |
bs = block_bb_get(dev_handle); |
bps = uint16_t_le2host(bs->bps); |
1164,7 → 1104,7 |
nodep->dirty = true; /* need to sync node */ |
rc = EOK; |
} |
fat_node_put(fn); |
fat_node_put(nodep); |
ipc_answer_0(rid, rc); |
return; |
} |
1175,13 → 1115,13 |
fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request); |
int rc; |
fs_node_t *fn = fat_node_get(dev_handle, index); |
if (!fn) { |
fat_node_t *nodep = fat_node_get(dev_handle, index); |
if (!nodep) { |
ipc_answer_0(rid, ENOENT); |
return; |
} |
rc = fat_destroy_node(fn); |
rc = fat_destroy_node(nodep); |
ipc_answer_0(rid, rc); |
} |
/branches/dd/uspace/srv/fs/fat/Makefile |
---|
74,7 → 74,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/obio/Makefile |
---|
64,7 → 64,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/devmap/Makefile |
---|
34,8 → 34,10 |
include $(LIBC_PREFIX)/Makefile.toolchain |
LIBS = $(LIBC_PREFIX)/libc.a |
CFLAGS += -I../libipc/include |
LIBS = $(LIBC_PREFIX)/libc.a |
## Sources |
# |
65,7 → 67,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/devmap/devmap.c |
---|
48,41 → 48,6 |
#define NAME "devmap" |
/** Representation of device driver. |
* |
* Each driver is responsible for a set of devices. |
* |
*/ |
typedef struct { |
/** Pointers to previous and next drivers in linked list */ |
link_t drivers; |
/** Pointer to the linked list of devices controlled by this driver */ |
link_t devices; |
/** Phone asociated with this driver */ |
ipcarg_t phone; |
/** Device driver name */ |
char *name; |
/** Futex for list of devices owned by this driver */ |
atomic_t devices_futex; |
} devmap_driver_t; |
/** Info about registered device |
* |
*/ |
typedef struct { |
/** Pointer to the previous and next device in the list of all devices */ |
link_t devices; |
/** Pointer to the previous and next device in the list of devices |
owned by one driver */ |
link_t driver_devices; |
/** Unique device identifier */ |
dev_handle_t handle; |
/** Device name */ |
char *name; |
/** Device driver handling this device */ |
devmap_driver_t *driver; |
} devmap_device_t; |
/** Pending lookup structure. */ |
typedef struct { |
link_t link; |
105,10 → 70,11 |
static atomic_t drivers_list_futex = FUTEX_INITIALIZER; |
static atomic_t create_handle_futex = FUTEX_INITIALIZER; |
static dev_handle_t last_handle = 0; |
static dev_handle_t devmap_create_handle(void) |
static int devmap_create_handle(void) |
{ |
static int last_handle = 0; |
int handle; |
/* TODO: allow reusing old handles after their unregistration |
* and implement some version of LRU algorithm |
*/ |
115,12 → 81,27 |
/* FIXME: overflow */ |
futex_down(&create_handle_futex); |
last_handle++; |
last_handle += 1; |
handle = last_handle; |
futex_up(&create_handle_futex); |
return last_handle; |
return handle; |
} |
/** Initialize device mapper. |
* |
* |
*/ |
static int devmap_init() |
{ |
/* TODO: */ |
return EOK; |
} |
/** Find device with given name. |
* |
*/ |
148,7 → 129,7 |
* @todo: use hash table |
* |
*/ |
static devmap_device_t *devmap_device_find_handle(dev_handle_t handle) |
static devmap_device_t *devmap_device_find_handle(int handle) |
{ |
futex_down(&devices_list_futex); |
316,13 → 297,13 |
futex_down(&drivers_list_futex); |
if (driver->phone != 0) |
ipc_hangup(driver->phone); |
ipc_hangup(driver->phone); |
/* Remove it from list of drivers */ |
/* remove it from list of drivers */ |
list_remove(&(driver->drivers)); |
/* Unregister all its devices */ |
/* unregister all its devices */ |
futex_down(&devices_list_futex); |
futex_down(&(driver->devices_futex)); |
337,7 → 318,7 |
futex_up(&drivers_list_futex); |
/* free name and driver */ |
if (driver->name != NULL) |
if (NULL != driver->name) |
free(driver->name); |
free(driver); |
473,15 → 454,15 |
/* |
* Get handle from request |
*/ |
dev_handle_t handle = IPC_GET_ARG2(*call); |
int handle = IPC_GET_ARG2(*call); |
devmap_device_t *dev = devmap_device_find_handle(handle); |
if ((dev == NULL) || (dev->driver == NULL) || (dev->driver->phone == 0)) { |
if (NULL == dev) { |
ipc_answer_0(callid, ENOENT); |
return; |
} |
ipc_forward_fast(callid, dev->driver->phone, dev->handle, |
ipc_forward_fast(callid, dev->driver->phone, (ipcarg_t)(dev->handle), |
IPC_GET_ARG3(*call), 0, IPC_FF_NONE); |
} |
514,7 → 495,7 |
/* |
* Allocate buffer for device name. |
*/ |
char *name = (char *) malloc(size + 1); |
char *name = (char *) malloc(size); |
if (name == NULL) { |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_0(iid, EREFUSED); |
568,7 → 549,7 |
/** Find name of device identified by id and send it to caller. |
* |
*/ |
static void devmap_get_name(ipc_callid_t iid, ipc_call_t *icall) |
static void devmap_get_name(ipc_callid_t iid, ipc_call_t *icall) |
{ |
const devmap_device_t *device = devmap_device_find_handle(IPC_GET_ARG1(*icall)); |
598,99 → 579,6 |
/* TODO: send name in response */ |
} |
static void devmap_get_count(ipc_callid_t iid, ipc_call_t *icall) |
{ |
futex_down(&devices_list_futex); |
ipc_answer_1(iid, EOK, list_count(&devices_list)); |
futex_up(&devices_list_futex); |
} |
static void devmap_get_devices(ipc_callid_t iid, ipc_call_t *icall) |
{ |
futex_down(&devices_list_futex); |
ipc_callid_t callid; |
size_t size; |
if (!ipc_data_read_receive(&callid, &size)) { |
ipc_answer_0(callid, EREFUSED); |
ipc_answer_0(iid, EREFUSED); |
return; |
} |
if ((size % sizeof(dev_desc_t)) != 0) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(iid, EREFUSED); |
return; |
} |
count_t count = size / sizeof(dev_desc_t); |
dev_desc_t *desc = (dev_desc_t *) malloc(size); |
if (desc == NULL) { |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_0(iid, EREFUSED); |
return; |
} |
count_t pos = 0; |
link_t *item = devices_list.next; |
while ((item != &devices_list) && (pos < count)) { |
devmap_device_t *device = list_get_instance(item, devmap_device_t, devices); |
desc[pos].handle = device->handle; |
str_cpy(desc[pos].name, DEVMAP_NAME_MAXLEN, device->name); |
pos++; |
item = item->next; |
} |
ipcarg_t retval = ipc_data_read_finalize(callid, desc, pos * sizeof(dev_desc_t)); |
if (retval != EOK) { |
ipc_answer_0(iid, EREFUSED); |
free(desc); |
return; |
} |
free(desc); |
futex_up(&devices_list_futex); |
ipc_answer_1(iid, EOK, pos); |
} |
/** Initialize device mapper. |
* |
* |
*/ |
static bool devmap_init() |
{ |
/* Create NULL device entry */ |
devmap_device_t *device = (devmap_device_t *) malloc(sizeof(devmap_device_t)); |
if (device == NULL) |
return false; |
device->name = str_dup("null"); |
if (device->name == NULL) { |
free(device); |
return false; |
} |
list_initialize(&(device->devices)); |
list_initialize(&(device->driver_devices)); |
futex_down(&devices_list_futex); |
/* Get unique device handle */ |
device->handle = devmap_create_handle(); |
device->driver = NULL; |
/* Insert device into list of all devices */ |
list_append(&device->devices, &devices_list); |
futex_up(&devices_list_futex); |
return true; |
} |
/** Handle connection with device driver. |
* |
*/ |
733,7 → 621,7 |
devmap_get_handle(callid, &call); |
break; |
case DEVMAP_DEVICE_GET_NAME: |
devmap_get_name(callid, &call); |
devmap_get_handle(callid, &call); |
break; |
default: |
if (!(callid & IPC_CALLID_NOTIFICATION)) |
772,14 → 660,9 |
devmap_get_handle(callid, &call); |
break; |
case DEVMAP_DEVICE_GET_NAME: |
/* TODO */ |
devmap_get_name(callid, &call); |
break; |
case DEVMAP_DEVICE_GET_COUNT: |
devmap_get_count(callid, &call); |
break; |
case DEVMAP_DEVICE_GET_DEVICES: |
devmap_get_devices(callid, &call); |
break; |
default: |
if (!(callid & IPC_CALLID_NOTIFICATION)) |
ipc_answer_0(callid, ENOENT); |
817,7 → 700,7 |
{ |
printf(NAME ": HelenOS Device Mapper\n"); |
if (!devmap_init()) { |
if (devmap_init() != 0) { |
printf(NAME ": Error while initializing service\n"); |
return -1; |
} |
/branches/dd/uspace/srv/vfs/vfs.c |
---|
52,7 → 52,7 |
static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
bool keep_on_going = true; |
/* |
* The connection was opened via the IPC_CONNECT_ME_TO call. |
* This call needs to be answered. |
80,6 → 80,21 |
case IPC_M_PHONE_HUNGUP: |
keep_on_going = false; |
break; |
case IPC_M_CONNECT_ME_TO: |
/* |
* Connect the client file system to another one. |
*/ |
/* FIXME: |
* Prevent ordinary clients from connecting to file |
* system servers directly. This should be solved by |
* applying some security mechanisms. |
*/ |
fs_handle = IPC_GET_ARG1(call); |
phone = vfs_grab_phone(fs_handle); |
(void) ipc_forward_fast(callid, phone, 0, 0, 0, |
IPC_FF_NONE); |
vfs_release_phone(phone); |
break; |
case VFS_REGISTER: |
vfs_register(callid, &call); |
/* |
/branches/dd/uspace/srv/vfs/vfs_ops.c |
---|
60,7 → 60,6 |
link_t link; |
char *fs_name; /**< File system name */ |
char *mp; /**< Mount point */ |
char *opts; /**< Mount options. */ |
ipc_callid_t callid; /**< Call ID waiting for the mount */ |
ipc_callid_t rid; /**< Request ID */ |
dev_handle_t dev_handle; /**< Device handle */ |
81,22 → 80,13 |
}; |
static void vfs_mount_internal(ipc_callid_t rid, dev_handle_t dev_handle, |
fs_handle_t fs_handle, char *mp, char *opts) |
fs_handle_t fs_handle, char *mp) |
{ |
/* Resolve the path to the mountpoint. */ |
vfs_lookup_res_t mp_res; |
vfs_lookup_res_t mr_res; |
vfs_node_t *mp_node = NULL; |
vfs_node_t *mr_node; |
fs_index_t rindex; |
size_t rsize; |
unsigned rlnkcnt; |
ipcarg_t rc; |
int rc; |
int phone; |
aid_t msg; |
ipc_call_t answer; |
/* Resolve the path to the mountpoint. */ |
futex_down(&rootfs_futex); |
if (rootfs.fs_handle) { |
/* We already have the root FS. */ |
135,6 → 125,12 |
} else { |
/* We still don't have the root file system mounted. */ |
if (str_cmp(mp, "/") == 0) { |
vfs_lookup_res_t mr_res; |
vfs_node_t *mr_node; |
ipcarg_t rindex; |
ipcarg_t rsize; |
ipcarg_t rlnkcnt; |
/* |
* For this simple, but important case, |
* we are almost done. |
142,19 → 138,8 |
/* Tell the mountee that it is being mounted. */ |
phone = vfs_grab_phone(fs_handle); |
msg = async_send_1(phone, VFS_MOUNTED, |
(ipcarg_t) dev_handle, &answer); |
/* send the mount options */ |
rc = ipc_data_write_start(phone, (void *)opts, |
str_size(opts)); |
if (rc != EOK) { |
async_wait_for(msg, NULL); |
vfs_release_phone(phone); |
futex_up(&rootfs_futex); |
ipc_answer_0(rid, rc); |
return; |
} |
async_wait_for(msg, &rc); |
rc = async_req_1_3(phone, VFS_MOUNTED, |
(ipcarg_t) dev_handle, &rindex, &rsize, &rlnkcnt); |
vfs_release_phone(phone); |
if (rc != EOK) { |
162,16 → 147,12 |
ipc_answer_0(rid, rc); |
return; |
} |
rindex = (fs_index_t) IPC_GET_ARG1(answer); |
rsize = (size_t) IPC_GET_ARG2(answer); |
rlnkcnt = (unsigned) IPC_GET_ARG3(answer); |
mr_res.triplet.fs_handle = fs_handle; |
mr_res.triplet.dev_handle = dev_handle; |
mr_res.triplet.index = rindex; |
mr_res.size = rsize; |
mr_res.lnkcnt = rlnkcnt; |
mr_res.triplet.index = (fs_index_t) rindex; |
mr_res.size = (size_t) rsize; |
mr_res.lnkcnt = (unsigned) rlnkcnt; |
mr_res.type = VFS_NODE_DIRECTORY; |
rootfs.fs_handle = fs_handle; |
201,41 → 182,12 |
* handles, and we know the mount point VFS node. |
*/ |
int mountee_phone = vfs_grab_phone(fs_handle); |
assert(mountee_phone >= 0); |
vfs_release_phone(mountee_phone); |
phone = vfs_grab_phone(mp_res.triplet.fs_handle); |
msg = async_send_4(phone, VFS_MOUNT, |
rc = async_req_4_0(phone, VFS_MOUNT, |
(ipcarg_t) mp_res.triplet.dev_handle, |
(ipcarg_t) mp_res.triplet.index, |
(ipcarg_t) fs_handle, |
(ipcarg_t) dev_handle, &answer); |
/* send connection */ |
rc = async_req_1_0(phone, IPC_M_CONNECTION_CLONE, mountee_phone); |
if (rc != EOK) { |
async_wait_for(msg, NULL); |
vfs_release_phone(phone); |
/* Mount failed, drop reference to mp_node. */ |
if (mp_node) |
vfs_node_put(mp_node); |
ipc_answer_0(rid, rc); |
return; |
} |
/* send the mount options */ |
rc = ipc_data_write_start(phone, (void *)opts, str_size(opts)); |
if (rc != EOK) { |
async_wait_for(msg, NULL); |
vfs_release_phone(phone); |
/* Mount failed, drop reference to mp_node. */ |
if (mp_node) |
vfs_node_put(mp_node); |
ipc_answer_0(rid, rc); |
return; |
} |
async_wait_for(msg, &rc); |
(ipcarg_t) dev_handle); |
vfs_release_phone(phone); |
if (rc != EOK) { |
244,21 → 196,6 |
vfs_node_put(mp_node); |
} |
rindex = (fs_index_t) IPC_GET_ARG1(answer); |
rsize = (size_t) IPC_GET_ARG2(answer); |
rlnkcnt = (unsigned) IPC_GET_ARG3(answer); |
mr_res.triplet.fs_handle = fs_handle; |
mr_res.triplet.dev_handle = dev_handle; |
mr_res.triplet.index = rindex; |
mr_res.size = rsize; |
mr_res.lnkcnt = rlnkcnt; |
mr_res.type = VFS_NODE_DIRECTORY; |
/* Add reference to the mounted root. */ |
mr_node = vfs_node_get(&mr_res); |
assert(mr_node); |
ipc_answer_0(rid, rc); |
} |
279,12 → 216,10 |
ipc_answer_0(pr->callid, EOK); |
/* Do the mount */ |
vfs_mount_internal(pr->rid, pr->dev_handle, fs_handle, pr->mp, |
pr->opts); |
vfs_mount_internal(pr->rid, pr->dev_handle, fs_handle, pr->mp); |
free(pr->fs_name); |
free(pr->mp); |
free(pr->opts); |
list_remove(cur); |
free(pr); |
goto loop; |
337,47 → 272,12 |
/* Deliver the mount point. */ |
ipcarg_t retval = ipc_data_write_finalize(callid, mp, size); |
if (retval != EOK) { |
ipc_answer_0(rid, retval); |
ipc_answer_0(rid, EREFUSED); |
free(mp); |
return; |
} |
mp[size] = '\0'; |
/* Now we expect to receive the mount options. */ |
if (!ipc_data_write_receive(&callid, &size)) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
free(mp); |
return; |
} |
/* Check the offered options size. */ |
if (size < 0 || size > MAX_MNTOPTS_LEN) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
free(mp); |
return; |
} |
/* Allocate buffer for the mount options. */ |
char *opts = (char *) malloc(size + 1); |
if (!opts) { |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_0(rid, ENOMEM); |
free(mp); |
return; |
} |
/* Deliver the mount options. */ |
retval = ipc_data_write_finalize(callid, opts, size); |
if (retval != EOK) { |
ipc_answer_0(rid, retval); |
free(mp); |
free(opts); |
return; |
} |
opts[size] = '\0'; |
/* |
* Now, we expect the client to send us data with the name of the file |
* system. |
386,7 → 286,6 |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
free(mp); |
free(opts); |
return; |
} |
398,7 → 297,6 |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
free(mp); |
free(opts); |
return; |
} |
408,9 → 306,8 |
char *fs_name = (char *) malloc(size + 1); |
if (fs_name == NULL) { |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_0(rid, ENOMEM); |
ipc_answer_0(rid, EREFUSED); |
free(mp); |
free(opts); |
return; |
} |
417,30 → 314,14 |
/* Deliver the file system name. */ |
retval = ipc_data_write_finalize(callid, fs_name, size); |
if (retval != EOK) { |
ipc_answer_0(rid, retval); |
ipc_answer_0(rid, EREFUSED); |
free(mp); |
free(opts); |
free(fs_name); |
return; |
} |
fs_name[size] = '\0'; |
/* |
* Wait for IPC_M_PING so that we can return an error if we don't know |
* fs_name. |
*/ |
ipc_call_t data; |
callid = async_get_call(&data); |
if (IPC_GET_METHOD(data) != IPC_M_PING) { |
ipc_answer_0(callid, ENOTSUP); |
ipc_answer_0(rid, ENOTSUP); |
free(mp); |
free(opts); |
free(fs_name); |
return; |
} |
/* |
* Check if we know a file system with the same name as is in fs_name. |
* This will also give us its file system handle. |
*/ |
447,22 → 328,18 |
fs_handle_t fs_handle = fs_name_to_handle(fs_name, true); |
if (!fs_handle) { |
if (flags & IPC_FLAG_BLOCKING) { |
pending_req_t *pr; |
/* Blocking mount, add to pending list */ |
pr = (pending_req_t *) malloc(sizeof(pending_req_t)); |
pending_req_t *pr = (pending_req_t *) malloc(sizeof(pending_req_t)); |
if (!pr) { |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_0(rid, ENOMEM); |
free(mp); |
free(fs_name); |
free(opts); |
return; |
} |
pr->fs_name = fs_name; |
pr->mp = mp; |
pr->opts = opts; |
pr->callid = callid; |
pr->rid = rid; |
pr->dev_handle = dev_handle; |
475,7 → 352,6 |
ipc_answer_0(rid, ENOENT); |
free(mp); |
free(fs_name); |
free(opts); |
return; |
} |
483,10 → 359,9 |
ipc_answer_0(callid, EOK); |
/* Do the mount */ |
vfs_mount_internal(rid, dev_handle, fs_handle, mp, opts); |
vfs_mount_internal(rid, dev_handle, fs_handle, mp); |
free(mp); |
free(fs_name); |
free(opts); |
} |
void vfs_open(ipc_callid_t rid, ipc_call_t *request) |
984,16 → 859,8 |
} |
oldc[olen] = '\0'; |
newc[nlen] = '\0'; |
if ((!str_lcmp(newc, oldc, str_length(oldc))) && |
((newc[str_length(oldc)] == '/') || |
(str_length(oldc) == 1) || |
(str_length(oldc) == str_length(newc)))) { |
/* |
* oldc is a prefix of newc and either |
* - newc continues with a / where oldc ends, or |
* - oldc was / itself, or |
* - oldc and newc are equal. |
*/ |
if (!str_lcmp(newc, oldc, str_length(oldc))) { |
/* oldc is a prefix of newc */ |
ipc_answer_0(rid, EINVAL); |
free(old); |
free(new); |
1021,23 → 888,8 |
free(new); |
return; |
} |
/* Determine the path to the parent of the node with the new name. */ |
char *parentc = str_dup(newc); |
if (!parentc) { |
rwlock_write_unlock(&namespace_rwlock); |
ipc_answer_0(rid, rc); |
free(old); |
free(new); |
return; |
} |
char *lastsl = str_rchr(parentc + 1, L'/'); |
if (lastsl) |
*lastsl = '\0'; |
else |
parentc[1] = '\0'; |
/* Lookup parent of the new file name. */ |
rc = vfs_lookup_internal(parentc, L_NONE, &new_par_lr, NULL); |
free(parentc); /* not needed anymore */ |
rc = vfs_lookup_internal(newc, L_PARENT, &new_par_lr, NULL); |
if (rc != EOK) { |
rwlock_write_unlock(&namespace_rwlock); |
ipc_answer_0(rid, rc); |
/branches/dd/uspace/srv/vfs/vfs.h |
---|
38,7 → 38,6 |
#include <futex.h> |
#include <rwlock.h> |
#include <sys/types.h> |
#include <devmap.h> |
#include <bool.h> |
// FIXME: according to CONFIG_DEBUG |
50,6 → 49,7 |
/* Basic types. */ |
typedef int16_t fs_handle_t; |
typedef int16_t dev_handle_t; |
typedef uint32_t fs_index_t; |
typedef enum { |
166,6 → 166,11 |
* VFS_UNLINK. |
*/ |
#define L_UNLINK 32 |
/** |
* L_PARENT performs a lookup but returns the triplet of the parent node. |
* This flag may not be combined with any other lookup flag. |
*/ |
#define L_PARENT 64 |
typedef enum vfs_node_type { |
VFS_NODE_UNKNOWN, |
249,8 → 254,6 |
extern uint8_t *plb; /**< Path Lookup Buffer */ |
extern link_t plb_head; /**< List of active PLB entries. */ |
#define MAX_MNTOPTS_LEN 256 |
/** Holding this rwlock prevents changes in file system namespace. */ |
extern rwlock_t namespace_rwlock; |
/branches/dd/uspace/srv/vfs/Makefile |
---|
69,7 → 69,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/srv/vfs/vfs_file.c |
---|
103,7 → 103,7 |
*/ |
int vfs_fd_free(int fd) |
{ |
if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (files[fd] == NULL)) |
if ((fd >= MAX_OPEN_FILES) || (files[fd] == NULL)) |
return EBADF; |
vfs_file_delref(files[fd]); |
files[fd] = NULL; |
150,7 → 150,7 |
*/ |
vfs_file_t *vfs_file_get(int fd) |
{ |
if ((fd >= 0) && (fd < MAX_OPEN_FILES)) |
if (fd < MAX_OPEN_FILES) |
return files[fd]; |
return NULL; |
} |
/branches/dd/uspace/app/init/init.c |
---|
45,7 → 45,6 |
#include <malloc.h> |
#include <macros.h> |
#include <console.h> |
#include <string.h> |
#include "init.h" |
#include "version.h" |
52,13 → 51,9 |
static bool mount_fs(const char *fstype) |
{ |
int rc = -1; |
char *opts = ""; |
if (str_cmp(fstype, "tmpfs") == 0) |
opts = "restore"; |
while (rc < 0) { |
rc = mount(fstype, "/", "initrd", opts, IPC_FLAG_BLOCKING); |
rc = mount(fstype, "/", "initrd", IPC_FLAG_BLOCKING); |
switch (rc) { |
case EOK: |
79,32 → 74,6 |
return true; |
} |
static bool mount_devfs(void) |
{ |
int rc = -1; |
while (rc < 0) { |
rc = mount("devfs", "/dev", "null", "", IPC_FLAG_BLOCKING); |
switch (rc) { |
case EOK: |
printf(NAME ": Device filesystem mounted\n"); |
break; |
case EBUSY: |
printf(NAME ": Device filesystem already mounted\n"); |
break; |
case ELIMIT: |
printf(NAME ": Unable to mount device filesystem\n"); |
return false; |
case ENOENT: |
printf(NAME ": Unknown filesystem type (devfs)\n"); |
return false; |
} |
} |
return true; |
} |
static void spawn(char *fname) |
{ |
char *argv[2]; |
114,8 → 83,12 |
argv[0] = fname; |
argv[1] = NULL; |
if (!task_spawn(fname, argv)) |
if (task_spawn(fname, argv)) { |
/* Add reasonable delay to avoid intermixed klog output. */ |
usleep(10000); |
} else { |
printf(NAME ": Error spawning %s\n", fname); |
} |
} |
int main(int argc, char *argv[]) |
127,13 → 100,6 |
return -1; |
} |
spawn("/srv/devfs"); |
if (!mount_devfs()) { |
return(NAME ": Exiting\n"); |
return -2; |
} |
spawn("/srv/fb"); |
spawn("/srv/kbd"); |
spawn("/srv/console"); |
/branches/dd/uspace/app/init/Makefile |
---|
69,7 → 69,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/app/bdsh/cmds/modules/mv/mv.c |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mv/mv_def.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mv/entry.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mv/mv.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/bdd/bdd.c |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/bdd/bdd_def.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/bdd/bdd.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/bdd/entry.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mount/mount.c |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mount/mount_def.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mount/entry.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mount/mount.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/modules.h |
---|
20,7 → 20,6 |
#include "help/entry.h" |
#include "mkdir/entry.h" |
#include "rm/entry.h" |
#include "bdd/entry.h" |
#include "cat/entry.h" |
#include "touch/entry.h" |
#include "ls/entry.h" |
27,8 → 26,6 |
#include "pwd/entry.h" |
#include "sleep/entry.h" |
#include "cp/entry.h" |
#include "mv/entry.h" |
#include "mount/entry.h" |
#include "kcon/entry.h" |
/* Each .def function fills the module_t struct with the individual name, entry |
39,7 → 36,6 |
#include "help/help_def.h" |
#include "mkdir/mkdir_def.h" |
#include "rm/rm_def.h" |
#include "bdd/bdd_def.h" |
#include "cat/cat_def.h" |
#include "touch/touch_def.h" |
#include "ls/ls_def.h" |
46,10 → 42,7 |
#include "pwd/pwd_def.h" |
#include "sleep/sleep_def.h" |
#include "cp/cp_def.h" |
#include "mv/mv_def.h" |
#include "mount/mount_def.h" |
#include "kcon/kcon_def.h" |
{NULL, NULL, NULL, NULL} |
}; |
/branches/dd/uspace/app/bdsh/cmds/modules/cat/cat.c |
---|
87,8 → 87,7 |
off_t total = 0; |
char *buff = NULL; |
fd = open(fname, O_RDONLY); |
if (fd < 0) { |
if (-1 == (fd = open(fname, O_RDONLY))) { |
printf("Unable to open %s\n", fname); |
return 1; |
} |
/branches/dd/uspace/app/bdsh/cmds/modules/module_aliases.h |
---|
12,7 → 12,6 |
* the entry point being reached. */ |
char *mod_aliases[] = { |
"ren", "mv", |
NULL, NULL |
}; |
/branches/dd/uspace/app/bdsh/Makefile |
---|
33,13 → 33,12 |
LIBC_PREFIX = ../../lib/libc |
SOFTINT_PREFIX = ../../lib/softint |
LIBBLOCK_PREFIX = ../../lib/libblock |
include $(LIBC_PREFIX)/Makefile.toolchain |
CFLAGS += -I../../srv/kbd/include -I$(LIBBLOCK_PREFIX) |
CFLAGS += -I../../srv/kbd/include |
LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a |
LIBS = $(LIBC_PREFIX)/libc.a |
DEFS += -DRELEASE=$(RELEASE) |
PROGRAM = bdsh |
52,7 → 51,6 |
cmds/modules/help/ \ |
cmds/modules/mkdir/ \ |
cmds/modules/rm/ \ |
cmds/modules/bdd/ \ |
cmds/modules/cat/ \ |
cmds/modules/touch/ \ |
cmds/modules/ls/ \ |
59,8 → 57,6 |
cmds/modules/pwd/ \ |
cmds/modules/sleep/ \ |
cmds/modules/cp/ \ |
cmds/modules/mv/ \ |
cmds/modules/mount/ \ |
cmds/modules/kcon/ \ |
cmds/builtins/ \ |
cmds/builtins/exit/\ |
70,7 → 66,6 |
cmds/modules/help/help.c \ |
cmds/modules/mkdir/mkdir.c \ |
cmds/modules/rm/rm.c \ |
cmds/modules/bdd/bdd.c \ |
cmds/modules/cat/cat.c \ |
cmds/modules/touch/touch.c \ |
cmds/modules/ls/ls.c \ |
77,8 → 72,6 |
cmds/modules/pwd/pwd.c \ |
cmds/modules/sleep/sleep.c \ |
cmds/modules/cp/cp.c \ |
cmds/modules/mv/mv.c \ |
cmds/modules/mount/mount.c \ |
cmds/modules/kcon/kcon.c \ |
cmds/builtins/exit/exit.c \ |
cmds/builtins/cd/cd.c \ |
/branches/dd/uspace/app/tester/tester.c |
---|
56,7 → 56,6 |
#include "ipc/send_sync.def" |
#include "ipc/answer.def" |
#include "ipc/hangup.def" |
#include "ipc/ping_pong.def" |
#include "devmap/devmap1.def" |
#include "loop/loop1.def" |
#include "vfs/vfs1.def" |
/branches/dd/uspace/app/tester/devmap/devmap1.c |
---|
32,7 → 32,7 |
#include <ipc/services.h> |
#include <async.h> |
#include <errno.h> |
#include <devmap.h> |
#include <ipc/devmap.h> |
#include "../tester.h" |
#include <time.h> |
84,14 → 84,22 |
handle = (int)arg; |
device_phone = devmap_device_connect(handle, 0); |
device_phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, |
DEVMAP_CONNECT_TO_DEVICE, handle); |
if (device_phone < 0) { |
printf("Failed to connect to device (handle = %u).\n", |
printf("Failed to connect to devmap as client (handle = %u).\n", |
handle); |
return -1; |
} |
/* |
* device_phone = (int) IPC_GET_ARG5(answer); |
*/ |
printf("Connected to device.\n"); |
ipc_call_sync_1_0(device_phone, 1024, 1025); |
/* |
* ipc_hangup(device_phone); |
*/ |
ipc_hangup(device_phone); |
return EOK; |
113,6 → 121,126 |
return EOK; |
} |
/** |
* |
*/ |
static int driver_register(char *name) |
{ |
ipcarg_t retval; |
aid_t req; |
ipc_call_t answer; |
int phone; |
ipcarg_t callback_phonehash; |
phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER, 0); |
if (phone < 0) { |
printf("Failed to connect to device mapper\n"); |
return -1; |
} |
req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer); |
retval = ipc_data_write_start(phone, (char *)name, str_size(name) + 1); |
if (retval != EOK) { |
async_wait_for(req, NULL); |
return -1; |
} |
async_set_client_connection(driver_client_connection); |
ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash); |
/* |
if (NULL == async_new_connection(callback_phonehash, 0, NULL, |
driver_client_connection)) { |
printf("Failed to create new fibril.\n"); |
async_wait_for(req, NULL); |
return -1; |
} |
*/ |
async_wait_for(req, &retval); |
printf("Driver '%s' registered.\n", name); |
return phone; |
} |
static int device_get_handle(int driver_phone, char *name, int *handle) |
{ |
ipcarg_t retval; |
aid_t req; |
ipc_call_t answer; |
req = async_send_2(driver_phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0, |
&answer); |
retval = ipc_data_write_start(driver_phone, name, str_size(name) + 1); |
if (retval != EOK) { |
printf("Failed to send device name '%s'.\n", name); |
async_wait_for(req, NULL); |
return retval; |
} |
async_wait_for(req, &retval); |
if (NULL != handle) { |
*handle = -1; |
} |
if (EOK == retval) { |
if (NULL != handle) { |
*handle = (int) IPC_GET_ARG1(answer); |
} |
printf("Device '%s' has handle %u.\n", name, |
(int) IPC_GET_ARG1(answer)); |
} else { |
printf("Failed to get handle for device '%s'.\n", name); |
} |
return retval; |
} |
/** Register new device. |
* @param driver_phone |
* @param name Device name. |
* @param handle Output variable. Handle to the created instance of device. |
*/ |
static int device_register(int driver_phone, char *name, int *handle) |
{ |
ipcarg_t retval; |
aid_t req; |
ipc_call_t answer; |
req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer); |
retval = ipc_data_write_start(driver_phone, (char *)name, |
str_size(name) + 1); |
if (retval != EOK) { |
printf("Failed to send device name '%s'.\n", name); |
async_wait_for(req, NULL); |
return retval; |
} |
async_wait_for(req, &retval); |
if (NULL != handle) { |
*handle = -1; |
} |
if (EOK == retval) { |
if (NULL != handle) { |
*handle = (int) IPC_GET_ARG1(answer); |
} |
printf("Device registered with handle %u.\n", |
(int) IPC_GET_ARG1(answer)); |
} |
return retval; |
} |
/** Test DevMap from the driver's point of view. |
* |
* |
119,71 → 247,64 |
*/ |
char * test_devmap1(bool quiet) |
{ |
const char *retval = NULL; |
int driver_phone; |
int dev1_handle; |
int dev2_handle; |
int dev3_handle; |
int handle; |
/* Register new driver */ |
int rc = devmap_driver_register("TestDriver", driver_client_connection); |
if (rc < 0) { |
retval = "Error: Cannot register driver.\n"; |
goto out; |
driver_phone = driver_register("TestDriver"); |
if (driver_phone < 0) { |
return "Error: Cannot register driver.\n"; |
} |
/* Register new device dev1. */ |
dev_handle_t dev1_handle; |
rc = devmap_device_register(TEST_DEVICE1, &dev1_handle); |
if (rc != EOK) { |
retval = "Error: cannot register device.\n"; |
goto out; |
/* Register new device dev1*/ |
if (EOK != device_register(driver_phone, TEST_DEVICE1, &dev1_handle)) { |
ipc_hangup(driver_phone); |
return "Error: cannot register device.\n"; |
} |
/* |
* Get handle for dev2 (Should fail unless device is already registered |
* by someone else). |
/* Get handle for dev2 (Should fail unless device is already |
* registered by someone else) |
*/ |
dev_handle_t handle; |
rc = devmap_device_get_handle(TEST_DEVICE2, &handle, 0); |
if (rc == EOK) { |
retval = "Error: got handle for dev2 before it was registered.\n"; |
goto out; |
if (EOK == device_get_handle(driver_phone, TEST_DEVICE2, &handle)) { |
ipc_hangup(driver_phone); |
return "Error: got handle for dev2 before it was registered.\n"; |
} |
/* Register new device dev2. */ |
dev_handle_t dev2_handle; |
rc = devmap_device_register(TEST_DEVICE2, &dev2_handle); |
if (rc != EOK) { |
retval = "Error: cannot register device dev2.\n"; |
goto out; |
/* Register new device dev2*/ |
if (EOK != device_register(driver_phone, TEST_DEVICE2, &dev2_handle)) { |
ipc_hangup(driver_phone); |
return "Error: cannot register device dev2.\n"; |
} |
/* Register device dev1 again. */ |
dev_handle_t dev3_handle; |
rc = devmap_device_register(TEST_DEVICE1, &dev3_handle); |
if (rc == EOK) { |
retval = "Error: dev1 registered twice.\n"; |
goto out; |
/* Register again device dev1 */ |
if (EOK == device_register(driver_phone, TEST_DEVICE1, &dev3_handle)) { |
return "Error: dev1 registered twice.\n"; |
} |
/* Get handle for dev1. */ |
rc = devmap_device_get_handle(TEST_DEVICE1, &handle, 0); |
if (rc != EOK) { |
retval = "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; |
goto out; |
/* Get handle for dev1*/ |
if (EOK != device_get_handle(driver_phone, TEST_DEVICE1, &handle)) { |
ipc_hangup(driver_phone); |
return "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; |
} |
if (handle != dev1_handle) { |
retval = "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; |
goto out; |
ipc_hangup(driver_phone); |
return "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; |
} |
if (device_client(dev1_handle) != EOK) { |
retval = "Error: failed client test for 'DEVMAP_DEVICE1'.\n"; |
goto out; |
if (EOK != device_client(dev1_handle)) { |
ipc_hangup(driver_phone); |
return "Error: failed client test for 'DEVMAP_DEVICE1'.\n"; |
} |
out: |
devmap_hangup_phone(DEVMAP_DRIVER); |
devmap_hangup_phone(DEVMAP_CLIENT); |
/* TODO: */ |
ipc_hangup(driver_phone); |
return NULL; |
} |
/branches/dd/uspace/app/tester/tester.h |
---|
69,7 → 69,6 |
extern char * test_send_sync(bool quiet); |
extern char * test_answer(bool quiet); |
extern char * test_hangup(bool quiet); |
extern char * test_ping_pong(bool quiet); |
extern char * test_devmap1(bool quiet); |
extern char * test_loop1(bool quiet); |
extern char * test_vfs1(bool quiet); |
/branches/dd/uspace/app/tester/Makefile |
---|
54,7 → 54,6 |
ipc/send_sync.c \ |
ipc/answer.c \ |
ipc/hangup.c \ |
ipc/ping_pong.c \ |
loop/loop1.c \ |
devmap/devmap1.c \ |
console/console1.c \ |
82,7 → 81,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/app/tester/ipc/ping_pong.c |
---|
File deleted |
/branches/dd/uspace/app/tester/ipc/ping_pong.def |
---|
File deleted |
/branches/dd/uspace/app/tester/vfs/vfs1.c |
---|
45,7 → 45,7 |
{ |
int rc; |
rc = mount("tmpfs", "/", "nulldev0", "", 0); |
rc = mount("tmpfs", "/", "nulldev0", 0); |
switch (rc) { |
case EOK: |
if (!quiet) |
/branches/dd/uspace/app/tetris/input.c |
---|
115,7 → 115,7 |
if (!lastchar) { |
again: |
if (!getchar_inprog) { |
cons_phone = console_open(true); |
cons_phone = console_phone_get(true); |
getchar_inprog = async_send_2(cons_phone, |
CONSOLE_GETKEY, 0, 0, &charcall); |
} |
/branches/dd/uspace/app/tetris/Makefile |
---|
27,7 → 27,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/app/klog/Makefile |
---|
64,7 → 64,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/app/trace/trace.c |
---|
666,8 → 666,6 |
arg_def[0] = V_CHAR; |
o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def); |
proto_add_oper(p, CONSOLE_PUTCHAR, o); |
o = oper_new("write", 0, arg_def, V_VOID, 0, resp_def); |
proto_add_oper(p, CONSOLE_WRITE, o); |
o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def); |
proto_add_oper(p, CONSOLE_CLEAR, o); |
/branches/dd/uspace/lib/libc/include/devmap.h |
---|
File deleted |
/branches/dd/uspace/lib/libc/include/console.h |
---|
27,7 → 27,7 |
*/ |
/** @addtogroup libc |
* @{ |
* @{ |
*/ |
/** @file |
*/ |
40,16 → 40,19 |
#include <sys/types.h> |
#include <bool.h> |
extern int console_open(bool); |
extern void console_open(bool); |
extern void console_close(void); |
extern int console_phone_get(bool); |
extern void console_wait(void); |
extern void console_clear(void); |
extern void console_goto(int, int); |
extern void console_putchar(wchar_t); |
extern ssize_t console_write(const char *, size_t); |
extern void console_putstr(const char *); |
extern ssize_t console_write(const char *buf, size_t nbyte); |
extern void console_putstr(const char *s); |
extern void console_flush(void); |
extern void console_flush_optional(void); |
extern int console_get_size(int *, int *); |
extern void console_set_style(int); |
60,6 → 63,6 |
extern void console_kcon_enable(void); |
#endif |
/** @} |
*/ |
/branches/dd/uspace/lib/libc/include/string.h |
---|
42,10 → 42,10 |
#define U_SPECIAL '?' |
#define U_BOM 0xfeff |
/** No size limit constant */ |
/**< No size limit constant */ |
#define STR_NO_LIMIT ((size_t) -1) |
/** Maximum size of a string containing @c length characters */ |
/**< Maximum size of a string containing @c length characters */ |
#define STR_BOUNDS(length) ((length) << 2) |
extern wchar_t str_decode(const char *str, size_t *offset, size_t sz); |
/branches/dd/uspace/lib/libc/include/io/stream.h |
---|
37,12 → 37,15 |
#include <libarch/types.h> |
#define EMFILE -17 |
#define EMFILE -17 |
extern ssize_t read_stdin(void *, size_t); |
extern int klog_puts(const char *); |
extern void klog_update(void); |
extern ssize_t read_stdin(void *, size_t); |
extern ssize_t write_stdout(const void *, size_t); |
extern ssize_t write_stderr(const void *, size_t); |
extern int flush_stdout(void); |
#endif |
/** @} |
/branches/dd/uspace/lib/libc/include/ipc/bd.h |
---|
File deleted |
/branches/dd/uspace/lib/libc/include/ipc/devmap.h |
---|
33,14 → 33,11 |
#ifndef DEVMAP_DEVMAP_H_ |
#define DEVMAP_DEVMAP_H_ |
#include <atomic.h> |
#include <ipc/ipc.h> |
#include <libadt/list.h> |
#define DEVMAP_NAME_MAXLEN 255 |
#define DEVMAP_NAME_MAXLEN 512 |
typedef ipcarg_t dev_handle_t; |
typedef enum { |
DEVMAP_DRIVER_REGISTER = IPC_FIRST_USER_METHOD, |
DEVMAP_DRIVER_UNREGISTER, |
47,30 → 44,56 |
DEVMAP_DEVICE_REGISTER, |
DEVMAP_DEVICE_UNREGISTER, |
DEVMAP_DEVICE_GET_NAME, |
DEVMAP_DEVICE_GET_HANDLE, |
DEVMAP_DEVICE_GET_COUNT, |
DEVMAP_DEVICE_GET_DEVICES |
DEVMAP_DEVICE_GET_HANDLE |
} devmap_request_t; |
/** Interface provided by devmap. |
/** Representation of device driver. |
* Each driver is responsible for a set of devices. |
*/ |
typedef struct { |
/** Pointers to previous and next drivers in linked list */ |
link_t drivers; |
/** Pointer to the linked list of devices controlled by |
* this driver */ |
link_t devices; |
/** Phone asociated with this driver */ |
ipcarg_t phone; |
/** Device driver name */ |
char *name; |
/** Futex for list of devices owned by this driver */ |
atomic_t devices_futex; |
} devmap_driver_t; |
/** Info about registered device |
* |
*/ |
typedef struct { |
/** Pointer to the previous and next device in the list of all devices */ |
link_t devices; |
/** Pointer to the previous and next device in the list of devices |
owned by one driver */ |
link_t driver_devices; |
/** Unique device identifier */ |
int handle; |
/** Device name */ |
char *name; |
/** Device driver handling this device */ |
devmap_driver_t *driver; |
} devmap_device_t; |
/** Interface provided by devmap. |
* Every process that connects to devmap must ask one of following |
* interfaces otherwise connection will be refused. |
* |
*/ |
typedef enum { |
/** Connect as device driver */ |
DEVMAP_DRIVER = 1, |
/** Connect as client */ |
/** Connect as device driver */ |
DEVMAP_DRIVER = 1, |
/** Connect as client */ |
DEVMAP_CLIENT, |
/** Create new connection to instance of device that |
is specified by second argument of call. */ |
/** Create new connection to instance of device that |
* is specified by second argument of call. */ |
DEVMAP_CONNECT_TO_DEVICE |
} devmap_interface_t; |
typedef struct { |
dev_handle_t handle; |
char name[DEVMAP_NAME_MAXLEN + 1]; |
} dev_desc_t; |
#endif |
#endif |
/branches/dd/uspace/lib/libc/include/ipc/fb.h |
---|
66,9 → 66,7 |
FB_ANIM_CHGVP, |
FB_ANIM_START, |
FB_ANIM_STOP, |
FB_POINTER_MOVE, |
FB_SCREEN_YIELD, |
FB_SCREEN_RECLAIM |
FB_POINTER_MOVE |
} fb_request_t; |
#endif |
/branches/dd/uspace/lib/libc/include/vfs/vfs.h |
---|
39,8 → 39,8 |
extern char *absolutize(const char *, size_t *); |
extern int mount(const char *, const char *, const char *, const char *, |
unsigned int flags); |
extern int mount(const char *, const char *, const char *, |
const unsigned int flags); |
#endif |
/branches/dd/uspace/lib/libc/include/async.h |
---|
98,22 → 98,22 |
/* Wrappers for simple communication */ |
#define async_msg_0(phone, method) \ |
ipc_call_async_0((phone), (method), NULL, NULL, true) |
ipc_call_async_0((phone), (method), NULL, NULL, !in_interrupt_handler()) |
#define async_msg_1(phone, method, arg1) \ |
ipc_call_async_1((phone), (method), (arg1), NULL, NULL, \ |
true) |
!in_interrupt_handler()) |
#define async_msg_2(phone, method, arg1, arg2) \ |
ipc_call_async_2((phone), (method), (arg1), (arg2), NULL, NULL, \ |
true) |
!in_interrupt_handler()) |
#define async_msg_3(phone, method, arg1, arg2, arg3) \ |
ipc_call_async_3((phone), (method), (arg1), (arg2), (arg3), NULL, NULL, \ |
true) |
!in_interrupt_handler()) |
#define async_msg_4(phone, method, arg1, arg2, arg3, arg4) \ |
ipc_call_async_4((phone), (method), (arg1), (arg2), (arg3), (arg4), NULL, \ |
NULL, true) |
NULL, !in_interrupt_handler()) |
#define async_msg_5(phone, method, arg1, arg2, arg3, arg4, arg5) \ |
ipc_call_async_5((phone), (method), (arg1), (arg2), (arg3), (arg4), \ |
(arg5), NULL, NULL, true) |
(arg5), NULL, NULL, !in_interrupt_handler()) |
/* |
* User-friendly wrappers for async_req_fast() and async_req_slow(). The macros |
253,6 → 253,8 |
fibril_dec_sercount(); |
} |
extern bool in_interrupt_handler(void); |
extern atomic_t async_futex; |
#endif |
/branches/dd/uspace/lib/libc/include/libadt/list.h |
---|
37,20 → 37,26 |
#include <unistd.h> |
#ifndef true |
# define true 1 |
#endif |
#ifndef false |
# define false 0 |
#endif |
typedef struct link link_t; |
/** Doubly linked list head and link type. */ |
typedef struct link { |
struct link *prev; /**< Pointer to the previous item in the list. */ |
struct link *next; /**< Pointer to the next item in the list. */ |
} link_t; |
struct link { |
link_t *prev; /**< Pointer to the previous item in the list. */ |
link_t *next; /**< Pointer to the next item in the list. */ |
}; |
/** Declare and initialize statically allocated list. |
* |
* @param name Name of the new statically allocated list. |
*/ |
#define LIST_INITIALIZE(name) link_t name = { \ |
.prev = &name, \ |
.next = &name \ |
} |
#define LIST_INITIALIZE(name) link_t name = { .prev = &name, .next = &name } |
/** Initialize doubly-linked circular list link |
* |
139,7 → 145,7 |
*/ |
static inline int list_empty(link_t *head) |
{ |
return ((head->next == head) ? 1 : 0); |
return head->next == head ? true : false; |
} |
155,11 → 161,11 |
*/ |
static inline void headless_list_split_or_concat(link_t *part1, link_t *part2) |
{ |
link_t *hlp; |
part1->prev->next = part2; |
part2->prev->next = part1; |
link_t *hlp = part1->prev; |
part2->prev->next = part1; |
hlp = part1->prev; |
part1->prev = part2->prev; |
part2->prev = hlp; |
} |
189,11 → 195,10 |
headless_list_split_or_concat(part1, part2); |
} |
#define list_get_instance(link, type, member) ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member)))) |
#define list_get_instance(link,type,member) (type *)(((char *)(link))-((char *)&(((type *)NULL)->member))) |
extern int list_member(const link_t *link, const link_t *head); |
extern void list_concat(link_t *head1, link_t *head2); |
extern unsigned int list_count(const link_t *link); |
#endif |
/branches/dd/uspace/lib/libc/generic/devmap.c |
---|
File deleted |
/branches/dd/uspace/lib/libc/generic/console.c |
---|
32,9 → 32,8 |
* @{ |
*/ |
/** @file |
*/ |
*/ |
#include <libc.h> |
#include <async.h> |
#include <io/stream.h> |
#include <ipc/console.h> |
46,7 → 45,7 |
static int console_phone = -1; |
/** Size of cbuffer. */ |
#define CBUFFER_SIZE 256 |
#define CBUFFER_SIZE 256 |
/** Buffer for writing characters to the console. */ |
static char cbuffer[CBUFFER_SIZE]; |
57,56 → 56,92 |
/** Pointer to first available field in cbuffer. */ |
static char *cbp = cbuffer; |
static ssize_t cons_write(const char *buf, size_t nbyte); |
static void cons_putchar(wchar_t c); |
/** Write one character to the console via IPC. */ |
static void cons_putchar(wchar_t c) |
static void cbuffer_flush(void); |
static void cbuffer_drain(void); |
static inline void cbuffer_putc(int c); |
void console_open(bool blocking) |
{ |
console_wait(); |
async_msg_1(console_phone, CONSOLE_PUTCHAR, c); |
if (console_phone < 0) { |
int phone; |
if (blocking) { |
phone = ipc_connect_me_to_blocking(PHONE_NS, |
SERVICE_CONSOLE, 0, 0); |
} else { |
phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, |
0); |
} |
if (phone >= 0) |
console_phone = phone; |
} |
} |
/** Write characters to the console via IPC or to klog */ |
static ssize_t cons_write(const char *buf, size_t size) |
void console_close(void) |
{ |
console_open(false); |
if (console_phone >= 0) { |
async_serialize_start(); |
ipc_call_t answer; |
aid_t req = async_send_0(console_phone, CONSOLE_WRITE, &answer); |
ipcarg_t rc = ipc_data_write_start(console_phone, (void *) buf, size); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
return (ssize_t) rc; |
if (ipc_hangup(console_phone) == 0) { |
console_phone = -1; |
} |
async_wait_for(req, &rc); |
async_serialize_end(); |
if (rc == EOK) |
return (ssize_t) IPC_GET_ARG1(answer); |
else |
return -1; |
} else |
return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, size); |
} |
} |
int console_phone_get(bool blocking) |
{ |
if (console_phone < 0) |
console_open(blocking); |
return console_phone; |
} |
void console_wait(void) |
{ |
while (console_phone < 0) |
console_open(true); |
} |
void console_clear(void) |
{ |
int cons_phone = console_phone_get(true); |
cbuffer_drain(); |
async_msg_0(cons_phone, CONSOLE_CLEAR); |
} |
void console_goto(int row, int col) |
{ |
int cons_phone = console_phone_get(true); |
cbuffer_flush(); |
async_msg_2(cons_phone, CONSOLE_GOTO, row, col); |
} |
void console_putchar(wchar_t c) |
{ |
// cbuffer_putc(c); |
cbuffer_flush(); |
cons_putchar(c); |
} |
/** Write all data from output buffer to the console. */ |
static void cbuffer_flush(void) |
{ |
size_t len = cbp - cbuffer; |
int rc; |
int len; |
len = cbp - cbuffer; |
while (len > 0) { |
ssize_t rc = cons_write(cbuffer, cbp - cbuffer); |
rc = cons_write(cbuffer, cbp - cbuffer); |
if (rc < 0) |
return; |
len -= rc; |
} |
cbp = cbuffer; |
} |
117,158 → 152,151 |
} |
/** Write one character to the output buffer. */ |
static inline void cbuffer_putc(char c) |
static inline void cbuffer_putc(int c) |
{ |
if (cbp == cbuffer_end) |
cbuffer_flush(); |
*cbp++ = c; |
if (c == '\n') |
cbuffer_flush(); |
} |
int console_open(bool blocking) |
/** Write one character to the console via IPC. */ |
static void cons_putchar(wchar_t c) |
{ |
if (console_phone < 0) { |
int phone; |
if (blocking) |
phone = ipc_connect_me_to_blocking(PHONE_NS, |
SERVICE_CONSOLE, 0, 0); |
else |
phone = ipc_connect_me_to(PHONE_NS, |
SERVICE_CONSOLE, 0, 0); |
if (phone >= 0) |
console_phone = phone; |
int cons_phone = console_phone_get(true); |
async_msg_1(cons_phone, CONSOLE_PUTCHAR, c); |
} |
/** Write characters to the console via IPC. */ |
static ssize_t cons_write(const char *buf, size_t nbyte) |
{ |
int cons_phone = console_phone_get(true); |
ipcarg_t rc; |
ipc_call_t answer; |
aid_t req; |
async_serialize_start(); |
req = async_send_0(cons_phone, CONSOLE_WRITE, &answer); |
rc = ipc_data_write_start(cons_phone, (void *) buf, nbyte); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
return (ssize_t) rc; |
} |
return console_phone; |
async_wait_for(req, &rc); |
async_serialize_end(); |
if (rc == EOK) |
return (ssize_t) IPC_GET_ARG1(answer); |
else |
return -1; |
} |
void console_close(void) |
/** Write characters to the console. */ |
ssize_t console_write(const char *buf, size_t nbyte) |
{ |
if (console_phone >= 0) { |
if (ipc_hangup(console_phone) == 0) |
console_phone = -1; |
size_t left; |
left = nbyte; |
while (left > 0) { |
cbuffer_putc(*buf++); |
--left; |
} |
return nbyte; |
} |
void console_wait(void) |
/** Write a NULL-terminated string to the console. */ |
void console_putstr(const char *s) |
{ |
while (console_phone < 0) |
console_open(true); |
size_t len; |
ssize_t rc; |
len = str_size(s); |
while (len > 0) { |
rc = console_write(s, len); |
if (rc < 0) |
return; /* Error */ |
s += rc; |
len -= rc; |
} |
} |
void console_clear(void) |
/** Flush all output to the console. */ |
void console_flush(void) |
{ |
console_wait(); |
cbuffer_drain(); |
async_msg_0(console_phone, CONSOLE_CLEAR); |
int cons_phone = console_phone_get(false); |
cbuffer_flush(); |
async_msg_0(cons_phone, CONSOLE_FLUSH); |
} |
void console_flush_optional(void) |
{ |
if (console_phone >= 0) |
console_flush(); |
} |
int console_get_size(int *rows, int *cols) |
{ |
console_wait(); |
ipcarg_t r; |
ipcarg_t c; |
int rc = async_req_0_2(console_phone, CONSOLE_GETSIZE, &r, &c); |
int cons_phone = console_phone_get(true); |
ipcarg_t r, c; |
int rc; |
rc = async_req_0_2(cons_phone, CONSOLE_GETSIZE, &r, &c); |
*rows = (int) r; |
*cols = (int) c; |
return rc; |
} |
void console_set_style(int style) |
{ |
console_wait(); |
int cons_phone = console_phone_get(true); |
cbuffer_flush(); |
async_msg_1(console_phone, CONSOLE_SET_STYLE, style); |
async_msg_1(cons_phone, CONSOLE_SET_STYLE, style); |
} |
void console_set_color(int fg_color, int bg_color, int flags) |
{ |
console_wait(); |
int cons_phone = console_phone_get(true); |
cbuffer_flush(); |
async_msg_3(console_phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags); |
async_msg_3(cons_phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags); |
} |
void console_set_rgb_color(int fg_color, int bg_color) |
{ |
console_wait(); |
int cons_phone = console_phone_get(true); |
cbuffer_flush(); |
async_msg_2(console_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color); |
async_msg_2(cons_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color); |
} |
void console_cursor_visibility(int show) |
{ |
console_wait(); |
int cons_phone = console_phone_get(true); |
cbuffer_flush(); |
async_msg_1(console_phone, CONSOLE_CURSOR_VISIBILITY, show != 0); |
async_msg_1(cons_phone, CONSOLE_CURSOR_VISIBILITY, show != 0); |
} |
void console_kcon_enable(void) |
{ |
console_wait(); |
cbuffer_flush(); |
async_msg_0(console_phone, CONSOLE_KCON_ENABLE); |
} |
int cons_phone = console_phone_get(true); |
void console_goto(int row, int col) |
{ |
console_wait(); |
cbuffer_flush(); |
async_msg_2(console_phone, CONSOLE_GOTO, row, col); |
async_msg_0(cons_phone, CONSOLE_KCON_ENABLE); |
} |
void console_putchar(wchar_t c) |
{ |
console_wait(); |
cbuffer_flush(); |
cons_putchar(c); |
} |
/** Write characters to the console. */ |
ssize_t console_write(const char *buf, size_t size) |
{ |
size_t left = size; |
while (left > 0) { |
cbuffer_putc(*buf++); |
left--; |
} |
return size; |
} |
/** Write a NULL-terminated string to the console. */ |
void console_putstr(const char *str) |
{ |
size_t left = str_size(str); |
while (left > 0) { |
ssize_t rc = console_write(str, left); |
if (rc < 0) { |
/* Error */ |
return; |
} |
str += rc; |
left -= rc; |
} |
} |
/** Flush all output to the console or klog. */ |
void console_flush(void) |
{ |
cbuffer_flush(); |
if (console_phone >= 0) |
async_msg_0(console_phone, CONSOLE_FLUSH); |
} |
/** @} |
*/ |
/branches/dd/uspace/lib/libc/generic/string.c |
---|
593,12 → 593,10 |
{ |
wchar_t acc; |
size_t off = 0; |
size_t last = 0; |
while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) { |
if (acc == ch) |
return (str + last); |
last = off; |
return (str + off); |
} |
return NULL; |
615,15 → 613,14 |
{ |
wchar_t acc; |
size_t off = 0; |
size_t last = 0; |
char *res = NULL; |
char *res; |
res = NULL; |
while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) { |
if (acc == ch) |
res = (str + last); |
last = off; |
res = (str + off); |
} |
return res; |
} |
/branches/dd/uspace/lib/libc/generic/libc.c |
---|
84,7 → 84,7 |
} |
main(argc, argv); |
console_flush(); |
console_flush_optional(); |
} |
void __exit(void) |
/branches/dd/uspace/lib/libc/generic/vfs/vfs.c |
---|
48,7 → 48,7 |
#include <futex.h> |
#include <errno.h> |
#include <string.h> |
#include <devmap.h> |
#include <ipc/devmap.h> |
#include "../../../srv/vfs/vfs.h" |
int vfs_phone = -1; |
115,8 → 115,47 |
vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0); |
} |
static int device_get_handle(const char *name, dev_handle_t *handle, |
const unsigned int flags) |
{ |
int phone; |
if (flags & IPC_FLAG_BLOCKING) |
phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0); |
else |
phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0); |
if (phone < 0) |
return phone; |
ipc_call_t answer; |
aid_t req = async_send_2(phone, DEVMAP_DEVICE_GET_HANDLE, flags, 0, |
&answer); |
ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1); |
if (retval != EOK) { |
async_wait_for(req, NULL); |
ipc_hangup(phone); |
return retval; |
} |
async_wait_for(req, &retval); |
if (handle != NULL) |
*handle = -1; |
if (retval == EOK) { |
if (handle != NULL) |
*handle = (dev_handle_t) IPC_GET_ARG1(answer); |
} |
ipc_hangup(phone); |
return retval; |
} |
int mount(const char *fs_name, const char *mp, const char *dev, |
const char *opts, unsigned int flags) |
const unsigned int flags) |
{ |
int res; |
ipcarg_t rc; |
123,7 → 162,7 |
aid_t req; |
dev_handle_t dev_handle; |
res = devmap_device_get_handle(dev, &dev_handle, flags); |
res = device_get_handle(dev, &dev_handle, flags); |
if (res != EOK) |
return res; |
146,15 → 185,6 |
return (int) rc; |
} |
rc = ipc_data_write_start(vfs_phone, (void *) opts, str_size(opts)); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
futex_up(&vfs_phone_futex); |
free(mpa); |
return (int) rc; |
} |
rc = ipc_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
163,16 → 193,6 |
free(mpa); |
return (int) rc; |
} |
/* Ask VFS whether it likes fs_name. */ |
rc = async_req_0_0(vfs_phone, IPC_M_PING); |
if (rc != EOK) { |
async_wait_for(req, NULL); |
async_serialize_end(); |
futex_up(&vfs_phone_futex); |
free(mpa); |
return (int) rc; |
} |
async_wait_for(req, &rc); |
async_serialize_end(); |
/branches/dd/uspace/lib/libc/generic/io/io.c |
---|
38,7 → 38,6 |
#include <io/io.h> |
#include <string.h> |
#include <errno.h> |
#include <console.h> |
const static char nl = '\n'; |
50,9 → 49,8 |
return putnchars("(NULL)", 6); |
for (count = 0; str[count] != 0; count++); |
if (console_write((void *) str, count) == count) { |
if (console_write(&nl, 1) == 1) |
if (write_stdout((void *) str, count) == count) { |
if (write_stdout(&nl, 1) == 1) |
return 0; |
} |
66,7 → 64,7 |
*/ |
int putnchars(const char *buf, size_t count) |
{ |
if (console_write((void *) buf, count) == count) |
if (write_stdout((void *) buf, count) == count) |
return 0; |
return EOF; |
83,7 → 81,7 |
return putnchars("(NULL)", 6); |
for (count = 0; str[count] != 0; count++); |
if (console_write((void *) str, count) == count) |
if (write_stdout((void *) str, count) == count) |
return 0; |
return EOF; |
98,7 → 96,7 |
if (chr_encode(c, buf, &offs, STR_BOUNDS(1)) != EOK) |
return EOF; |
if (console_write((void *) buf, offs) == offs) |
if (write_stdout((void *) buf, offs) == offs) |
return c; |
return EOF; |
107,8 → 105,8 |
int getchar(void) |
{ |
unsigned char c; |
console_flush(); |
flush_stdout(); |
if (read_stdin((void *) &c, 1) == 1) |
return c; |
117,10 → 115,8 |
int fflush(FILE *f) |
{ |
/* Dummy implementation */ |
(void) f; |
console_flush(); |
return 0; |
return flush_stdout(); |
} |
/** @} |
/branches/dd/uspace/lib/libc/generic/io/vprintf.c |
---|
38,7 → 38,6 |
#include <io/printf_core.h> |
#include <futex.h> |
#include <async.h> |
#include <console.h> |
static atomic_t printf_futex = FUTEX_INITIALIZER; |
51,7 → 50,7 |
while (offset < size) { |
prev = offset; |
str_decode(str, &offset, size); |
console_write(str + prev, offset - prev); |
write_stdout(str + prev, offset - prev); |
chars++; |
} |
68,7 → 67,7 |
while (offset < size) { |
boff = 0; |
chr_encode(str[chars], buf, &boff, 4); |
console_write(buf, boff); |
write_stdout(buf, boff); |
chars++; |
offset += sizeof(wchar_t); |
} |
/branches/dd/uspace/lib/libc/generic/io/stream.c |
---|
49,34 → 49,62 |
#include <async.h> |
#include <sys/types.h> |
ssize_t write_stderr(const void *buf, size_t count) |
{ |
return count; |
} |
ssize_t read_stdin(void *buf, size_t count) |
{ |
int cons_phone = console_open(false); |
int cons_phone = console_phone_get(false); |
if (cons_phone >= 0) { |
kbd_event_t ev; |
int rc; |
size_t i = 0; |
while (i < count) { |
do { |
rc = kbd_get_event(&ev); |
if (rc < 0) return -1; |
} while (ev.c == 0 || ev.type == KE_RELEASE); |
((char *) buf)[i++] = ev.c; |
} |
return i; |
} else |
} else { |
return -1; |
} |
} |
/** Write a string to klog. */ |
int klog_puts(const char *str) |
ssize_t write_stdout(const void *buf, size_t count) |
{ |
return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) str, str_size(str)); |
int cons_phone = console_phone_get(false); |
int left, rc; |
if (cons_phone >= 0) { |
int i; |
left = count; |
while (left > 0) { |
rc = console_write(buf, left); |
if (rc < 0) |
break; |
buf += rc; |
left -= rc; |
} |
return count; |
} else |
return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, count); |
} |
int flush_stdout(void) |
{ |
console_flush(); |
return 0; |
} |
void klog_update(void) |
{ |
(void) __SYSCALL3(SYS_KLOG, 1, NULL, 0); |
/branches/dd/uspace/lib/libc/generic/kbd.c |
---|
42,7 → 42,7 |
int kbd_get_event(kbd_event_t *ev) |
{ |
int cons_phone = console_open(true); |
int cons_phone = console_phone_get(true); |
ipcarg_t r0, r1, r2, r3; |
int rc; |
/branches/dd/uspace/lib/libc/generic/ddi.c |
---|
130,7 → 130,7 |
phys = ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE); |
offset = pio_addr - phys; |
pages = ALIGN_UP(offset + size, PAGE_SIZE) >> PAGE_WIDTH; |
virt = as_get_mappable_page(pages << PAGE_WIDTH); |
virt = as_get_mappable_page(pages); |
*use_addr = virt + offset; |
return physmem_map(phys, virt, pages, AS_AREA_READ | AS_AREA_WRITE); |
} |
/branches/dd/uspace/lib/libc/generic/ipc.c |
---|
704,7 → 704,7 |
IPC_SET_ARG4(data, arg4); |
IPC_SET_ARG5(data, arg5); |
return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data, mode); |
return __SYSCALL3(SYS_IPC_FORWARD_SLOW, callid, (sysarg_t) &data, mode); |
} |
/** Wrapper for making IPC_M_SHARE_IN calls. |
/branches/dd/uspace/lib/libc/generic/async.c |
---|
30,65 → 30,64 |
* @{ |
*/ |
/** @file |
*/ |
*/ |
/** |
* Asynchronous library |
* |
* The aim of this library is to provide a facility for writing programs which |
* utilize the asynchronous nature of HelenOS IPC, yet using a normal way of |
* programming. |
* The aim of this library is facilitating writing programs utilizing the |
* asynchronous nature of HelenOS IPC, yet using a normal way of programming. |
* |
* You should be able to write very simple multithreaded programs, the async |
* framework will automatically take care of most synchronization problems. |
* |
* Default semantics: |
* - async_send_*(): Send asynchronously. If the kernel refuses to send |
* more messages, [ try to get responses from kernel, if |
* nothing found, might try synchronous ] |
* - async_send_*(): send asynchronously. If the kernel refuses to send |
* more messages, [ try to get responses from kernel, if |
* nothing found, might try synchronous ] |
* |
* Example of use (pseudo C): |
* |
* |
* 1) Multithreaded client application |
* |
* fibril_create(fibril1, ...); |
* fibril_create(fibril2, ...); |
* ... |
* fibril_create(fibril1, ...); |
* fibril_create(fibril2, ...); |
* ... |
* |
* int fibril1(void *arg) |
* { |
* conn = ipc_connect_me_to(); |
* c1 = async_send(conn); |
* c2 = async_send(conn); |
* async_wait_for(c1); |
* async_wait_for(c2); |
* ... |
* } |
* |
* int fibril1(void *arg) |
* { |
* conn = ipc_connect_me_to(); |
* c1 = async_send(conn); |
* c2 = async_send(conn); |
* async_wait_for(c1); |
* async_wait_for(c2); |
* ... |
* } |
* |
* |
* 2) Multithreaded server application |
* main() |
* { |
* async_manager(); |
* } |
* |
* |
* main() |
* { |
* async_manager(); |
* } |
* my_client_connection(icallid, *icall) |
* { |
* if (want_refuse) { |
* ipc_answer_0(icallid, ELIMIT); |
* return; |
* } |
* ipc_answer_0(icallid, EOK); |
* |
* my_client_connection(icallid, *icall) |
* { |
* if (want_refuse) { |
* ipc_answer_0(icallid, ELIMIT); |
* return; |
* } |
* ipc_answer_0(icallid, EOK); |
* callid = async_get_call(&call); |
* handle_call(callid, call); |
* ipc_answer_2(callid, 1, 2, 3); |
* |
* callid = async_get_call(&call); |
* handle_call(callid, call); |
* ipc_answer_2(callid, 1, 2, 3); |
* callid = async_get_call(&call); |
* .... |
* } |
* |
* callid = async_get_call(&call); |
* ... |
* } |
* |
*/ |
#include <futex.h> |
105,26 → 104,24 |
#include <bool.h> |
atomic_t async_futex = FUTEX_INITIALIZER; |
static hash_table_t conn_hash_table; |
static LIST_INITIALIZE(timeout_list); |
/** Structures of this type represent a waiting fibril. */ |
typedef struct { |
/** Expiration time. */ |
struct timeval expires; |
struct timeval expires; |
/** If true, this struct is in the timeout list. */ |
bool inlist; |
int inlist; |
/** Timeout list link. */ |
link_t link; |
/** Identification of and link to the waiting fibril. */ |
fid_t fid; |
/** If true, this fibril is currently active. */ |
bool active; |
int active; |
/** If true, we have timed out. */ |
bool timedout; |
int timedout; |
} awaiter_t; |
typedef struct { |
131,11 → 128,10 |
awaiter_t wdata; |
/** If reply was received. */ |
bool done; |
int done; |
/** Pointer to where the answer data is stored. */ |
ipc_call_t *dataptr; |
ipc_call_t *dataptr; |
ipcarg_t retval; |
} amsg_t; |
151,24 → 147,24 |
typedef struct { |
awaiter_t wdata; |
/** Hash table link. */ |
link_t link; |
/** Incoming phone hash. */ |
ipcarg_t in_phone_hash; |
ipcarg_t in_phone_hash; |
/** Messages that should be delivered to this fibril. */ |
link_t msg_queue; |
link_t msg_queue; |
/** Identification of the opening call. */ |
ipc_callid_t callid; |
/** Call data of the opening call. */ |
ipc_call_t call; |
/** Identification of the closing call. */ |
ipc_callid_t close_callid; |
/** Fibril function that will be used to handle the connection. */ |
void (*cfibril)(ipc_callid_t, ipc_call_t *); |
} connection_t; |
176,6 → 172,12 |
/** Identifier of the incoming connection handled by the current fibril. */ |
__thread connection_t *FIBRIL_connection; |
/** |
* If true, it is forbidden to use async_req functions and all preemption is |
* disabled. |
*/ |
__thread int _in_interrupt_handler; |
static void default_client_connection(ipc_callid_t callid, ipc_call_t *call); |
static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call); |
183,7 → 185,6 |
* Pointer to a fibril function that will be used to handle connections. |
*/ |
static async_client_conn_t client_connection = default_client_connection; |
/** |
* Pointer to a fibril function that will be used to handle interrupt |
* notifications. |
190,39 → 191,46 |
*/ |
static async_client_conn_t interrupt_received = default_interrupt_received; |
/* |
* Getter for _in_interrupt_handler. We need to export the value of this thread |
* local variable to other modules, but the binutils 2.18 linkers die on an |
* attempt to export this symbol in the header file. For now, consider this as a |
* workaround. |
*/ |
bool in_interrupt_handler(void) |
{ |
return _in_interrupt_handler; |
} |
static hash_table_t conn_hash_table; |
static LIST_INITIALIZE(timeout_list); |
#define CONN_HASH_TABLE_CHAINS 32 |
#define CONN_HASH_TABLE_CHAINS 32 |
/** Compute hash into the connection hash table based on the source phone hash. |
* |
* @param key Pointer to source phone hash. |
* @param key Pointer to source phone hash. |
* |
* @return Index into the connection hash table. |
* |
* @return Index into the connection hash table. |
*/ |
static hash_index_t conn_hash(unsigned long *key) |
{ |
assert(key); |
return (((*key) >> 4) % CONN_HASH_TABLE_CHAINS); |
return ((*key) >> 4) % CONN_HASH_TABLE_CHAINS; |
} |
/** Compare hash table item with a key. |
* |
* @param key Array containing the source phone hash as the only item. |
* @param keys Expected 1 but ignored. |
* @param item Connection hash table item. |
* @param key Array containing the source phone hash as the only item. |
* @param keys Expected 1 but ignored. |
* @param item Connection hash table item. |
* |
* @return True on match, false otherwise. |
* |
* @return True on match, false otherwise. |
*/ |
static int conn_compare(unsigned long key[], hash_count_t keys, link_t *item) |
{ |
connection_t *hs = hash_table_get_instance(item, connection_t, link); |
return (key[0] == hs->in_phone_hash); |
connection_t *hs; |
hs = hash_table_get_instance(item, connection_t, link); |
return key[0] == hs->in_phone_hash; |
} |
/** Connection hash table removal callback function. |
230,8 → 238,7 |
* This function is called whenever a connection is removed from the connection |
* hash table. |
* |
* @param item Connection hash table item being removed. |
* |
* @param item Connection hash table item being removed. |
*/ |
static void conn_remove(link_t *item) |
{ |
248,24 → 255,23 |
/** Sort in current fibril's timeout request. |
* |
* @param wd Wait data of the current fibril. |
* |
* @param wd Wait data of the current fibril. |
*/ |
static void insert_timeout(awaiter_t *wd) |
{ |
wd->timedout = false; |
wd->inlist = true; |
link_t *tmp = timeout_list.next; |
link_t *tmp; |
awaiter_t *cur; |
wd->timedout = 0; |
wd->inlist = 1; |
tmp = timeout_list.next; |
while (tmp != &timeout_list) { |
awaiter_t *cur = list_get_instance(tmp, awaiter_t, link); |
cur = list_get_instance(tmp, awaiter_t, link); |
if (tv_gteq(&cur->expires, &wd->expires)) |
break; |
tmp = tmp->next; |
} |
list_append(&wd->link, tmp); |
} |
275,146 → 281,93 |
* its message queue. If the fibril was not active, it is activated and all |
* timeouts are unregistered. |
* |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
* |
* @return False if the call doesn't match any connection. |
* True if the call was passed to the respective connection fibril. |
* |
* @return Zero if the call doesn't match any connection. |
* One if the call was passed to the respective connection |
* fibril. |
*/ |
static bool route_call(ipc_callid_t callid, ipc_call_t *call) |
static int route_call(ipc_callid_t callid, ipc_call_t *call) |
{ |
connection_t *conn; |
msg_t *msg; |
link_t *hlp; |
unsigned long key; |
futex_down(&async_futex); |
unsigned long key = call->in_phone_hash; |
link_t *hlp = hash_table_find(&conn_hash_table, &key); |
key = call->in_phone_hash; |
hlp = hash_table_find(&conn_hash_table, &key); |
if (!hlp) { |
futex_up(&async_futex); |
return false; |
return 0; |
} |
connection_t *conn = hash_table_get_instance(hlp, connection_t, link); |
msg_t *msg = malloc(sizeof(*msg)); |
if (!msg) { |
futex_up(&async_futex); |
return false; |
} |
conn = hash_table_get_instance(hlp, connection_t, link); |
msg = malloc(sizeof(*msg)); |
msg->callid = callid; |
msg->call = *call; |
list_append(&msg->link, &conn->msg_queue); |
if (IPC_GET_METHOD(*call) == IPC_M_PHONE_HUNGUP) |
conn->close_callid = callid; |
/* If the connection fibril is waiting for an event, activate it */ |
if (!conn->wdata.active) { |
/* If in timeout list, remove it */ |
if (conn->wdata.inlist) { |
conn->wdata.inlist = false; |
conn->wdata.inlist = 0; |
list_remove(&conn->wdata.link); |
} |
conn->wdata.active = true; |
conn->wdata.active = 1; |
fibril_add_ready(conn->wdata.fid); |
} |
futex_up(&async_futex); |
return true; |
} |
/** Notification fibril. |
* |
* When a notification arrives, a fibril with this implementing function is |
* created. It calls interrupt_received() and does the final cleanup. |
* |
* @param arg Message structure pointer. |
* |
* @return Always zero. |
* |
*/ |
static int notification_fibril(void *arg) |
{ |
msg_t *msg = (msg_t *) arg; |
interrupt_received(msg->callid, &msg->call); |
free(msg); |
return 0; |
return 1; |
} |
/** Process interrupt notification. |
* |
* A new fibril is created which would process the notification. |
* |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
* |
* @return False if an error occured. |
* True if the call was passed to the notification fibril. |
* |
*/ |
static bool process_notification(ipc_callid_t callid, ipc_call_t *call) |
{ |
futex_down(&async_futex); |
msg_t *msg = malloc(sizeof(*msg)); |
if (!msg) { |
futex_up(&async_futex); |
return false; |
} |
msg->callid = callid; |
msg->call = *call; |
fid_t fid = fibril_create(notification_fibril, msg); |
fibril_add_ready(fid); |
futex_up(&async_futex); |
return true; |
} |
/** Return new incoming message for the current (fibril-local) connection. |
* |
* @param call Storage where the incoming call data will be stored. |
* @param usecs Timeout in microseconds. Zero denotes no timeout. |
* @param call Storage where the incoming call data will be stored. |
* @param usecs Timeout in microseconds. Zero denotes no timeout. |
* |
* @return If no timeout was specified, then a hash of the |
* incoming call is returned. If a timeout is specified, |
* then a hash of the incoming call is returned unless |
* the timeout expires prior to receiving a message. In |
* that case zero is returned. |
* |
* @return If no timeout was specified, then a hash of the |
* incoming call is returned. If a timeout is specified, |
* then a hash of the incoming call is returned unless |
* the timeout expires prior to receiving a message. In |
* that case zero is returned. |
*/ |
ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs) |
{ |
msg_t *msg; |
ipc_callid_t callid; |
connection_t *conn; |
assert(FIBRIL_connection); |
/* Why doing this? |
* GCC 4.1.0 coughs on FIBRIL_connection-> dereference. |
/* GCC 4.1.0 coughs on FIBRIL_connection-> dereference, |
* GCC 4.1.1 happilly puts the rdhwr instruction in delay slot. |
* I would never expect to find so many errors in |
* a compiler. |
* I would never expect to find so many errors in |
* a compiler *($&$(*&$ |
*/ |
connection_t *conn = FIBRIL_connection; |
conn = FIBRIL_connection; |
futex_down(&async_futex); |
if (usecs) { |
gettimeofday(&conn->wdata.expires, NULL); |
tv_add(&conn->wdata.expires, usecs); |
} else |
conn->wdata.inlist = false; |
} else { |
conn->wdata.inlist = 0; |
} |
/* If nothing in queue, wait until something arrives */ |
while (list_empty(&conn->msg_queue)) { |
if (usecs) |
insert_timeout(&conn->wdata); |
conn->wdata.active = false; |
conn->wdata.active = 0; |
/* |
* Note: the current fibril will be rescheduled either due to a |
* timeout or due to an arriving message destined to it. In the |
422,14 → 375,13 |
* case, route_call() will perform the wakeup. |
*/ |
fibril_switch(FIBRIL_TO_MANAGER); |
/* |
* Futex is up after getting back from async_manager. |
* Get it again. |
* Futex is up after getting back from async_manager get it |
* again. |
*/ |
futex_down(&async_futex); |
if ((usecs) && (conn->wdata.timedout) |
&& (list_empty(&conn->msg_queue))) { |
if (usecs && conn->wdata.timedout && |
list_empty(&conn->msg_queue)) { |
/* If we timed out -> exit */ |
futex_up(&async_futex); |
return 0; |
436,10 → 388,9 |
} |
} |
msg_t *msg = list_get_instance(conn->msg_queue.next, msg_t, link); |
msg = list_get_instance(conn->msg_queue.next, msg_t, link); |
list_remove(&msg->link); |
ipc_callid_t callid = msg->callid; |
callid = msg->callid; |
*call = msg->call; |
free(msg); |
451,9 → 402,8 |
* |
* This function is defined as a weak symbol - to be redefined in user code. |
* |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
* |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
*/ |
static void default_client_connection(ipc_callid_t callid, ipc_call_t *call) |
{ |
462,11 → 412,8 |
/** Default fibril function that gets called to handle interrupt notifications. |
* |
* This function is defined as a weak symbol - to be redefined in user code. |
* |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
* |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
*/ |
static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call) |
{ |
477,17 → 424,17 |
* When a new connection arrives, a fibril with this implementing function is |
* created. It calls client_connection() and does the final cleanup. |
* |
* @param arg Connection structure pointer. |
* @param arg Connection structure pointer. |
* |
* @return Always zero. |
* |
* @return Always zero. |
*/ |
static int connection_fibril(void *arg) |
static int connection_fibril(void *arg) |
{ |
/* |
* Setup fibril-local connection pointer and call client_connection(). |
* |
*/ |
unsigned long key; |
msg_t *msg; |
int close_answered = 0; |
/* Setup fibril-local connection pointer */ |
FIBRIL_connection = (connection_t *) arg; |
FIBRIL_connection->cfibril(FIBRIL_connection->callid, |
&FIBRIL_connection->call); |
494,20 → 441,20 |
/* Remove myself from the connection hash table */ |
futex_down(&async_futex); |
unsigned long key = FIBRIL_connection->in_phone_hash; |
key = FIBRIL_connection->in_phone_hash; |
hash_table_remove(&conn_hash_table, &key, 1); |
futex_up(&async_futex); |
/* Answer all remaining messages with EHANGUP */ |
while (!list_empty(&FIBRIL_connection->msg_queue)) { |
msg_t *msg |
= list_get_instance(FIBRIL_connection->msg_queue.next, msg_t, link); |
msg = list_get_instance(FIBRIL_connection->msg_queue.next, |
msg_t, link); |
list_remove(&msg->link); |
if (msg->callid == FIBRIL_connection->close_callid) |
close_answered = 1; |
ipc_answer_0(msg->callid, EHANGUP); |
free(msg); |
} |
if (FIBRIL_connection->close_callid) |
ipc_answer_0(FIBRIL_connection->close_callid, EOK); |
516,45 → 463,43 |
/** Create a new fibril for a new connection. |
* |
* Create new fibril for connection, fill in connection structures and inserts |
* Creates new fibril for connection, fills in connection structures and inserts |
* it into the hash table, so that later we can easily do routing of messages to |
* particular fibrils. |
* |
* @param in_phone_hash Identification of the incoming connection. |
* @param callid Hash of the opening IPC_M_CONNECT_ME_TO call. |
* If callid is zero, the connection was opened by |
* accepting the IPC_M_CONNECT_TO_ME call and this function |
* is called directly by the server. |
* @param call Call data of the opening call. |
* @param cfibril Fibril function that should be called upon opening the |
* connection. |
* @param in_phone_hash Identification of the incoming connection. |
* @param callid Hash of the opening IPC_M_CONNECT_ME_TO call. |
* If callid is zero, the connection was opened by |
* accepting the IPC_M_CONNECT_TO_ME call and this function |
* is called directly by the server. |
* @param call Call data of the opening call. |
* @param cfibril Fibril function that should be called upon opening the |
* connection. |
* |
* @return New fibril id or NULL on failure. |
* |
* @return New fibril id or NULL on failure. |
*/ |
fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid, |
ipc_call_t *call, void (*cfibril)(ipc_callid_t, ipc_call_t *)) |
{ |
connection_t *conn = malloc(sizeof(*conn)); |
connection_t *conn; |
unsigned long key; |
conn = malloc(sizeof(*conn)); |
if (!conn) { |
if (callid) |
ipc_answer_0(callid, ENOMEM); |
return NULL; |
} |
conn->in_phone_hash = in_phone_hash; |
list_initialize(&conn->msg_queue); |
conn->callid = callid; |
conn->close_callid = false; |
conn->close_callid = 0; |
if (call) |
conn->call = *call; |
conn->wdata.active = 1; /* We will activate the fibril ASAP */ |
conn->cfibril = cfibril; |
/* We will activate the fibril ASAP */ |
conn->wdata.active = true; |
conn->cfibril = cfibril; |
conn->wdata.fid = fibril_create(connection_fibril, conn); |
if (!conn->wdata.fid) { |
free(conn); |
if (callid) |
563,8 → 508,7 |
} |
/* Add connection to the connection hash table */ |
ipcarg_t key = conn->in_phone_hash; |
key = conn->in_phone_hash; |
futex_down(&async_futex); |
hash_table_insert(&conn_hash_table, &key, &conn->link); |
futex_up(&async_futex); |
579,8 → 523,8 |
* If the call has the IPC_M_CONNECT_ME_TO method, a new connection is created. |
* Otherwise the call is routed to its connection fibril. |
* |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
* @param callid Hash of the incoming call. |
* @param call Data of the incoming call. |
* |
*/ |
static void handle_call(ipc_callid_t callid, ipc_call_t *call) |
587,12 → 531,13 |
{ |
/* Unrouted call - do some default behaviour */ |
if ((callid & IPC_CALLID_NOTIFICATION)) { |
process_notification(callid, call); |
_in_interrupt_handler = 1; |
(*interrupt_received)(callid, call); |
_in_interrupt_handler = 0; |
return; |
} |
switch (IPC_GET_METHOD(*call)) { |
case IPC_M_CONNECT_ME: |
case IPC_M_CONNECT_ME_TO: |
/* Open new connection with fibril etc. */ |
async_new_connection(IPC_GET_ARG5(*call), callid, call, |
612,44 → 557,47 |
static void handle_expired_timeouts(void) |
{ |
struct timeval tv; |
awaiter_t *waiter; |
link_t *cur; |
gettimeofday(&tv, NULL); |
futex_down(&async_futex); |
link_t *cur = timeout_list.next; |
cur = timeout_list.next; |
while (cur != &timeout_list) { |
awaiter_t *waiter = list_get_instance(cur, awaiter_t, link); |
waiter = list_get_instance(cur, awaiter_t, link); |
if (tv_gt(&waiter->expires, &tv)) |
break; |
cur = cur->next; |
list_remove(&waiter->link); |
waiter->inlist = false; |
waiter->timedout = true; |
waiter->inlist = 0; |
waiter->timedout = 1; |
/* |
* Redundant condition? |
* The fibril should not be active when it gets here. |
* Redundant condition? |
* The fibril should not be active when it gets here. |
*/ |
if (!waiter->active) { |
waiter->active = true; |
waiter->active = 1; |
fibril_add_ready(waiter->fid); |
} |
} |
futex_up(&async_futex); |
} |
/** Endless loop dispatching incoming calls and answers. |
* |
* @return Never returns. |
* |
* @return Never returns. |
*/ |
static int async_manager_worker(void) |
{ |
while (true) { |
ipc_call_t call; |
ipc_callid_t callid; |
int timeout; |
awaiter_t *waiter; |
struct timeval tv; |
while (1) { |
if (fibril_switch(FIBRIL_FROM_MANAGER)) { |
futex_up(&async_futex); |
/* |
658,17 → 606,11 |
*/ |
continue; |
} |
futex_down(&async_futex); |
suseconds_t timeout; |
if (!list_empty(&timeout_list)) { |
awaiter_t *waiter |
= list_get_instance(timeout_list.next, awaiter_t, link); |
struct timeval tv; |
waiter = list_get_instance(timeout_list.next, awaiter_t, |
link); |
gettimeofday(&tv, NULL); |
if (tv_gteq(&tv, &waiter->expires)) { |
futex_up(&async_futex); |
handle_expired_timeouts(); |
677,21 → 619,19 |
timeout = tv_sub(&waiter->expires, &tv); |
} else |
timeout = SYNCH_NO_TIMEOUT; |
futex_up(&async_futex); |
ipc_call_t call; |
ipc_callid_t callid |
= ipc_wait_cycle(&call, timeout, SYNCH_FLAGS_NONE); |
callid = ipc_wait_cycle(&call, timeout, SYNCH_FLAGS_NONE); |
if (!callid) { |
handle_expired_timeouts(); |
continue; |
} |
if (callid & IPC_CALLID_ANSWERED) |
if (callid & IPC_CALLID_ANSWERED) { |
continue; |
} |
handle_call(callid, &call); |
} |
699,17 → 639,16 |
} |
/** Function to start async_manager as a standalone fibril. |
* |
* |
* When more kernel threads are used, one async manager should exist per thread. |
* |
* @param arg Unused. |
* @return Never returns. |
* @param arg Unused. |
* |
* @return Never returns. |
*/ |
static int async_manager_fibril(void *arg) |
{ |
futex_up(&async_futex); |
/* |
* async_futex is always locked when entering manager |
*/ |
721,7 → 660,9 |
/** Add one manager to manager list. */ |
void async_create_manager(void) |
{ |
fid_t fid = fibril_create(async_manager_fibril, NULL); |
fid_t fid; |
fid = fibril_create(async_manager_fibril, NULL); |
fibril_add_manager(fid); |
} |
733,7 → 674,7 |
/** Initialize the async framework. |
* |
* @return Zero on success or an error code. |
* @return Zero on success or an error code. |
*/ |
int _async_init(void) |
{ |
753,33 → 694,30 |
* |
* Notify the fibril which is waiting for this message that it has arrived. |
* |
* @param arg Pointer to the asynchronous message record. |
* @param retval Value returned in the answer. |
* @param data Call data of the answer. |
* @param private Pointer to the asynchronous message record. |
* @param retval Value returned in the answer. |
* @param data Call data of the answer. |
*/ |
static void reply_received(void *arg, int retval, ipc_call_t *data) |
static void reply_received(void *private, int retval, ipc_call_t *data) |
{ |
amsg_t *msg = (amsg_t *) arg; |
amsg_t *msg = (amsg_t *) private; |
msg->retval = retval; |
futex_down(&async_futex); |
/* Copy data after futex_down, just in case the call was detached */ |
if (msg->dataptr) |
*msg->dataptr = *data; |
*msg->dataptr = *data; |
write_barrier(); |
/* Remove message from timeout list */ |
if (msg->wdata.inlist) |
list_remove(&msg->wdata.link); |
msg->done = true; |
msg->done = 1; |
if (!msg->wdata.active) { |
msg->wdata.active = true; |
msg->wdata.active = 1; |
fibril_add_ready(msg->wdata.fid); |
} |
futex_up(&async_futex); |
} |
788,35 → 726,31 |
* The return value can be used as input for async_wait() to wait for |
* completion. |
* |
* @param phoneid Handle of the phone that will be used for the send. |
* @param method Service-defined method. |
* @param arg1 Service-defined payload argument. |
* @param arg2 Service-defined payload argument. |
* @param arg3 Service-defined payload argument. |
* @param arg4 Service-defined payload argument. |
* @param dataptr If non-NULL, storage where the reply data will be |
* stored. |
* @param phoneid Handle of the phone that will be used for the send. |
* @param method Service-defined method. |
* @param arg1 Service-defined payload argument. |
* @param arg2 Service-defined payload argument. |
* @param arg3 Service-defined payload argument. |
* @param arg4 Service-defined payload argument. |
* @param dataptr If non-NULL, storage where the reply data will be |
* stored. |
* |
* @return Hash of the sent message or 0 on error. |
* |
* @return Hash of the sent message. |
*/ |
aid_t async_send_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, |
ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr) |
{ |
amsg_t *msg = malloc(sizeof(*msg)); |
amsg_t *msg; |
if (!msg) |
return 0; |
msg->done = false; |
msg = malloc(sizeof(*msg)); |
msg->done = 0; |
msg->dataptr = dataptr; |
msg->wdata.inlist = false; |
/* We may sleep in the next method, but it will use its own mechanism */ |
msg->wdata.active = true; |
msg->wdata.active = 1; |
ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, msg, |
reply_received, true); |
reply_received, !_in_interrupt_handler); |
return (aid_t) msg; |
} |
826,37 → 760,33 |
* The return value can be used as input for async_wait() to wait for |
* completion. |
* |
* @param phoneid Handle of the phone that will be used for the send. |
* @param method Service-defined method. |
* @param arg1 Service-defined payload argument. |
* @param arg2 Service-defined payload argument. |
* @param arg3 Service-defined payload argument. |
* @param arg4 Service-defined payload argument. |
* @param arg5 Service-defined payload argument. |
* @param dataptr If non-NULL, storage where the reply data will be |
* stored. |
* @param phoneid Handle of the phone that will be used for the send. |
* @param method Service-defined method. |
* @param arg1 Service-defined payload argument. |
* @param arg2 Service-defined payload argument. |
* @param arg3 Service-defined payload argument. |
* @param arg4 Service-defined payload argument. |
* @param arg5 Service-defined payload argument. |
* @param dataptr If non-NULL, storage where the reply data will be |
* stored. |
* |
* @return Hash of the sent message or 0 on error. |
* |
* @return Hash of the sent message. |
*/ |
aid_t async_send_slow(int phoneid, ipcarg_t method, ipcarg_t arg1, |
ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, |
ipc_call_t *dataptr) |
{ |
amsg_t *msg = malloc(sizeof(*msg)); |
amsg_t *msg; |
if (!msg) |
return 0; |
msg->done = false; |
msg = malloc(sizeof(*msg)); |
msg->done = 0; |
msg->dataptr = dataptr; |
msg->wdata.inlist = false; |
/* We may sleep in next method, but it will use its own mechanism */ |
msg->wdata.active = true; |
msg->wdata.active = 1; |
ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, msg, |
reply_received, true); |
reply_received, !_in_interrupt_handler); |
return (aid_t) msg; |
} |
863,82 → 793,74 |
/** Wait for a message sent by the async framework. |
* |
* @param amsgid Hash of the message to wait for. |
* @param retval Pointer to storage where the retval of the answer will |
* be stored. |
* |
* @param amsgid Hash of the message to wait for. |
* @param retval Pointer to storage where the retval of the answer will |
* be stored. |
*/ |
void async_wait_for(aid_t amsgid, ipcarg_t *retval) |
{ |
amsg_t *msg = (amsg_t *) amsgid; |
futex_down(&async_futex); |
if (msg->done) { |
futex_up(&async_futex); |
goto done; |
} |
msg->wdata.fid = fibril_get_id(); |
msg->wdata.active = false; |
msg->wdata.inlist = false; |
msg->wdata.active = 0; |
msg->wdata.inlist = 0; |
/* Leave the async_futex locked when entering this function */ |
fibril_switch(FIBRIL_TO_MANAGER); |
/* Futex is up automatically after fibril_switch */ |
/* futex is up automatically after fibril_switch...*/ |
done: |
if (retval) |
*retval = msg->retval; |
free(msg); |
} |
/** Wait for a message sent by the async framework, timeout variant. |
* |
* @param amsgid Hash of the message to wait for. |
* @param retval Pointer to storage where the retval of the answer will |
* be stored. |
* @param timeout Timeout in microseconds. |
* @param amsgid Hash of the message to wait for. |
* @param retval Pointer to storage where the retval of the answer will |
* be stored. |
* @param timeout Timeout in microseconds. |
* |
* @return Zero on success, ETIMEOUT if the timeout has expired. |
* |
* @return Zero on success, ETIMEOUT if the timeout has expired. |
*/ |
int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout) |
{ |
amsg_t *msg = (amsg_t *) amsgid; |
/* TODO: Let it go through the event read at least once */ |
if (timeout < 0) |
return ETIMEOUT; |
futex_down(&async_futex); |
if (msg->done) { |
futex_up(&async_futex); |
goto done; |
} |
gettimeofday(&msg->wdata.expires, NULL); |
tv_add(&msg->wdata.expires, timeout); |
msg->wdata.fid = fibril_get_id(); |
msg->wdata.active = false; |
msg->wdata.active = 0; |
insert_timeout(&msg->wdata); |
/* Leave the async_futex locked when entering this function */ |
fibril_switch(FIBRIL_TO_MANAGER); |
/* Futex is up automatically after fibril_switch */ |
/* futex is up automatically after fibril_switch...*/ |
if (!msg->done) |
return ETIMEOUT; |
done: |
if (retval) |
*retval = msg->retval; |
free(msg); |
return 0; |
} |
946,38 → 868,33 |
* |
* The current fibril is suspended but the thread continues to execute. |
* |
* @param timeout Duration of the wait in microseconds. |
* |
* @param timeout Duration of the wait in microseconds. |
*/ |
void async_usleep(suseconds_t timeout) |
{ |
amsg_t *msg = malloc(sizeof(*msg)); |
amsg_t *msg; |
msg = malloc(sizeof(*msg)); |
if (!msg) |
return; |
msg->wdata.fid = fibril_get_id(); |
msg->wdata.active = false; |
msg->wdata.active = 0; |
gettimeofday(&msg->wdata.expires, NULL); |
tv_add(&msg->wdata.expires, timeout); |
futex_down(&async_futex); |
insert_timeout(&msg->wdata); |
/* Leave the async_futex locked when entering this function */ |
fibril_switch(FIBRIL_TO_MANAGER); |
/* Futex is up automatically after fibril_switch() */ |
/* futex is up automatically after fibril_switch()...*/ |
free(msg); |
} |
/** Setter for client_connection function pointer. |
* |
* @param conn Function that will implement a new connection fibril. |
* |
* @param conn Function that will implement a new connection fibril. |
*/ |
void async_set_client_connection(async_client_conn_t conn) |
{ |
986,12 → 903,12 |
/** Setter for interrupt_received function pointer. |
* |
* @param intr Function that will implement a new interrupt |
* notification fibril. |
* @param conn Function that will implement a new interrupt |
* notification fibril. |
*/ |
void async_set_interrupt_received(async_client_conn_t intr) |
void async_set_interrupt_received(async_client_conn_t conn) |
{ |
interrupt_received = intr; |
interrupt_received = conn; |
} |
/** Pseudo-synchronous message sending - fast version. |
1001,20 → 918,18 |
* This function can only transfer 4 register payload arguments. For |
* transferring more arguments, see the slower async_req_slow(). |
* |
* @param phoneid Hash of the phone through which to make the call. |
* @param method Method of the call. |
* @param arg1 Service-defined payload argument. |
* @param arg2 Service-defined payload argument. |
* @param arg3 Service-defined payload argument. |
* @param arg4 Service-defined payload argument. |
* @param r1 If non-NULL, storage for the 1st reply argument. |
* @param r2 If non-NULL, storage for the 2nd reply argument. |
* @param r3 If non-NULL, storage for the 3rd reply argument. |
* @param r4 If non-NULL, storage for the 4th reply argument. |
* @param r5 If non-NULL, storage for the 5th reply argument. |
* |
* @return Return code of the reply or a negative error code. |
* |
* @param phoneid Hash of the phone through which to make the call. |
* @param method Method of the call. |
* @param arg1 Service-defined payload argument. |
* @param arg2 Service-defined payload argument. |
* @param arg3 Service-defined payload argument. |
* @param arg4 Service-defined payload argument. |
* @param r1 If non-NULL, storage for the 1st reply argument. |
* @param r2 If non-NULL, storage for the 2nd reply argument. |
* @param r3 If non-NULL, storage for the 3rd reply argument. |
* @param r4 If non-NULL, storage for the 4th reply argument. |
* @param r5 If non-NULL, storage for the 5th reply argument. |
* @return Return code of the reply or a negative error code. |
*/ |
ipcarg_t async_req_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, |
ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t *r1, ipcarg_t *r2, |
1021,27 → 936,21 |
ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5) |
{ |
ipc_call_t result; |
ipcarg_t rc; |
aid_t eid = async_send_4(phoneid, method, arg1, arg2, arg3, arg4, |
&result); |
ipcarg_t rc; |
async_wait_for(eid, &rc); |
if (r1) |
if (r1) |
*r1 = IPC_GET_ARG1(result); |
if (r2) |
*r2 = IPC_GET_ARG2(result); |
if (r3) |
*r3 = IPC_GET_ARG3(result); |
if (r4) |
*r4 = IPC_GET_ARG4(result); |
if (r5) |
*r5 = IPC_GET_ARG5(result); |
return rc; |
} |
1049,21 → 958,19 |
* |
* Send message asynchronously and return only after the reply arrives. |
* |
* @param phoneid Hash of the phone through which to make the call. |
* @param method Method of the call. |
* @param arg1 Service-defined payload argument. |
* @param arg2 Service-defined payload argument. |
* @param arg3 Service-defined payload argument. |
* @param arg4 Service-defined payload argument. |
* @param arg5 Service-defined payload argument. |
* @param r1 If non-NULL, storage for the 1st reply argument. |
* @param r2 If non-NULL, storage for the 2nd reply argument. |
* @param r3 If non-NULL, storage for the 3rd reply argument. |
* @param r4 If non-NULL, storage for the 4th reply argument. |
* @param r5 If non-NULL, storage for the 5th reply argument. |
* |
* @return Return code of the reply or a negative error code. |
* |
* @param phoneid Hash of the phone through which to make the call. |
* @param method Method of the call. |
* @param arg1 Service-defined payload argument. |
* @param arg2 Service-defined payload argument. |
* @param arg3 Service-defined payload argument. |
* @param arg4 Service-defined payload argument. |
* @param arg5 Service-defined payload argument. |
* @param r1 If non-NULL, storage for the 1st reply argument. |
* @param r2 If non-NULL, storage for the 2nd reply argument. |
* @param r3 If non-NULL, storage for the 3rd reply argument. |
* @param r4 If non-NULL, storage for the 4th reply argument. |
* @param r5 If non-NULL, storage for the 5th reply argument. |
* @return Return code of the reply or a negative error code. |
*/ |
ipcarg_t async_req_slow(int phoneid, ipcarg_t method, ipcarg_t arg1, |
ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *r1, |
1070,27 → 977,21 |
ipcarg_t *r2, ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5) |
{ |
ipc_call_t result; |
ipcarg_t rc; |
aid_t eid = async_send_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, |
&result); |
ipcarg_t rc; |
async_wait_for(eid, &rc); |
if (r1) |
if (r1) |
*r1 = IPC_GET_ARG1(result); |
if (r2) |
*r2 = IPC_GET_ARG2(result); |
if (r3) |
*r3 = IPC_GET_ARG3(result); |
if (r4) |
*r4 = IPC_GET_ARG4(result); |
if (r5) |
*r5 = IPC_GET_ARG5(result); |
return rc; |
} |
/branches/dd/uspace/lib/libc/generic/libadt/list.c |
---|
48,12 → 48,12 |
*/ |
int list_member(const link_t *link, const link_t *head) |
{ |
int found = 0; |
int found = false; |
link_t *hlp = head->next; |
while (hlp != head) { |
if (hlp == link) { |
found = 1; |
found = true; |
break; |
} |
hlp = hlp->next; |
77,36 → 77,13 |
{ |
if (list_empty(head2)) |
return; |
head2->next->prev = head1->prev; |
head2->prev->next = head1; |
head2->prev->next = head1; |
head1->prev->next = head2->next; |
head1->prev = head2->prev; |
list_initialize(head2); |
} |
/** Count list items |
* |
* Return the number of items in the list. |
* |
* @param link List to count. |
* |
* @return Number of items in the list. |
* |
*/ |
unsigned int list_count(const link_t *link) |
{ |
unsigned int count = 0; |
link_t *hlp = link->next; |
while (hlp != link) { |
count++; |
hlp = hlp->next; |
} |
return count; |
} |
/** @} |
*/ |
/branches/dd/uspace/lib/libc/Makefile |
---|
47,7 → 47,6 |
generic/as.c \ |
generic/cap.c \ |
generic/console.c \ |
generic/devmap.c \ |
generic/event.c \ |
generic/mem.c \ |
generic/string.c \ |
/branches/dd/uspace/lib/libfs/libfs.c |
---|
1,5 → 1,5 |
/* |
* Copyright (c) 2009 Jakub Jermar |
* Copyright (c) 2008 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
122,85 → 122,6 |
return IPC_GET_RETVAL(answer); |
} |
void fs_node_initialize(fs_node_t *fn) |
{ |
memset(fn, 0, sizeof(fs_node_t)); |
} |
void libfs_mount(libfs_ops_t *ops, 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); |
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); |
int res; |
ipcarg_t rc; |
ipc_call_t call; |
ipc_callid_t callid; |
/* accept the phone */ |
callid = async_get_call(&call); |
int mountee_phone = (int)IPC_GET_ARG1(call); |
if ((IPC_GET_METHOD(call) != IPC_M_CONNECTION_CLONE) || |
mountee_phone < 0) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
} |
ipc_answer_0(callid, EOK); /* acknowledge the mountee_phone */ |
res = ipc_data_write_receive(&callid, NULL); |
if (!res) { |
ipc_hangup(mountee_phone); |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
return; |
} |
fs_node_t *fn = ops->node_get(mp_dev_handle, mp_fs_index); |
if (!fn) { |
ipc_hangup(mountee_phone); |
ipc_answer_0(callid, ENOENT); |
ipc_answer_0(rid, ENOENT); |
return; |
} |
if (fn->mp_data.mp_active) { |
ipc_hangup(mountee_phone); |
ops->node_put(fn); |
ipc_answer_0(callid, EBUSY); |
ipc_answer_0(rid, EBUSY); |
return; |
} |
rc = async_req_0_0(mountee_phone, IPC_M_CONNECT_ME); |
if (rc != 0) { |
ipc_hangup(mountee_phone); |
ops->node_put(fn); |
ipc_answer_0(callid, rc); |
ipc_answer_0(rid, rc); |
return; |
} |
ipc_call_t answer; |
aid_t msg = async_send_1(mountee_phone, VFS_MOUNTED, mr_dev_handle, |
&answer); |
ipc_forward_fast(callid, mountee_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); |
async_wait_for(msg, &rc); |
if (rc == EOK) { |
fn->mp_data.mp_active = true; |
fn->mp_data.fs_handle = mr_fs_handle; |
fn->mp_data.dev_handle = mr_dev_handle; |
fn->mp_data.phone = mountee_phone; |
} |
/* |
* Do not release the FS node so that it stays in memory. |
*/ |
ipc_answer_0(rid, rc); |
} |
/** Lookup VFS triplet by name in the file system name space. |
* |
* The path passed in the PLB must be in the canonical file system path format |
216,9 → 137,8 |
void libfs_lookup(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid, |
ipc_call_t *request) |
{ |
unsigned first = IPC_GET_ARG1(*request); |
unsigned next = IPC_GET_ARG1(*request); |
unsigned last = IPC_GET_ARG2(*request); |
unsigned next = first; |
dev_handle_t dev_handle = IPC_GET_ARG3(*request); |
int lflag = IPC_GET_ARG4(*request); |
fs_index_t index = IPC_GET_ARG5(*request); /* when L_LINK specified */ |
228,18 → 148,10 |
if (last < next) |
last += PLB_SIZE; |
fs_node_t *par = NULL; |
fs_node_t *cur = ops->root_get(dev_handle); |
fs_node_t *tmp = NULL; |
void *par = NULL; |
void *cur = ops->root_get(dev_handle); |
void *tmp = NULL; |
if (cur->mp_data.mp_active) { |
ipc_forward_slow(rid, cur->mp_data.phone, VFS_LOOKUP, |
next, last, cur->mp_data.dev_handle, lflag, index, |
IPC_FF_ROUTE_FROM_ME); |
ops->node_put(cur); |
return; |
} |
if (ops->plb_get_char(next) == '/') |
next++; /* eat slash */ |
262,21 → 174,6 |
/* match the component */ |
tmp = ops->match(cur, component); |
if (tmp && tmp->mp_data.mp_active) { |
if (next > last) |
next = last = first; |
else |
next--; |
ipc_forward_slow(rid, tmp->mp_data.phone, VFS_LOOKUP, |
next, last, tmp->mp_data.dev_handle, lflag, index, |
IPC_FF_ROUTE_FROM_ME); |
ops->node_put(cur); |
ops->node_put(tmp); |
if (par) |
ops->node_put(par); |
return; |
} |
/* handle miss: match amongst siblings */ |
if (!tmp) { |
292,33 → 189,39 |
ipc_answer_0(rid, ENOTDIR); |
goto out; |
} |
fs_node_t *fn; |
void *nodep; |
if (lflag & L_CREATE) |
fn = ops->create(dev_handle, lflag); |
nodep = ops->create(dev_handle, lflag); |
else |
fn = ops->node_get(dev_handle, |
nodep = ops->node_get(dev_handle, |
index); |
if (fn) { |
if (nodep) { |
int rc; |
rc = ops->link(cur, fn, component); |
rc = ops->link(cur, nodep, component); |
if (rc != EOK) { |
if (lflag & L_CREATE) { |
(void)ops->destroy(fn); |
(void)ops->destroy( |
nodep); |
} |
ipc_answer_0(rid, rc); |
} else { |
ipc_answer_5(rid, EOK, |
fs_handle, dev_handle, |
ops->index_get(fn), |
ops->size_get(fn), |
ops->lnkcnt_get(fn)); |
ops->node_put(fn); |
ops->index_get(nodep), |
ops->size_get(nodep), |
ops->lnkcnt_get(nodep)); |
ops->node_put(nodep); |
} |
} else { |
ipc_answer_0(rid, ENOSPC); |
} |
goto out; |
} else if (lflag & L_PARENT) { |
/* return parent */ |
ipc_answer_5(rid, EOK, fs_handle, dev_handle, |
ops->index_get(cur), ops->size_get(cur), |
ops->lnkcnt_get(cur)); |
} |
ipc_answer_0(rid, ENOENT); |
goto out; |
360,26 → 263,26 |
assert(len); |
component[len] = '\0'; |
fs_node_t *fn; |
void *nodep; |
if (lflag & L_CREATE) |
fn = ops->create(dev_handle, lflag); |
nodep = ops->create(dev_handle, lflag); |
else |
fn = ops->node_get(dev_handle, index); |
if (fn) { |
nodep = ops->node_get(dev_handle, index); |
if (nodep) { |
int rc; |
rc = ops->link(cur, fn, component); |
rc = ops->link(cur, nodep, component); |
if (rc != EOK) { |
if (lflag & L_CREATE) |
(void)ops->destroy(fn); |
(void)ops->destroy(nodep); |
ipc_answer_0(rid, rc); |
} else { |
ipc_answer_5(rid, EOK, |
fs_handle, dev_handle, |
ops->index_get(fn), |
ops->size_get(fn), |
ops->lnkcnt_get(fn)); |
ops->node_put(fn); |
ops->index_get(nodep), |
ops->size_get(nodep), |
ops->lnkcnt_get(nodep)); |
ops->node_put(nodep); |
} |
} else { |
ipc_answer_0(rid, ENOSPC); |
391,9 → 294,18 |
} |
/* handle hit */ |
if (lflag & L_PARENT) { |
ops->node_put(cur); |
cur = par; |
par = NULL; |
if (!cur) { |
ipc_answer_0(rid, ENOENT); |
goto out; |
} |
} |
if (lflag & L_UNLINK) { |
unsigned old_lnkcnt = ops->lnkcnt_get(cur); |
int res = ops->unlink(par, cur, component); |
int res = ops->unlink(par, cur); |
ipc_answer_5(rid, (ipcarg_t)res, fs_handle, dev_handle, |
ops->index_get(cur), ops->size_get(cur), old_lnkcnt); |
goto out; |
/branches/dd/uspace/lib/libfs/libfs.h |
---|
1,5 → 1,5 |
/* |
* Copyright (c) 2009 Jakub Jermar |
* Copyright (c) 2007 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
42,33 → 42,21 |
#include <async.h> |
typedef struct { |
bool mp_active; |
int phone; |
fs_handle_t fs_handle; |
dev_handle_t dev_handle; |
} mp_data_t; |
typedef struct { |
mp_data_t mp_data; /**< Mount point info. */ |
void *data; /**< Data of the file system implementation. */ |
} fs_node_t; |
typedef struct { |
fs_node_t * (* match)(fs_node_t *, const char *); |
fs_node_t * (* node_get)(dev_handle_t, fs_index_t); |
void (* node_put)(fs_node_t *); |
fs_node_t * (* create)(dev_handle_t, int); |
int (* destroy)(fs_node_t *); |
int (* link)(fs_node_t *, fs_node_t *, const char *); |
int (* unlink)(fs_node_t *, fs_node_t *, const char *); |
fs_index_t (* index_get)(fs_node_t *); |
size_t (* size_get)(fs_node_t *); |
unsigned (* lnkcnt_get)(fs_node_t *); |
bool (* has_children)(fs_node_t *); |
fs_node_t *(* root_get)(dev_handle_t); |
void * (* match)(void *, const char *); |
void * (* node_get)(dev_handle_t, fs_index_t); |
void (* node_put)(void *); |
void * (* create)(dev_handle_t, int); |
int (* destroy)(void *); |
int (* link)(void *, void *, const char *); |
int (* unlink)(void *, void *); |
fs_index_t (* index_get)(void *); |
size_t (* size_get)(void *); |
unsigned (* lnkcnt_get)(void *); |
bool (* has_children)(void *); |
void *(* root_get)(dev_handle_t); |
char (* plb_get_char)(unsigned pos); |
bool (* is_directory)(fs_node_t *); |
bool (* is_file)(fs_node_t *); |
bool (* is_directory)(void *); |
bool (* is_file)(void *); |
} libfs_ops_t; |
typedef struct { |
79,9 → 67,6 |
extern int fs_register(int, fs_reg_t *, vfs_info_t *, async_client_conn_t); |
extern void fs_node_initialize(fs_node_t *); |
extern void libfs_mount(libfs_ops_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 |
---|
37,8 → 37,8 |
#include "libblock.h" |
#include "../../srv/vfs/vfs.h" |
#include "../../srv/rd/rd.h" |
#include <ipc/devmap.h> |
#include <ipc/bd.h> |
#include <ipc/services.h> |
#include <errno.h> |
#include <sys/mman.h> |
146,8 → 146,9 |
if (!com_area) { |
return ENOMEM; |
} |
dev_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, |
DEVMAP_CONNECT_TO_DEVICE, dev_handle); |
dev_phone = devmap_device_connect(dev_handle, IPC_FLAG_BLOCKING); |
if (dev_phone < 0) { |
munmap(com_area, com_size); |
return dev_phone; |
476,7 → 477,7 |
if (*bufpos == *buflen) { |
/* Refill the communication buffer with a new block. */ |
ipcarg_t retval; |
int rc = async_req_2_1(devcon->dev_phone, BD_READ_BLOCK, |
int rc = async_req_2_1(devcon->dev_phone, RD_READ_BLOCK, |
*pos / block_size, block_size, &retval); |
if ((rc != EOK) || (retval != EOK)) |
return (rc != EOK ? rc : retval); |
/branches/dd/uspace/Makefile |
---|
37,7 → 37,6 |
lib/libblock \ |
lib/softint \ |
lib/softfloat \ |
srv/bd/gxe_bd \ |
srv/ns \ |
srv/loader \ |
srv/fb \ |
46,7 → 45,6 |
srv/rd \ |
srv/fs/fat \ |
srv/fs/tmpfs \ |
srv/fs/devfs \ |
srv/vfs \ |
srv/devmap \ |
app/tetris \ |
/branches/dd/kernel/arch/amd64/include/atomic.h |
---|
115,7 → 115,9 |
preemption_disable(); |
asm volatile ( |
"0:\n" |
#ifdef CONFIG_HT |
"pause\n" |
#endif |
"mov %[count], %[tmp]\n" |
"testq %[tmp], %[tmp]\n" |
"jnz 0b\n" /* lightweight looping on locked spinlock */ |
/branches/dd/kernel/arch/amd64/src/amd64.c |
---|
197,15 → 197,10 |
* Initialize the i8042 controller. Then initialize the keyboard |
* module and connect it to i8042. Enable keyboard interrupts. |
*/ |
i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); |
if (i8042_instance) { |
kbrd_instance_t *kbrd_instance = kbrd_init(); |
if (kbrd_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *kbrd = kbrd_wire(kbrd_instance, sink); |
i8042_wire(i8042_instance, kbrd); |
trap_virtual_enable_irqs(1 << IRQ_KBD); |
} |
indev_t *kbrdin = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); |
if (kbrdin) { |
kbrd_init(kbrdin); |
trap_virtual_enable_irqs(1 << IRQ_KBD); |
} |
/* |
/branches/dd/kernel/arch/sparc64/include/trap/trap_table.h |
---|
100,7 → 100,7 |
.macro PREEMPTIBLE_HANDLER f |
sethi %hi(\f), %g1 |
ba %xcc, preemptible_handler |
b preemptible_handler |
or %g1, %lo(\f), %g1 |
.endm |
/branches/dd/kernel/arch/sparc64/include/drivers/sgcn.h |
---|
37,7 → 37,6 |
#include <arch/types.h> |
#include <console/chardev.h> |
#include <proc/thread.h> |
/* number of bytes in the TOC magic, including the NULL-terminator */ |
#define TOC_MAGIC_BYTES 8 |
117,17 → 116,11 |
uint32_t out_wrptr; |
} __attribute__ ((packed)) sgcn_buffer_header_t; |
typedef struct { |
thread_t *thread; |
indev_t *srlnin; |
} sgcn_instance_t; |
void sgcn_grab(void); |
void sgcn_release(void); |
indev_t *sgcnin_init(void); |
void sgcnout_init(void); |
extern void sgcn_grab(void); |
extern void sgcn_release(void); |
extern sgcn_instance_t *sgcnin_init(void); |
extern void sgcnin_wire(sgcn_instance_t *, indev_t *); |
extern void sgcnout_init(void); |
#endif |
/** @} |
/branches/dd/kernel/arch/sparc64/include/drivers/kbd.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup sparc64 |
/** @addtogroup sparc64 |
* @{ |
*/ |
/** @file |
38,6 → 38,15 |
#include <arch/types.h> |
#include <genarch/ofw/ofw_tree.h> |
typedef enum { |
KBD_UNKNOWN, |
KBD_Z8530, |
KBD_NS16550, |
KBD_SGCN |
} kbd_type_t; |
extern kbd_type_t kbd_type; |
extern void kbd_init(ofw_tree_node_t *node); |
#endif |
/branches/dd/kernel/arch/sparc64/include/atomic.h |
---|
123,7 → 123,7 |
"ldx %0, %2\n" |
"brz %2, 0b\n" |
"nop\n" |
"ba %xcc, 1b\n" |
"ba 1b\n" |
"nop\n" |
"2:\n" |
: "+m" (*((uint64_t *) x)), "+r" (tmp1), "+r" (tmp2) : "r" (0) |
/branches/dd/kernel/arch/sparc64/src/console.c |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup sparc64 |
/** @addtogroup sparc64 |
* @{ |
*/ |
/** @file |
92,15 → 92,10 |
static void serengeti_init(void) |
{ |
#ifdef CONFIG_SGCN_KBD |
sgcn_instance_t *sgcn_instance = sgcnin_init(); |
if (sgcn_instance) { |
srln_instance_t *srln_instance = srln_init(); |
if (srln_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *srln = srln_wire(srln_instance, sink); |
sgcnin_wire(sgcn_instance, srln); |
} |
} |
indev_t *kbrdin; |
kbrdin = sgcnin_init(); |
if (kbrdin) |
srln_init(kbrdin); |
#endif |
#ifdef CONFIG_SGCN_PRN |
sgcnout_init(); |
140,9 → 135,15 |
scr_redraw(); |
#endif |
switch (kbd_type) { |
#ifdef CONFIG_SGCN_KBD |
sgcn_grab(); |
case KBD_SGCN: |
sgcn_grab(); |
break; |
#endif |
default: |
break; |
} |
} |
/** Return console to userspace |
150,9 → 151,15 |
*/ |
void arch_release_console(void) |
{ |
switch (kbd_type) { |
#ifdef CONFIG_SGCN_KBD |
sgcn_release(); |
case KBD_SGCN: |
sgcn_release(); |
break; |
#endif |
default: |
break; |
} |
} |
/** @} |
/branches/dd/kernel/arch/sparc64/src/trap/trap_table.S |
---|
341,7 → 341,7 |
.org trap_table + (TT_TRAP_INSTRUCTION_0+\cur)*ENTRY_SIZE |
.global trap_instruction_\cur\()_tl0 |
trap_instruction_\cur\()_tl0: |
ba %xcc, trap_instruction_handler |
ba trap_instruction_handler |
mov \cur, %g2 |
.endr |
480,7 → 480,7 |
cmp %g3, 1 |
be %xcc, 1f |
nop |
0: ba %xcc, 0b ! this is for debugging, if we ever get here |
0: ba 0b ! this is for debugging, if we ever get here |
nop ! it will be easy to find |
1: |
545,7 → 545,7 |
flush %l0 |
.if NOT(\is_syscall) |
ba %xcc, 1f |
ba 1f |
nop |
0: |
save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp |
774,7 → 774,7 |
and %g3, NWINDOWS - 1, %g3 |
wrpr %g3, 0, %cwp ! switch to the preceeding window |
ba %xcc, 0b |
ba 0b |
inc %g4 |
0: |
/branches/dd/kernel/arch/sparc64/src/mm/tlb.c |
---|
497,7 → 497,38 |
dtlb_sfsr_write(0); |
} |
#if defined (US) |
#if defined (US3) |
/** Invalidates given TLB entry if and only if it is non-locked or global. |
* |
* @param tlb TLB number (one of TLB_DSMALL, TLB_DBIG_0, TLB_DBIG_1, |
* TLB_ISMALL, TLB_IBIG). |
* @param entry Entry index within the given TLB. |
*/ |
static void tlb_invalidate_entry(int tlb, index_t entry) |
{ |
tlb_data_t d; |
tlb_tag_read_reg_t t; |
if (tlb == TLB_DSMALL || tlb == TLB_DBIG_0 || tlb == TLB_DBIG_1) { |
d.value = dtlb_data_access_read(tlb, entry); |
if (!d.l || d.g) { |
t.value = dtlb_tag_read_read(tlb, entry); |
d.v = false; |
dtlb_tag_access_write(t.value); |
dtlb_data_access_write(tlb, entry, d.value); |
} |
} else if (tlb == TLB_ISMALL || tlb == TLB_IBIG) { |
d.value = itlb_data_access_read(tlb, entry); |
if (!d.l || d.g) { |
t.value = itlb_tag_read_read(tlb, entry); |
d.v = false; |
itlb_tag_access_write(t.value); |
itlb_data_access_write(tlb, entry, d.value); |
} |
} |
} |
#endif |
/** Invalidate all unlocked ITLB and DTLB entries. */ |
void tlb_invalidate_all(void) |
{ |
512,6 → 543,7 |
* be safe to invalidate them as late as now. |
*/ |
#if defined (US) |
tlb_data_t d; |
tlb_tag_read_reg_t t; |
535,19 → 567,22 |
} |
} |
} |
#elif defined (US3) |
/** Invalidate all unlocked ITLB and DTLB entries. */ |
void tlb_invalidate_all(void) |
{ |
itlb_demap(TLB_DEMAP_ALL, 0, 0); |
dtlb_demap(TLB_DEMAP_ALL, 0, 0); |
for (i = 0; i < tlb_ismall_size(); i++) |
tlb_invalidate_entry(TLB_ISMALL, i); |
for (i = 0; i < tlb_ibig_size(); i++) |
tlb_invalidate_entry(TLB_IBIG, i); |
for (i = 0; i < tlb_dsmall_size(); i++) |
tlb_invalidate_entry(TLB_DSMALL, i); |
for (i = 0; i < tlb_dbig_size(); i++) |
tlb_invalidate_entry(TLB_DBIG_0, i); |
for (i = 0; i < tlb_dbig_size(); i++) |
tlb_invalidate_entry(TLB_DBIG_1, i); |
#endif |
} |
#endif |
/** Invalidate all ITLB and DTLB entries that belong to specified ASID |
* (Context). |
* |
/branches/dd/kernel/arch/sparc64/src/drivers/kbd.c |
---|
54,140 → 54,100 |
#include <print.h> |
#include <sysinfo/sysinfo.h> |
kbd_type_t kbd_type = KBD_UNKNOWN; |
#ifdef CONFIG_SUN_KBD |
#ifdef CONFIG_Z8530 |
static bool kbd_z8530_init(ofw_tree_node_t *node) |
/** Initialize keyboard. |
* |
* Traverse OpenFirmware device tree in order to find necessary |
* info about the keyboard device. |
* |
* @param node Keyboard device node. |
*/ |
void kbd_init(ofw_tree_node_t *node) |
{ |
const char *name = ofw_tree_node_name(node); |
if (str_cmp(name, "zs") != 0) |
return false; |
/* |
* Read 'interrupts' property. |
*/ |
ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts"); |
if ((!prop) || (!prop->value)) { |
printf("z8530: Unable to find interrupts property\n"); |
return false; |
} |
uint32_t interrupts = *((uint32_t *) prop->value); |
/* |
* Read 'reg' property. |
*/ |
prop = ofw_tree_getprop(node, "reg"); |
if ((!prop) || (!prop->value)) { |
printf("z8530: Unable to find reg property\n"); |
return false; |
} |
size_t size = ((ofw_fhc_reg_t *) prop->value)->size; |
uintptr_t pa; |
if (!ofw_fhc_apply_ranges(node->parent, |
((ofw_fhc_reg_t *) prop->value), &pa)) { |
printf("z8530: Failed to determine address\n"); |
return false; |
} |
inr_t inr; |
size_t offset; |
uintptr_t aligned_addr; |
ofw_tree_property_t *prop; |
const char *name; |
cir_t cir; |
void *cir_arg; |
if (!ofw_fhc_map_interrupt(node->parent, |
((ofw_fhc_reg_t *) prop->value), interrupts, &inr, &cir, |
&cir_arg)) { |
printf("z8530: Failed to determine interrupt\n"); |
return false; |
} |
/* |
* We need to pass aligned address to hw_map(). |
* However, the physical keyboard address can |
* be pretty much unaligned, depending on the |
* underlying controller. |
*/ |
uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); |
size_t offset = pa - aligned_addr; |
#ifdef CONFIG_NS16550 |
ns16550_t *ns16550; |
#endif |
#ifdef CONFIG_Z8530 |
z8530_t *z8530; |
#endif |
z8530_t *z8530 = (z8530_t *) |
(hw_map(aligned_addr, offset + size) + offset); |
name = ofw_tree_node_name(node); |
z8530_instance_t *z8530_instance = z8530_init(z8530, inr, cir, cir_arg); |
if (z8530_instance) { |
kbrd_instance_t *kbrd_instance = kbrd_init(); |
if (kbrd_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *kbrd = kbrd_wire(kbrd_instance, sink); |
z8530_wire(z8530_instance, kbrd); |
} |
} |
/* |
* This is the necessary evil until the userspace drivers are |
* entirely self-sufficient. |
* Determine keyboard serial controller type. |
*/ |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.inr", NULL, inr); |
sysinfo_set_item_val("kbd.address.kernel", NULL, |
(uintptr_t) z8530); |
sysinfo_set_item_val("kbd.address.physical", NULL, pa); |
sysinfo_set_item_val("kbd.type.z8530", NULL, true); |
if (str_cmp(name, "zs") == 0) |
kbd_type = KBD_Z8530; |
else if (str_cmp(name, "su") == 0) |
kbd_type = KBD_NS16550; |
return true; |
} |
#endif /* CONFIG_Z8530 */ |
#ifdef CONFIG_NS16550 |
static bool kbd_ns16550_init(ofw_tree_node_t *node) |
{ |
const char *name = ofw_tree_node_name(node); |
if (kbd_type == KBD_UNKNOWN) { |
printf("Unknown keyboard device.\n"); |
return; |
} |
if (str_cmp(name, "su") != 0) |
return false; |
/* |
* Read 'interrupts' property. |
*/ |
ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts"); |
if ((!prop) || (!prop->value)) { |
printf("ns16550: Unable to find interrupts property\n"); |
return false; |
} |
uint32_t interrupts; |
prop = ofw_tree_getprop(node, "interrupts"); |
if ((!prop) || (!prop->value)) |
panic("Cannot find 'interrupt' property."); |
interrupts = *((uint32_t *) prop->value); |
uint32_t interrupts = *((uint32_t *) prop->value); |
/* |
* Read 'reg' property. |
*/ |
prop = ofw_tree_getprop(node, "reg"); |
if ((!prop) || (!prop->value)) { |
printf("ns16550: Unable to find reg property\n"); |
return false; |
} |
if ((!prop) || (!prop->value)) |
panic("Cannot find 'reg' property."); |
size_t size = ((ofw_ebus_reg_t *) prop->value)->size; |
uintptr_t pa; |
if (!ofw_ebus_apply_ranges(node->parent, |
((ofw_ebus_reg_t *) prop->value), &pa)) { |
printf("ns16550: Failed to determine address\n"); |
return false; |
} |
size_t size; |
inr_t inr; |
inr_t inr; |
cir_t cir; |
void *cir_arg; |
if (!ofw_ebus_map_interrupt(node->parent, |
((ofw_ebus_reg_t *) prop->value), interrupts, &inr, &cir, |
&cir_arg)) { |
printf("ns16550: Failed to determine interrupt\n"); |
return false; |
switch (kbd_type) { |
case KBD_Z8530: |
size = ((ofw_fhc_reg_t *) prop->value)->size; |
if (!ofw_fhc_apply_ranges(node->parent, |
((ofw_fhc_reg_t *) prop->value), &pa)) { |
printf("Failed to determine keyboard address.\n"); |
return; |
} |
if (!ofw_fhc_map_interrupt(node->parent, |
((ofw_fhc_reg_t *) prop->value), interrupts, &inr, &cir, |
&cir_arg)) { |
printf("Failed to determine keyboard interrupt.\n"); |
return; |
} |
break; |
case KBD_NS16550: |
size = ((ofw_ebus_reg_t *) prop->value)->size; |
if (!ofw_ebus_apply_ranges(node->parent, |
((ofw_ebus_reg_t *) prop->value), &pa)) { |
printf("Failed to determine keyboard address.\n"); |
return; |
} |
if (!ofw_ebus_map_interrupt(node->parent, |
((ofw_ebus_reg_t *) prop->value), interrupts, &inr, &cir, |
&cir_arg)) { |
printf("Failed to determine keyboard interrupt.\n"); |
return; |
}; |
break; |
default: |
panic("Unexpected keyboard type."); |
} |
/* |
196,58 → 156,59 |
* be pretty much unaligned, depending on the |
* underlying controller. |
*/ |
uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); |
size_t offset = pa - aligned_addr; |
aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); |
offset = pa - aligned_addr; |
ns16550_t *ns16550 = (ns16550_t *) |
(hw_map(aligned_addr, offset + size) + offset); |
ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir, cir_arg); |
if (ns16550_instance) { |
kbrd_instance_t *kbrd_instance = kbrd_init(); |
if (kbrd_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *kbrd = kbrd_wire(kbrd_instance, sink); |
ns16550_wire(ns16550_instance, kbrd); |
} |
} |
/* |
* This is the necessary evil until the userspace drivers are |
* entirely self-sufficient. |
*/ |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.inr", NULL, inr); |
sysinfo_set_item_val("kbd.address.kernel", NULL, |
(uintptr_t) ns16550); |
sysinfo_set_item_val("kbd.address.physical", NULL, pa); |
sysinfo_set_item_val("kbd.type.ns16550", NULL, true); |
return true; |
} |
#endif /* CONFIG_NS16550 */ |
/** Initialize keyboard. |
* |
* Traverse OpenFirmware device tree in order to find necessary |
* info about the keyboard device. |
* |
* @param node Keyboard device node. |
* |
*/ |
void kbd_init(ofw_tree_node_t *node) |
{ |
switch (kbd_type) { |
#ifdef CONFIG_Z8530 |
kbd_z8530_init(node); |
case KBD_Z8530: |
z8530 = (z8530_t *) |
(hw_map(aligned_addr, offset + size) + offset); |
indev_t *kbrdin_z8530 = z8530_init(z8530, inr, cir, cir_arg); |
if (kbrdin_z8530) |
kbrd_init(kbrdin_z8530); |
/* |
* This is the necessary evil until the userspace drivers are |
* entirely self-sufficient. |
*/ |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530); |
sysinfo_set_item_val("kbd.inr", NULL, inr); |
sysinfo_set_item_val("kbd.address.kernel", NULL, |
(uintptr_t) z8530); |
sysinfo_set_item_val("kbd.address.physical", NULL, pa); |
break; |
#endif |
#ifdef CONFIG_NS16550 |
kbd_ns16550_init(node); |
case KBD_NS16550: |
ns16550 = (ns16550_t *) |
(hw_map(aligned_addr, offset + size) + offset); |
indev_t *kbrdin_ns16550 = ns16550_init(ns16550, inr, cir, cir_arg); |
if (kbrdin_ns16550) |
kbrd_init(kbrdin_ns16550); |
/* |
* This is the necessary evil until the userspace driver is |
* entirely self-sufficient. |
*/ |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); |
sysinfo_set_item_val("kbd.inr", NULL, inr); |
sysinfo_set_item_val("kbd.address.kernel", NULL, |
(uintptr_t) ns16550); |
sysinfo_set_item_val("kbd.address.physical", NULL, pa); |
break; |
#endif |
default: |
printf("Kernel is not compiled with the necessary keyboard " |
"driver this machine requires.\n"); |
} |
} |
#endif /* CONFIG_SUN_KBD */ |
#endif |
/** @} |
*/ |
/branches/dd/kernel/arch/sparc64/src/drivers/sgcn.c |
---|
101,6 → 101,9 |
/** Returns a pointer to the console buffer header. */ |
#define SGCN_BUFFER_HEADER (SGCN_BUFFER(sgcn_buffer_header_t, 0)) |
/** defined in drivers/kbd.c */ |
extern kbd_type_t kbd_type; |
/** starting address of SRAM, will be set by the init_sram_begin function */ |
static uintptr_t sram_begin; |
134,6 → 137,12 |
.write = sgcn_putchar |
}; |
/** SGCN input device operations */ |
static indev_operations_t sgcnin_ops = { |
.poll = NULL |
}; |
static indev_t sgcnin; /**< SGCN input device. */ |
static outdev_t sgcnout; /**< SGCN output device. */ |
/** |
279,7 → 288,7 |
*/ |
void sgcn_grab(void) |
{ |
kbd_disabled = false; |
kbd_disabled = true; |
} |
/** |
295,7 → 304,7 |
* there are some unread characters in the input queue. If so, it picks them up |
* and sends them to the upper layers of HelenOS. |
*/ |
static void sgcn_poll(sgcn_instance_t *instance) |
static void sgcn_poll() |
{ |
uint32_t begin = SGCN_BUFFER_HEADER->in_begin; |
uint32_t end = SGCN_BUFFER_HEADER->in_end; |
313,12 → 322,13 |
volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr); |
while (*in_rdptr_ptr != *in_wrptr_ptr) { |
buf_ptr = (volatile char *) |
SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); |
char c = *buf_ptr; |
*in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin; |
indev_push_character(instance->srlnin, c); |
indev_push_character(&sgcnin, c); |
} |
spinlock_unlock(&sgcn_input_lock); |
327,10 → 337,11 |
/** |
* Polling thread function. |
*/ |
static void ksgcnpoll(void *instance) { |
static void kkbdpoll(void *arg) { |
while (1) { |
if (!silent) |
sgcn_poll(instance); |
if (!silent) { |
sgcn_poll(); |
} |
thread_usleep(POLL_INTERVAL); |
} |
} |
338,36 → 349,23 |
/** |
* A public function which initializes input from the Serengeti console. |
*/ |
sgcn_instance_t *sgcnin_init(void) |
indev_t *sgcnin_init(void) |
{ |
sgcn_buffer_begin_init(); |
sgcn_instance_t *instance = |
malloc(sizeof(sgcn_instance_t), FRAME_ATOMIC); |
if (instance) { |
instance->srlnin = NULL; |
instance->thread = thread_create(ksgcnpoll, instance, TASK, 0, |
"ksgcnpoll", true); |
if (!instance->thread) { |
free(instance); |
return NULL; |
} |
} |
return instance; |
} |
void sgcnin_wire(sgcn_instance_t *instance, indev_t *srlnin) |
{ |
ASSERT(instance); |
ASSERT(srlnin); |
kbd_type = KBD_SGCN; |
instance->srlnin = srlnin; |
thread_ready(instance->thread); |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.type", NULL, KBD_SGCN); |
sysinfo_set_item_val("kbd", NULL, true); |
thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); |
if (!t) |
panic("Cannot create kkbdpoll."); |
thread_ready(t); |
indev_initialize("sgcnin", &sgcnin, &sgcnin_ops); |
return &sgcnin; |
} |
/** |
/branches/dd/kernel/arch/sparc64/src/start.S |
---|
294,7 → 294,7 |
/* Not reached. */ |
0: |
ba %xcc, 0b |
ba 0b |
nop |
352,7 → 352,7 |
#endif |
0: |
ba %xcc, 0b |
ba 0b |
nop |
/branches/dd/kernel/arch/sparc64/src/asm.S |
---|
225,12 → 225,12 |
.global memsetb |
memsetb: |
ba %xcc, _memsetb |
b _memsetb |
nop |
.global memsetw |
memsetw: |
ba %xcc, _memsetw |
b _memsetw |
nop |
/branches/dd/kernel/arch/sparc64/src/dummy.s |
---|
42,5 → 42,5 |
.global cpu_halt |
cpu_halt: |
ba %xcc, cpu_halt |
b cpu_halt |
nop |
/branches/dd/kernel/arch/ia64/include/ski/ski.h |
---|
0,0 → 1,52 |
/* |
* Copyright (c) 2005 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 ia64 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KERN_ia64_SKI_H_ |
#define KERN_ia64_SKI_H_ |
#include <console/chardev.h> |
#define SKI_INIT_CONSOLE 20 |
#define SKI_GETCHAR 21 |
#define SKI_PUTCHAR 31 |
extern indev_t *skiin_init(void); |
extern void skiout_init(void); |
extern void ski_kbd_grab(void); |
extern void ski_kbd_release(void); |
#endif |
/** @} |
*/ |
/branches/dd/kernel/arch/ia64/include/arch.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup ia64 |
/** @addtogroup ia64 |
* @{ |
*/ |
/** @file |
37,7 → 37,7 |
#define LOADED_PROG_STACK_PAGES_NO 2 |
#include <arch/drivers/ski.h> |
#include <arch/ski/ski.h> |
extern void arch_pre_main(void); |
/branches/dd/kernel/arch/ia64/include/drivers/ski.h |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/branches/dd/kernel/arch/ia64/src/ia64.c |
---|
33,7 → 33,7 |
*/ |
#include <arch.h> |
#include <arch/drivers/ski.h> |
#include <arch/ski/ski.h> |
#include <arch/drivers/it.h> |
#include <arch/interrupt.h> |
#include <arch/barrier.h> |
148,17 → 148,11 |
void arch_post_smp_init(void) |
{ |
#ifdef MACHINE_ski |
ski_instance_t *ski_instance = skiin_init(); |
if (ski_instance) { |
srln_instance_t *srln_instance = srln_init(); |
if (srln_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *srln = srln_wire(srln_instance, sink); |
skiin_wire(ski_instance, srln); |
} |
} |
#ifdef SKI |
indev_t *in; |
in = skiin_init(); |
if (in) |
srln_init(in); |
skiout_init(); |
#endif |
167,16 → 161,10 |
#endif |
#ifdef CONFIG_NS16550 |
ns16550_instance_t *ns16550_instance |
indev_t *kbrdin_ns16550 |
= ns16550_init((ns16550_t *) NS16550_BASE, NS16550_IRQ, NULL, NULL); |
if (ns16550_instance) { |
srln_instance_t *srln_instance = srln_init(); |
if (srln_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *srln = srln_wire(srln_instance, sink); |
ns16550_wire(ns16550_instance, srln); |
} |
} |
if (kbrdin_ns16550) |
srln_init(kbrdin_ns16550); |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.inr", NULL, NS16550_IRQ); |
188,15 → 176,9 |
#endif |
#ifdef CONFIG_I8042 |
i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); |
if (i8042_instance) { |
kbrd_instance_t *kbrd_instance = kbrd_init(); |
if (kbrd_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *kbrd = kbrd_wire(kbrd_instance, sink); |
i8042_wire(i8042_instance, kbrd); |
} |
} |
indev_t *kbrdin_i8042 = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); |
if (kbrdin_i8042) |
kbrd_init(kbrdin_i8042); |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD); |
256,7 → 238,7 |
*/ |
void arch_grab_console(void) |
{ |
#ifdef MACHINE_ski |
#ifdef SKI |
ski_kbd_grab(); |
#endif |
} |
266,7 → 248,7 |
*/ |
void arch_release_console(void) |
{ |
#ifdef MACHINE_ski |
#ifdef SKI |
ski_kbd_release(); |
#endif |
} |
/branches/dd/kernel/arch/ia64/src/ski/ski.c |
---|
0,0 → 1,210 |
/* |
* Copyright (c) 2005 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 ia64 |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/ski/ski.h> |
#include <console/console.h> |
#include <console/chardev.h> |
#include <sysinfo/sysinfo.h> |
#include <arch/types.h> |
#include <proc/thread.h> |
#include <synch/spinlock.h> |
#include <arch/asm.h> |
#include <arch/drivers/kbd.h> |
#include <string.h> |
#include <arch.h> |
static indev_t skiin; /**< Ski input device. */ |
static outdev_t skiout; /**< Ski output device. */ |
static bool kbd_disabled; |
static void ski_do_putchar(const wchar_t ch) |
{ |
asm volatile ( |
"mov r15 = %[cmd]\n" |
"mov r32 = %[ch]\n" /* r32 is in0 */ |
"break 0x80000\n" /* modifies r8 */ |
: |
: [cmd] "i" (SKI_PUTCHAR), [ch] "r" (ch) |
: "r15", "in0", "r8" |
); |
} |
/** Display character on debug console |
* |
* Use SSC (Simulator System Call) to |
* display character on debug console. |
* |
* @param d Character device. |
* @param ch Character to be printed. |
*/ |
static void ski_putchar(outdev_t *d, const wchar_t ch, bool silent) |
{ |
if (!silent) { |
if (ascii_check(ch)) { |
if (ch == '\n') |
ski_do_putchar('\r'); |
ski_do_putchar(ch); |
} else |
ski_do_putchar(SPECIAL); |
} |
} |
static indev_operations_t skiin_ops = { |
.poll = NULL |
}; |
static outdev_operations_t skiout_ops = { |
.write = ski_putchar |
}; |
/** Ask debug console if a key was pressed. |
* |
* Use SSC (Simulator System Call) to |
* get character from debug console. |
* |
* This call is non-blocking. |
* |
* @return ASCII code of pressed key or 0 if no key pressed. |
*/ |
static int32_t ski_getchar(void) |
{ |
uint64_t ch; |
asm volatile ( |
"mov r15 = %1\n" |
"break 0x80000;;\n" /* modifies r8 */ |
"mov %0 = r8;;\n" |
: "=r" (ch) |
: "i" (SKI_GETCHAR) |
: "r15", "r8" |
); |
return (int32_t) ch; |
} |
/** Ask keyboard if a key was pressed. */ |
static void poll_keyboard(void) |
{ |
char ch; |
if (kbd_disabled) |
return; |
ch = ski_getchar(); |
if(ch == '\r') |
ch = '\n'; |
if (ch) { |
indev_push_character(&skiin, ch); |
return; |
} |
} |
#define POLL_INTERVAL 10000 /* 10 ms */ |
/** Kernel thread for polling keyboard. */ |
static void kkbdpoll(void *arg) |
{ |
while (1) { |
if (!silent) { |
poll_keyboard(); |
} |
thread_usleep(POLL_INTERVAL); |
} |
} |
/** Initialize debug console |
* |
* Issue SSC (Simulator System Call) to |
* to open debug console. |
*/ |
static void ski_init(void) |
{ |
static bool initialized; |
if (initialized) |
return; |
asm volatile ( |
"mov r15 = %0\n" |
"break 0x80000\n" |
: |
: "i" (SKI_INIT_CONSOLE) |
: "r15", "r8" |
); |
initialized = true; |
} |
indev_t *skiin_init(void) |
{ |
ski_init(); |
indev_initialize("skiin", &skiin, &skiin_ops); |
thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); |
if (t) |
thread_ready(t); |
else |
return NULL; |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.type", NULL, KBD_SKI); |
return &skiin; |
} |
void skiout_init(void) |
{ |
ski_init(); |
outdev_initialize("skiout", &skiout, &skiout_ops); |
stdout = &skiout; |
sysinfo_set_item_val("fb", NULL, false); |
} |
void ski_kbd_grab(void) |
{ |
kbd_disabled = true; |
} |
void ski_kbd_release(void) |
{ |
kbd_disabled = false; |
} |
/** @} |
*/ |
/branches/dd/kernel/arch/ia64/src/drivers/ski.c |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/branches/dd/kernel/arch/ia64/src/smp/smp.c |
---|
33,7 → 33,7 |
*/ |
#include <arch.h> |
#include <arch/drivers/ski.h> |
#include <arch/ski/ski.h> |
#include <arch/drivers/it.h> |
#include <arch/interrupt.h> |
#include <arch/barrier.h> |
/branches/dd/kernel/arch/ia64/Makefile.inc |
---|
64,7 → 64,8 |
arch/$(KARCH)/src/drivers/it.c |
ifeq ($(MACHINE),ski) |
ARCH_SOURCES += arch/$(KARCH)/src/drivers/ski.c |
ARCH_SOURCES += arch/$(KARCH)/src/ski/ski.c |
DEFS += -DSKI |
BFD = binary |
endif |
/branches/dd/kernel/arch/arm32/src/arm32.c |
---|
35,6 → 35,7 |
#include <arch.h> |
#include <config.h> |
#include <arch/console.h> |
#include <genarch/fb/fb.h> |
#include <genarch/fb/visuals.h> |
#include <genarch/drivers/dsrln/dsrlnin.h> |
41,7 → 42,6 |
#include <genarch/drivers/dsrln/dsrlnout.h> |
#include <genarch/srln/srln.h> |
#include <sysinfo/sysinfo.h> |
#include <console/console.h> |
#include <ddi/irq.h> |
#include <arch/drivers/gxemul.h> |
#include <print.h> |
129,18 → 129,11 |
#ifdef CONFIG_ARM_KBD |
/* |
* Initialize the GXemul keyboard port. Then initialize the serial line |
* module and connect it to the GXemul keyboard. |
* module and connect it to the GXemul keyboard. Enable keyboard interrupts. |
*/ |
dsrlnin_instance_t *dsrlnin_instance |
= dsrlnin_init((dsrlnin_t *) gxemul_kbd, GXEMUL_KBD_IRQ); |
if (dsrlnin_instance) { |
srln_instance_t *srln_instance = srln_init(); |
if (srln_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *srln = srln_wire(srln_instance, sink); |
dsrlnin_wire(dsrlnin_instance, srln); |
} |
} |
indev_t *kbrdin = dsrlnin_init((dsrlnin_t *) gxemul_kbd, GXEMUL_KBD_IRQ); |
if (kbrdin) |
srln_init(kbrdin); |
/* |
* This is the necessary evil until the userspace driver is entirely |
208,18 → 201,5 |
return addr; |
} |
/** Acquire console back for kernel. */ |
void arch_grab_console(void) |
{ |
#ifdef CONFIG_FB |
fb_redraw(); |
#endif |
} |
/** Return console to userspace. */ |
void arch_release_console(void) |
{ |
} |
/** @} |
*/ |
/branches/dd/kernel/arch/arm32/src/console.c |
---|
0,0 → 1,54 |
/* |
* Copyright (c) 2007 Michal Kebrt |
* 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 arm32 |
* @{ |
*/ |
/** @file |
* @brief Console. |
*/ |
#include <console/console.h> |
#include <arch/console.h> |
#include <genarch/fb/fb.h> |
/** Acquire console back for kernel. */ |
void arch_grab_console(void) |
{ |
#ifdef CONFIG_FB |
fb_redraw(); |
#endif |
} |
/** Return console to userspace. */ |
void arch_release_console(void) |
{ |
} |
/** @} |
*/ |
/branches/dd/kernel/arch/arm32/include/console.h |
---|
0,0 → 1,42 |
/* |
* Copyright (c) 2007 Michal Kebrt |
* 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 arm32 |
* @{ |
*/ |
/** @file |
* @brief Console. |
*/ |
#ifndef KERN_arm32_CONSOLE_H_ |
#define KERN_arm32_CONSOLE_H_ |
#endif |
/** @} |
*/ |
/branches/dd/kernel/arch/arm32/Makefile.inc |
---|
51,6 → 51,7 |
arch/$(KARCH)/src/cpu/cpu.c \ |
arch/$(KARCH)/src/ddi/ddi.c \ |
arch/$(KARCH)/src/interrupt.c \ |
arch/$(KARCH)/src/console.c \ |
arch/$(KARCH)/src/exception.c \ |
arch/$(KARCH)/src/userspace.c \ |
arch/$(KARCH)/src/mm/as.c \ |
/branches/dd/kernel/arch/ppc32/src/ppc32.c |
---|
35,7 → 35,7 |
#include <config.h> |
#include <arch.h> |
#include <arch/boot/boot.h> |
#include <genarch/drivers/via-cuda/cuda.h> |
#include <arch/drivers/cuda.h> |
#include <arch/interrupt.h> |
#include <genarch/fb/fb.h> |
#include <genarch/fb/visuals.h> |
44,12 → 44,10 |
#include <console/console.h> |
#include <ddi/irq.h> |
#include <arch/drivers/pic.h> |
#include <align.h> |
#include <macros.h> |
#include <string.h> |
#define IRQ_COUNT 64 |
#define IRQ_CUDA 10 |
bootinfo_t bootinfo; |
119,27 → 117,10 |
if (bootinfo.macio.addr) { |
/* Initialize PIC */ |
cir_t cir; |
void *cir_arg; |
pic_init(bootinfo.macio.addr, PAGE_SIZE, &cir, &cir_arg); |
pic_init(bootinfo.macio.addr, PAGE_SIZE); |
#ifdef CONFIG_VIA_CUDA |
uintptr_t pa = bootinfo.macio.addr + 0x16000; |
uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); |
size_t offset = pa - aligned_addr; |
size_t size = 2 * PAGE_SIZE; |
cuda_t *cuda = (cuda_t *) |
(hw_map(aligned_addr, offset + size) + offset); |
/* Initialize I/O controller */ |
cuda_instance_t *cuda_instance = |
cuda_init(cuda, IRQ_CUDA, cir, cir_arg); |
if (cuda_instance) { |
indev_t *sink = stdin_wire(); |
cuda_wire(cuda_instance, sink); |
} |
#endif |
cuda_init(bootinfo.macio.addr + 0x16000, 2 * PAGE_SIZE); |
} |
/* Merge all zones to 1 big zone */ |
205,11 → 186,5 |
return addr; |
} |
void arch_reboot(void) |
{ |
// TODO |
while (1); |
} |
/** @} |
*/ |
/branches/dd/kernel/arch/ppc32/src/drivers/cuda.c |
---|
0,0 → 1,260 |
/* |
* 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. |
*/ |
/** @addtogroup ppc32 |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/drivers/cuda.h> |
#include <arch/asm.h> |
#include <console/console.h> |
#include <console/chardev.h> |
#include <arch/drivers/pic.h> |
#include <sysinfo/sysinfo.h> |
#include <interrupt.h> |
#include <stdarg.h> |
#include <ddi/device.h> |
#include <string.h> |
#define CUDA_IRQ 10 |
#define PACKET_ADB 0x00 |
#define PACKET_CUDA 0x01 |
#define CUDA_POWERDOWN 0x0a |
#define CUDA_RESET 0x11 |
#define RS 0x200 |
#define B (0 * RS) |
#define A (1 * RS) |
#define SR (10 * RS) |
#define ACR (11 * RS) |
#define SR_OUT 0x10 |
#define TACK 0x10 |
#define TIP 0x20 |
#define SCANCODES 128 |
static volatile uint8_t *cuda = NULL; |
static irq_t cuda_irq; /**< Cuda's IRQ. */ |
static wchar_t lchars[SCANCODES] = { |
'a', 's', 'd', 'f', 'h', 'g', 'z', 'x', 'c', 'v', |
U_SPECIAL, |
'b', 'q', 'w', 'e', 'r', 'y', 't', '1', '2', '3', '4', '6', '5', |
'=', '9', '7', '-', '8', '0', ']', 'o', 'u', '[', 'i', 'p', |
'\n', /* Enter */ |
'l', 'j', '\'', 'k', ';', '\\', ',', '/', 'n', 'm', '.', |
'\t', /* Tab */ |
' ', '`', |
'\b', /* Backspace */ |
U_SPECIAL, |
U_ESCAPE, /* Escape */ |
U_SPECIAL, /* Ctrl */ |
U_SPECIAL, /* Alt */ |
U_SPECIAL, /* Shift */ |
U_SPECIAL, /* CapsLock */ |
U_SPECIAL, /* Right Alt */ |
U_LEFT_ARROW, /* Left */ |
U_RIGHT_ARROW, /* Right */ |
U_DOWN_ARROW, /* Down */ |
U_UP_ARROW, /* Up */ |
U_SPECIAL, |
U_SPECIAL, |
'.', /* Keypad . */ |
U_SPECIAL, |
'*', /* Keypad * */ |
U_SPECIAL, |
'+', /* Keypad + */ |
U_SPECIAL, |
U_SPECIAL, /* NumLock */ |
U_SPECIAL, |
U_SPECIAL, |
U_SPECIAL, |
'/', /* Keypad / */ |
'\n', /* Keypad Enter */ |
U_SPECIAL, |
'-', /* Keypad - */ |
U_SPECIAL, |
U_SPECIAL, |
U_SPECIAL, |
'0', /* Keypad 0 */ |
'1', /* Keypad 1 */ |
'2', /* Keypad 2 */ |
'3', /* Keypad 3 */ |
'4', /* Keypad 4 */ |
'5', /* Keypad 5 */ |
'6', /* Keypad 6 */ |
'7', /* Keypad 7 */ |
U_SPECIAL, |
'8', /* Keypad 8 */ |
'9', /* Keypad 9 */ |
U_SPECIAL, |
U_SPECIAL, |
U_SPECIAL, |
U_SPECIAL, /* F5 */ |
U_SPECIAL, /* F6 */ |
U_SPECIAL, /* F7 */ |
U_SPECIAL, /* F3 */ |
U_SPECIAL, /* F8 */ |
U_SPECIAL, /* F9 */ |
U_SPECIAL, |
U_SPECIAL, /* F11 */ |
U_SPECIAL, |
U_SPECIAL, /* F13 */ |
U_SPECIAL, |
U_SPECIAL, /* ScrollLock */ |
U_SPECIAL, |
U_SPECIAL, /* F10 */ |
U_SPECIAL, |
U_SPECIAL, /* F12 */ |
U_SPECIAL, |
U_SPECIAL, /* Pause */ |
U_SPECIAL, /* Insert */ |
U_HOME_ARROW, /* Home */ |
U_PAGE_UP, /* Page Up */ |
U_DELETE, /* Delete */ |
U_SPECIAL, /* F4 */ |
U_END_ARROW, /* End */ |
U_SPECIAL, /* F2 */ |
U_PAGE_DOWN, /* Page Down */ |
U_SPECIAL /* F1 */ |
}; |
static void receive_packet(uint8_t *kind, index_t count, uint8_t data[]) |
{ |
cuda[B] = cuda[B] & ~TIP; |
*kind = cuda[SR]; |
index_t i; |
for (i = 0; i < count; i++) |
data[i] = cuda[SR]; |
cuda[B] = cuda[B] | TIP; |
} |
static indev_t kbrd; |
static indev_operations_t ops = { |
.poll = NULL |
}; |
int cuda_get_scancode(void) |
{ |
if (cuda) { |
uint8_t kind; |
uint8_t data[4]; |
receive_packet(&kind, 4, data); |
if ((kind == PACKET_ADB) && (data[0] == 0x40) && (data[1] == 0x2c)) |
return data[2]; |
} |
return -1; |
} |
static void cuda_irq_handler(irq_t *irq) |
{ |
int scan_code = cuda_get_scancode(); |
if (scan_code != -1) { |
uint8_t scancode = (uint8_t) scan_code; |
if ((scancode & 0x80) != 0x80) |
indev_push_character(&kbrd, lchars[scancode & 0x7f]); |
} |
} |
static irq_ownership_t cuda_claim(irq_t *irq) |
{ |
return IRQ_ACCEPT; |
} |
void cuda_init(uintptr_t base, size_t size) |
{ |
cuda = (uint8_t *) hw_map(base, size); |
indev_initialize("cuda_kbd", &kbrd, &ops); |
stdin = &kbrd; |
irq_initialize(&cuda_irq); |
cuda_irq.devno = device_assign_devno(); |
cuda_irq.inr = CUDA_IRQ; |
cuda_irq.claim = cuda_claim; |
cuda_irq.handler = cuda_irq_handler; |
irq_register(&cuda_irq); |
pic_enable_interrupt(CUDA_IRQ); |
sysinfo_set_item_val("kbd", NULL, true); |
sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ); |
sysinfo_set_item_val("kbd.address.virtual", NULL, base); |
} |
static void send_packet(const uint8_t kind, count_t count, ...) |
{ |
index_t i; |
va_list va; |
cuda[B] = cuda[B] | TIP; |
cuda[ACR] = cuda[ACR] | SR_OUT; |
cuda[SR] = kind; |
cuda[B] = cuda[B] & ~TIP; |
va_start(va, count); |
for (i = 0; i < count; i++) { |
cuda[ACR] = cuda[ACR] | SR_OUT; |
cuda[SR] = va_arg(va, int); |
cuda[B] = cuda[B] | TACK; |
} |
va_end(va); |
cuda[B] = cuda[B] | TIP; |
} |
void cpu_halt(void) { |
asm volatile ( |
"b 0\n" |
); |
} |
void arch_reboot(void) { |
if (cuda) |
send_packet(PACKET_CUDA, 1, CUDA_RESET); |
asm volatile ( |
"b 0\n" |
); |
} |
/** @} |
*/ |
/branches/dd/kernel/arch/ppc32/src/drivers/pic.c |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup ppc32 |
/** @addtogroup ppc32 |
* @{ |
*/ |
/** @file |
40,14 → 40,12 |
static volatile uint32_t *pic = NULL; |
void pic_init(uintptr_t base, size_t size, cir_t *cir, void **cir_arg) |
void pic_init(uintptr_t base, size_t size) |
{ |
pic = (uint32_t *) hw_map(base, size); |
*cir = pic_ack_interrupt; |
*cir_arg = NULL; |
} |
void pic_enable_interrupt(inr_t intnum) |
void pic_enable_interrupt(int intnum) |
{ |
if (pic) { |
if (intnum < 32) |
58,7 → 56,7 |
} |
void pic_disable_interrupt(inr_t intnum) |
void pic_disable_interrupt(int intnum) |
{ |
if (pic) { |
if (intnum < 32) |
68,7 → 66,7 |
} |
} |
void pic_ack_interrupt(void *arg, inr_t intnum) |
void pic_ack_interrupt(int intnum) |
{ |
if (pic) { |
if (intnum < 32) |
/branches/dd/kernel/arch/ppc32/src/interrupt.c |
---|
60,6 → 60,7 |
int inum; |
while ((inum = pic_get_pending()) != -1) { |
bool ack = false; |
irq_t *irq = irq_dispatch_and_lock(inum); |
if (irq) { |
/* |
68,17 → 69,11 |
if (irq->preack) { |
/* Acknowledge the interrupt before processing */ |
if (irq->cir) |
irq->cir(irq->cir_arg, irq->inr); |
pic_ack_interrupt(inum); |
ack = true; |
} |
irq->handler(irq); |
if (!irq->preack) { |
if (irq->cir) |
irq->cir(irq->cir_arg, irq->inr); |
} |
spinlock_unlock(&irq->lock); |
} else { |
/* |
88,6 → 83,9 |
printf("cpu%u: spurious interrupt (inum=%d)\n", CPU->id, inum); |
#endif |
} |
if (!ack) |
pic_ack_interrupt(inum); |
} |
} |
/branches/dd/kernel/arch/ppc32/src/dummy.s |
---|
30,7 → 30,6 |
.global asm_delay_loop |
.global sys_tls_set |
.global cpu_halt |
sys_tls_set: |
b sys_tls_set |
37,6 → 36,3 |
asm_delay_loop: |
blr |
cpu_halt: |
b cpu_halt |
/branches/dd/kernel/arch/ppc32/include/drivers/cuda.h |
---|
0,0 → 1,47 |
/* |
* 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. |
*/ |
/** @addtogroup ppc32 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KERN_ppc32_CUDA_H_ |
#define KERN_ppc32_CUDA_H_ |
#include <arch/types.h> |
#include <typedefs.h> |
extern void cuda_init(uintptr_t base, size_t size); |
extern int cuda_get_scancode(void); |
#endif |
/** @} |
*/ |
/branches/dd/kernel/arch/ppc32/include/drivers/pic.h |
---|
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup ppc32 |
/** @addtogroup ppc32 |
* @{ |
*/ |
/** @file |
36,7 → 36,6 |
#define KERN_ppc32_PIC_H_ |
#include <arch/types.h> |
#include <ddi/irq.h> |
#define PIC_PENDING_LOW 8 |
#define PIC_PENDING_HIGH 4 |
45,11 → 44,11 |
#define PIC_ACK_LOW 10 |
#define PIC_ACK_HIGH 6 |
extern void pic_init(uintptr_t base, size_t size, cir_t *cir, void **cir_arg); |
extern void pic_enable_interrupt(inr_t intnum); |
extern void pic_disable_interrupt(inr_t intnum); |
extern void pic_ack_interrupt(void *arg, inr_t intnum); |
extern int pic_get_pending(void); |
void pic_init(uintptr_t base, size_t size); |
void pic_enable_interrupt(int intnum); |
void pic_disable_interrupt(int intnum); |
void pic_ack_interrupt(int intnum); |
int pic_get_pending(void); |
#endif |
/branches/dd/kernel/arch/ppc32/Makefile.inc |
---|
54,6 → 54,7 |
arch/$(KARCH)/src/cpu/cpu.c \ |
arch/$(KARCH)/src/proc/scheduler.c \ |
arch/$(KARCH)/src/ddi/ddi.c \ |
arch/$(KARCH)/src/drivers/cuda.c \ |
arch/$(KARCH)/src/mm/as.c \ |
arch/$(KARCH)/src/mm/frame.c \ |
arch/$(KARCH)/src/mm/page.c \ |
/branches/dd/kernel/arch/mips32/src/mips32.c |
---|
36,14 → 36,16 |
#include <arch/cp0.h> |
#include <arch/exception.h> |
#include <mm/as.h> |
#include <userspace.h> |
#include <arch/console.h> |
#include <memstr.h> |
#include <proc/thread.h> |
#include <proc/uarg.h> |
#include <print.h> |
#include <console/console.h> |
#include <syscall/syscall.h> |
#include <sysinfo/sysinfo.h> |
#include <arch/interrupt.h> |
#include <console/chardev.h> |
#include <arch/barrier.h> |
57,6 → 59,7 |
#include <config.h> |
#include <string.h> |
#include <arch/drivers/msim.h> |
#include <arch/asm/regname.h> |
/* Size of the code jumping to the exception handler code |
166,16 → 169,10 |
* Initialize the msim/GXemul keyboard port. Then initialize the serial line |
* module and connect it to the msim/GXemul keyboard. Enable keyboard interrupts. |
*/ |
dsrlnin_instance_t *dsrlnin_instance |
= dsrlnin_init((dsrlnin_t *) MSIM_KBD_ADDRESS, MSIM_KBD_IRQ); |
if (dsrlnin_instance) { |
srln_instance_t *srln_instance = srln_init(); |
if (srln_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *srln = srln_wire(srln_instance, sink); |
dsrlnin_wire(dsrlnin_instance, srln); |
cp0_unmask_int(MSIM_KBD_IRQ); |
} |
indev_t *kbrdin = dsrlnin_init((dsrlnin_t *) MSIM_KBD_ADDRESS, MSIM_KBD_IRQ); |
if (kbrdin) { |
srln_init(kbrdin); |
cp0_unmask_int(MSIM_KBD_IRQ); |
} |
/* |
251,19 → 248,5 |
return addr; |
} |
void arch_grab_console(void) |
{ |
#ifdef CONFIG_FB |
fb_redraw(); |
#endif |
} |
/** Return console to userspace |
* |
*/ |
void arch_release_console(void) |
{ |
} |
/** @} |
*/ |
/branches/dd/kernel/arch/mips32/src/console.c |
---|
0,0 → 1,56 |
/* |
* Copyright (c) 2005 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 mips32 |
* @{ |
*/ |
/** @file |
*/ |
#include <console/console.h> |
#include <genarch/fb/fb.h> |
/** Acquire console back for kernel |
* |
*/ |
void arch_grab_console(void) |
{ |
#ifdef CONFIG_FB |
fb_redraw(); |
#endif |
} |
/** Return console to userspace |
* |
*/ |
void arch_release_console(void) |
{ |
} |
/** @} |
*/ |
/branches/dd/kernel/arch/mips32/include/console.h |
---|
0,0 → 1,41 |
/* |
* 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. |
*/ |
/** @addtogroup mips32 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef KERN_mips32_CONSOLE_H_ |
#define KERN_mips32_CONSOLE_H_ |
#endif |
/** @} |
*/ |
/branches/dd/kernel/arch/mips32/include/elf.h |
---|
35,11 → 35,9 |
#ifndef KERN_mips32_ELF_H_ |
#define KERN_mips32_ELF_H_ |
#include <byteorder.h> |
#define ELF_MACHINE EM_MIPS |
#ifdef ARCH_IS_BIG_ENDIAN |
#ifdef BIG_ENDIAN |
# define ELF_DATA_ENCODING ELFDATA2MSB |
#else |
# define ELF_DATA_ENCODING ELFDATA2LSB |
/branches/dd/kernel/arch/mips32/Makefile.inc |
---|
60,6 → 60,7 |
arch/$(KARCH)/src/context.S \ |
arch/$(KARCH)/src/panic.S \ |
arch/$(KARCH)/src/mips32.c \ |
arch/$(KARCH)/src/console.c \ |
arch/$(KARCH)/src/asm.S \ |
arch/$(KARCH)/src/exception.c \ |
arch/$(KARCH)/src/interrupt.c \ |
/branches/dd/kernel/arch/ia32/src/ia32.c |
---|
80,7 → 80,7 |
void arch_pre_main(uint32_t signature, const multiboot_info_t *mi) |
{ |
/* Parse multiboot information obtained from the bootloader. */ |
multiboot_info_parse(signature, mi); |
multiboot_info_parse(signature, mi); |
#ifdef CONFIG_SMP |
/* Copy AP bootstrap routines below 1 MB. */ |
155,15 → 155,10 |
* Initialize the i8042 controller. Then initialize the keyboard |
* module and connect it to i8042. Enable keyboard interrupts. |
*/ |
i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); |
if (i8042_instance) { |
kbrd_instance_t *kbrd_instance = kbrd_init(); |
if (kbrd_instance) { |
indev_t *sink = stdin_wire(); |
indev_t *kbrd = kbrd_wire(kbrd_instance, sink); |
i8042_wire(i8042_instance, kbrd); |
trap_virtual_enable_irqs(1 << IRQ_KBD); |
} |
indev_t *kbrdin = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); |
if (kbrdin) { |
kbrd_init(kbrdin); |
trap_virtual_enable_irqs(1 << IRQ_KBD); |
} |
/* |
/branches/dd/kernel/arch/ia32/src/atomic.S |
---|
42,7 → 42,9 |
movl 12(%esp),%ebx |
0: |
#ifdef CONFIG_HT |
pause # Pentium 4's with HT love this instruction |
#endif |
movl (%ebx),%eax |
testl %eax,%eax |
jnz 0b # lightweight looping while it is locked |
/branches/dd/kernel/arch/ia32/include/atomic.h |
---|
114,7 → 114,9 |
preemption_disable(); |
asm volatile ( |
"0:\n" |
#ifdef CONFIG_HT |
"pause\n" /* Pentium 4's HT love this instruction */ |
#endif |
"mov %[count], %[tmp]\n" |
"testl %[tmp], %[tmp]\n" |
"jnz 0b\n" /* lightweight looping on locked spinlock */ |
/branches/dd/kernel/genarch/include/kbrd/kbrd.h |
---|
37,23 → 37,9 |
#define KERN_KBD_H_ |
#include <console/chardev.h> |
#include <proc/thread.h> |
#include <synch/spinlock.h> |
typedef struct { |
thread_t *thread; |
indev_t *sink; |
indev_t raw; |
SPINLOCK_DECLARE(keylock); /**< keylock protects keyflags and lockflags. */ |
volatile unsigned int keyflags; /**< Tracking of multiple keypresses. */ |
volatile unsigned int lockflags; /**< Tracking of multiple keys lockings. */ |
} kbrd_instance_t; |
extern void kbrd_init(indev_t *devin); |
extern kbrd_instance_t *kbrd_init(void); |
extern indev_t *kbrd_wire(kbrd_instance_t *, indev_t *); |
#endif |
/** @} |
/branches/dd/kernel/genarch/include/drivers/via-cuda/cuda.h |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/branches/dd/kernel/genarch/include/drivers/i8042/i8042.h |
---|
49,11 → 49,10 |
typedef struct { |
irq_t irq; |
i8042_t *i8042; |
indev_t *kbrdin; |
indev_t kbrdin; |
} i8042_instance_t; |
extern i8042_instance_t *i8042_init(i8042_t *, inr_t); |
extern void i8042_wire(i8042_instance_t *, indev_t *); |
extern indev_t *i8042_init(i8042_t *, inr_t); |
extern void i8042_cpu_reset(i8042_t *); |
#endif |
/branches/dd/kernel/genarch/include/drivers/ns16550/ns16550.h |
---|
62,13 → 62,12 |
/** Structure representing the ns16550 device. */ |
typedef struct { |
ns16550_t *ns16550; |
irq_t irq; |
ns16550_t *ns16550; |
indev_t *kbrdin; |
indev_t kbrdin; |
} ns16550_instance_t; |
extern ns16550_instance_t *ns16550_init(ns16550_t *, inr_t, cir_t, void *); |
extern void ns16550_wire(ns16550_instance_t *, indev_t *); |
extern indev_t *ns16550_init(ns16550_t *, inr_t, cir_t, void *); |
#endif |
/branches/dd/kernel/genarch/include/drivers/dsrln/dsrlnin.h |
---|
49,11 → 49,10 |
typedef struct { |
irq_t irq; |
dsrlnin_t *dsrlnin; |
indev_t *srlnin; |
indev_t kbrdin; |
} dsrlnin_instance_t; |
extern dsrlnin_instance_t *dsrlnin_init(dsrlnin_t *, inr_t); |
extern void dsrlnin_wire(dsrlnin_instance_t *, indev_t *); |
extern indev_t *dsrlnin_init(dsrlnin_t *, inr_t); |
#endif |
/branches/dd/kernel/genarch/include/drivers/z8530/z8530.h |
---|
116,11 → 116,10 |
typedef struct { |
irq_t irq; |
z8530_t *z8530; |
indev_t *kbrdin; |
indev_t kbrdin; |
} z8530_instance_t; |
extern z8530_instance_t *z8530_init(z8530_t *, inr_t, cir_t, void *); |
extern void z8530_wire(z8530_instance_t *, indev_t *); |
extern indev_t *z8530_init(z8530_t *, inr_t, cir_t, void *); |
#endif |
/branches/dd/kernel/genarch/include/srln/srln.h |
---|
37,18 → 37,9 |
#define KERN_SRLN_H_ |
#include <console/chardev.h> |
#include <proc/thread.h> |
typedef struct { |
thread_t *thread; |
indev_t *sink; |
indev_t raw; |
} srln_instance_t; |
extern void srln_init(indev_t *devin); |
extern srln_instance_t *srln_init(void); |
extern indev_t *srln_wire(srln_instance_t *, indev_t *); |
#endif |
/** @} |
/branches/dd/kernel/genarch/src/kbrd/kbrd.c |
---|
59,35 → 59,39 |
#define PRESSED_CAPSLOCK (1 << 1) |
#define LOCKED_CAPSLOCK (1 << 0) |
static indev_operations_t kbrd_raw_ops = { |
static indev_t kbrdout; |
indev_operations_t kbrdout_ops = { |
.poll = NULL |
}; |
SPINLOCK_INITIALIZE(keylock); /**< keylock protects keyflags and lockflags. */ |
static volatile int keyflags; /**< Tracking of multiple keypresses. */ |
static volatile int lockflags; /**< Tracking of multiple keys lockings. */ |
/** Process release of key. |
* |
* @param sc Scancode of the key being released. |
*/ |
static void key_released(kbrd_instance_t *instance, wchar_t sc) |
static void key_released(wchar_t sc) |
{ |
spinlock_lock(&instance->keylock); |
spinlock_lock(&keylock); |
switch (sc) { |
case SC_LSHIFT: |
case SC_RSHIFT: |
instance->keyflags &= ~PRESSED_SHIFT; |
keyflags &= ~PRESSED_SHIFT; |
break; |
case SC_CAPSLOCK: |
instance->keyflags &= ~PRESSED_CAPSLOCK; |
if (instance->lockflags & LOCKED_CAPSLOCK) |
instance->lockflags &= ~LOCKED_CAPSLOCK; |
keyflags &= ~PRESSED_CAPSLOCK; |
if (lockflags & LOCKED_CAPSLOCK) |
lockflags &= ~LOCKED_CAPSLOCK; |
else |
instance->lockflags |= LOCKED_CAPSLOCK; |
lockflags |= LOCKED_CAPSLOCK; |
break; |
default: |
break; |
} |
spinlock_unlock(&instance->keylock); |
spinlock_unlock(&keylock); |
} |
/** Process keypress. |
94,94 → 98,69 |
* |
* @param sc Scancode of the key being pressed. |
*/ |
static void key_pressed(kbrd_instance_t *instance, wchar_t sc) |
static void key_pressed(wchar_t sc) |
{ |
bool letter; |
bool shift; |
bool capslock; |
spinlock_lock(&instance->keylock); |
spinlock_lock(&keylock); |
switch (sc) { |
case SC_LSHIFT: |
case SC_RSHIFT: |
instance->keyflags |= PRESSED_SHIFT; |
keyflags |= PRESSED_SHIFT; |
break; |
case SC_CAPSLOCK: |
instance->keyflags |= PRESSED_CAPSLOCK; |
keyflags |= PRESSED_CAPSLOCK; |
break; |
case SC_SCAN_ESCAPE: |
break; |
default: |
letter = islower(sc_primary_map[sc]); |
shift = instance->keyflags & PRESSED_SHIFT; |
capslock = (instance->keyflags & PRESSED_CAPSLOCK) || |
(instance->lockflags & LOCKED_CAPSLOCK); |
shift = keyflags & PRESSED_SHIFT; |
capslock = (keyflags & PRESSED_CAPSLOCK) || |
(lockflags & LOCKED_CAPSLOCK); |
if ((letter) && (capslock)) |
shift = !shift; |
if (shift) |
indev_push_character(instance->sink, sc_secondary_map[sc]); |
indev_push_character(stdin, sc_secondary_map[sc]); |
else |
indev_push_character(instance->sink, sc_primary_map[sc]); |
indev_push_character(stdin, sc_primary_map[sc]); |
break; |
} |
spinlock_unlock(&instance->keylock); |
spinlock_unlock(&keylock); |
} |
static void kkbrd(void *arg) |
{ |
kbrd_instance_t *instance = (kbrd_instance_t *) arg; |
indev_t *in = (indev_t *) arg; |
while (true) { |
wchar_t sc = indev_pop_character(&instance->raw); |
wchar_t sc = _getc(in); |
if (sc == IGNORE_CODE) |
continue; |
if (sc & KEY_RELEASE) |
key_released(instance, (sc ^ KEY_RELEASE) & 0x7f); |
key_released((sc ^ KEY_RELEASE) & 0x7f); |
else |
key_pressed(instance, sc & 0x7f); |
key_pressed(sc & 0x7f); |
} |
} |
kbrd_instance_t *kbrd_init(void) |
void kbrd_init(indev_t *devin) |
{ |
kbrd_instance_t *instance |
= malloc(sizeof(kbrd_instance_t), FRAME_ATOMIC); |
if (instance) { |
instance->thread |
= thread_create(kkbrd, (void *) instance, TASK, 0, "kkbrd", false); |
if (!instance->thread) { |
free(instance); |
return NULL; |
} |
instance->sink = NULL; |
indev_initialize("kbrd", &instance->raw, &kbrd_raw_ops); |
spinlock_initialize(&instance->keylock, "instance_keylock"); |
instance->keyflags = 0; |
instance->lockflags = 0; |
indev_initialize("kbrd", &kbrdout, &kbrdout_ops); |
thread_t *thread |
= thread_create(kkbrd, devin, TASK, 0, "kkbrd", false); |
if (thread) { |
stdin = &kbrdout; |
thread_ready(thread); |
} |
return instance; |
} |
indev_t *kbrd_wire(kbrd_instance_t *instance, indev_t *sink) |
{ |
ASSERT(instance); |
ASSERT(sink); |
instance->sink = sink; |
thread_ready(instance->thread); |
return &instance->raw; |
} |
/** @} |
*/ |
/branches/dd/kernel/genarch/src/drivers/via-cuda/cuda.c |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/branches/dd/kernel/genarch/src/drivers/dsrln/dsrlnin.c |
---|
40,6 → 40,10 |
#include <arch/asm.h> |
#include <ddi/device.h> |
static indev_operations_t kbrdin_ops = { |
.poll = NULL |
}; |
static irq_ownership_t dsrlnin_claim(irq_t *irq) |
{ |
return IRQ_ACCEPT; |
50,35 → 54,29 |
dsrlnin_instance_t *instance = irq->instance; |
dsrlnin_t *dev = instance->dsrlnin; |
indev_push_character(instance->srlnin, pio_read_8(&dev->data)); |
indev_push_character(&instance->kbrdin, pio_read_8(&dev->data)); |
} |
dsrlnin_instance_t *dsrlnin_init(dsrlnin_t *dev, inr_t inr) |
indev_t *dsrlnin_init(dsrlnin_t *dev, inr_t inr) |
{ |
dsrlnin_instance_t *instance |
= malloc(sizeof(dsrlnin_instance_t), FRAME_ATOMIC); |
if (instance) { |
instance->dsrlnin = dev; |
instance->srlnin = NULL; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = dsrlnin_claim; |
instance->irq.handler = dsrlnin_irq_handler; |
instance->irq.instance = instance; |
} |
if (!instance) |
return NULL; |
return instance; |
} |
void dsrlnin_wire(dsrlnin_instance_t *instance, indev_t *srlnin) |
{ |
ASSERT(instance); |
ASSERT(srlnin); |
indev_initialize("dsrlnin", &instance->kbrdin, &kbrdin_ops); |
instance->srlnin = srlnin; |
instance->dsrlnin = dev; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = dsrlnin_claim; |
instance->irq.handler = dsrlnin_irq_handler; |
instance->irq.instance = instance; |
irq_register(&instance->irq); |
return &instance->kbrdin; |
} |
/** @} |
/branches/dd/kernel/genarch/src/drivers/i8042/i8042.c |
---|
44,6 → 44,10 |
#include <mm/slab.h> |
#include <ddi/device.h> |
static indev_operations_t kbrdin_ops = { |
.poll = NULL |
}; |
#define i8042_SET_COMMAND 0x60 |
#define i8042_COMMAND 0x69 |
#define i8042_CPU_RESET 0xfe |
70,46 → 74,35 |
if (((status = pio_read_8(&dev->status)) & i8042_BUFFER_FULL_MASK)) { |
uint8_t data = pio_read_8(&dev->data); |
indev_push_character(instance->kbrdin, data); |
indev_push_character(&instance->kbrdin, data); |
} |
} |
/**< Clear input buffer. */ |
static void i8042_clear_buffer(i8042_t *dev) |
{ |
while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) |
(void) pio_read_8(&dev->data); |
} |
/** Initialize i8042. */ |
i8042_instance_t *i8042_init(i8042_t *dev, inr_t inr) |
indev_t *i8042_init(i8042_t *dev, inr_t inr) |
{ |
i8042_instance_t *instance |
= malloc(sizeof(i8042_instance_t), FRAME_ATOMIC); |
if (instance) { |
instance->i8042 = dev; |
instance->kbrdin = NULL; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = i8042_claim; |
instance->irq.handler = i8042_irq_handler; |
instance->irq.instance = instance; |
} |
if (!instance) |
return NULL; |
return instance; |
} |
void i8042_wire(i8042_instance_t *instance, indev_t *kbrdin) |
{ |
ASSERT(instance); |
ASSERT(kbrdin); |
indev_initialize("i8042", &instance->kbrdin, &kbrdin_ops); |
instance->kbrdin = kbrdin; |
instance->i8042 = dev; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = i8042_claim; |
instance->irq.handler = i8042_irq_handler; |
instance->irq.instance = instance; |
irq_register(&instance->irq); |
i8042_clear_buffer(instance->i8042); |
/* Clear input buffer */ |
while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) |
(void) pio_read_8(&dev->data); |
return &instance->kbrdin; |
} |
/* Reset CPU by pulsing pin 0 */ |
117,7 → 110,9 |
{ |
interrupts_disable(); |
i8042_clear_buffer(dev); |
/* Clear input buffer */ |
while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) |
(void) pio_read_8(&dev->data); |
/* Reset CPU */ |
pio_write_8(&dev->status, i8042_CPU_RESET); |
/branches/dd/kernel/genarch/src/drivers/ega/ega.c |
---|
426,56 → 426,45 |
/* |
* This function takes care of scrolling. |
*/ |
static void ega_check_cursor(bool silent) |
static void ega_check_cursor(void) |
{ |
if (ega_cursor < EGA_SCREEN) |
return; |
memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2), |
(EGA_SCREEN - EGA_COLS) * 2); |
memmove((void *) backbuf, (void *) (backbuf + EGA_COLS * 2), |
(EGA_SCREEN - EGA_COLS) * 2); |
memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR); |
memsetw(backbuf + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR); |
if (!silent) { |
memmove((void *) videoram, (void *) (videoram + EGA_COLS * 2), |
(EGA_SCREEN - EGA_COLS) * 2); |
memsetw(videoram + (EGA_SCREEN - EGA_COLS) * 2, EGA_COLS, EMPTY_CHAR); |
} |
ega_cursor = ega_cursor - EGA_COLS; |
} |
static void ega_show_cursor(bool silent) |
static void ega_show_cursor(void) |
{ |
if (!silent) { |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
uint8_t stat = pio_read_8(ega_base + EGA_DATA_REG); |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
pio_write_8(ega_base + EGA_DATA_REG, stat & (~(1 << 5))); |
} |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
uint8_t stat = pio_read_8(ega_base + EGA_DATA_REG); |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0a); |
pio_write_8(ega_base + EGA_DATA_REG, stat & (~(1 << 5))); |
} |
static void ega_move_cursor(bool silent) |
static void ega_move_cursor(void) |
{ |
if (!silent) { |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff)); |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff)); |
} |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) ((ega_cursor >> 8) & 0xff)); |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
pio_write_8(ega_base + EGA_DATA_REG, (uint8_t) (ega_cursor & 0xff)); |
} |
static void ega_sync_cursor(bool silent) |
static void ega_sync_cursor(void) |
{ |
if (!silent) { |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG); |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG); |
ega_cursor = (hi << 8) | lo; |
} else |
ega_cursor = 0; |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0e); |
uint8_t hi = pio_read_8(ega_base + EGA_DATA_REG); |
pio_write_8(ega_base + EGA_INDEX_REG, 0x0f); |
uint8_t lo = pio_read_8(ega_base + EGA_DATA_REG); |
ega_cursor = (hi << 8) | lo; |
if (ega_cursor >= EGA_SCREEN) |
ega_cursor = 0; |
482,14 → 471,12 |
if ((ega_cursor % EGA_COLS) != 0) |
ega_cursor = (ega_cursor + EGA_COLS) - ega_cursor % EGA_COLS; |
memsetw(videoram + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
memsetw(backbuf + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
if (!silent) |
memsetw(videoram + ega_cursor * 2, EGA_SCREEN - ega_cursor, EMPTY_CHAR); |
ega_check_cursor(silent); |
ega_move_cursor(silent); |
ega_show_cursor(silent); |
ega_check_cursor(); |
ega_move_cursor(); |
ega_show_cursor(); |
} |
static void ega_display_char(wchar_t ch, bool silent) |
538,9 → 525,11 |
ega_cursor++; |
break; |
} |
ega_check_cursor(silent); |
ega_move_cursor(silent); |
ega_check_cursor(); |
if (!silent) |
ega_move_cursor(); |
spinlock_unlock(&egalock); |
interrupts_restore(ipl); |
} |
563,7 → 552,7 |
/* Synchronize the back buffer and cursor position. */ |
memcpy(backbuf, videoram, EGA_VRAM_SIZE); |
ega_sync_cursor(silent); |
ega_sync_cursor(); |
outdev_initialize("ega", &ega_console, &ega_ops); |
stdout = &ega_console; |
579,8 → 568,8 |
void ega_redraw(void) |
{ |
memcpy(videoram, backbuf, EGA_VRAM_SIZE); |
ega_move_cursor(silent); |
ega_show_cursor(silent); |
ega_move_cursor(); |
ega_show_cursor(); |
} |
/** @} |
/branches/dd/kernel/genarch/src/drivers/ns16550/ns16550.c |
---|
43,6 → 43,10 |
#define LSR_DATA_READY 0x01 |
static indev_operations_t kbrdin_ops = { |
.poll = NULL |
}; |
static irq_ownership_t ns16550_claim(irq_t *irq) |
{ |
ns16550_instance_t *instance = irq->instance; |
60,18 → 64,11 |
ns16550_t *dev = instance->ns16550; |
if (pio_read_8(&dev->lsr) & LSR_DATA_READY) { |
uint8_t data = pio_read_8(&dev->rbr); |
indev_push_character(instance->kbrdin, data); |
uint8_t x = pio_read_8(&dev->rbr); |
indev_push_character(&instance->kbrdin, x); |
} |
} |
/**< Clear input buffer. */ |
static void ns16550_clear_buffer(ns16550_t *dev) |
{ |
while ((pio_read_8(&dev->lsr) & LSR_DATA_READY)) |
(void) pio_read_8(&dev->rbr); |
} |
/** Initialize ns16550. |
* |
* @param dev Addrress of the beginning of the device in I/O space. |
80,43 → 77,38 |
* @param cir Clear interrupt function. |
* @param cir_arg First argument to cir. |
* |
* @return Keyboard instance or NULL on failure. |
* @return Keyboard device pointer or NULL on failure. |
* |
*/ |
ns16550_instance_t *ns16550_init(ns16550_t *dev, inr_t inr, cir_t cir, void *cir_arg) |
indev_t *ns16550_init(ns16550_t *dev, inr_t inr, cir_t cir, void *cir_arg) |
{ |
ns16550_instance_t *instance |
= malloc(sizeof(ns16550_instance_t), FRAME_ATOMIC); |
if (instance) { |
instance->ns16550 = dev; |
instance->kbrdin = NULL; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = ns16550_claim; |
instance->irq.handler = ns16550_irq_handler; |
instance->irq.instance = instance; |
instance->irq.cir = cir; |
instance->irq.cir_arg = cir_arg; |
} |
if (!instance) |
return NULL; |
return instance; |
} |
void ns16550_wire(ns16550_instance_t *instance, indev_t *kbrdin) |
{ |
ASSERT(instance); |
ASSERT(kbrdin); |
indev_initialize("ns16550", &instance->kbrdin, &kbrdin_ops); |
instance->kbrdin = kbrdin; |
instance->ns16550 = dev; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = ns16550_claim; |
instance->irq.handler = ns16550_irq_handler; |
instance->irq.instance = instance; |
instance->irq.cir = cir; |
instance->irq.cir_arg = cir_arg; |
irq_register(&instance->irq); |
ns16550_clear_buffer(instance->ns16550); |
while ((pio_read_8(&dev->lsr) & LSR_DATA_READY)) |
(void) pio_read_8(&dev->rbr); |
/* Enable interrupts */ |
pio_write_8(&instance->ns16550->ier, IER_ERBFI); |
pio_write_8(&instance->ns16550->mcr, MCR_OUT2); |
pio_write_8(&dev->ier, IER_ERBFI); |
pio_write_8(&dev->mcr, MCR_OUT2); |
return &instance->kbrdin; |
} |
/** @} |
/branches/dd/kernel/genarch/src/drivers/z8530/z8530.c |
---|
41,6 → 41,10 |
#include <mm/slab.h> |
#include <ddi/device.h> |
static indev_operations_t kbrdin_ops = { |
.poll = NULL |
}; |
static inline void z8530_write(ioport8_t *ctl, uint8_t reg, uint8_t val) |
{ |
/* |
78,58 → 82,51 |
z8530_t *dev = instance->z8530; |
if (z8530_read(&dev->ctl_a, RR0) & RR0_RCA) { |
uint8_t data = z8530_read(&dev->ctl_a, RR8); |
indev_push_character(instance->kbrdin, data); |
uint8_t x = z8530_read(&dev->ctl_a, RR8); |
indev_push_character(&instance->kbrdin, x); |
} |
} |
/** Initialize z8530. */ |
z8530_instance_t *z8530_init(z8530_t *dev, inr_t inr, cir_t cir, void *cir_arg) |
indev_t *z8530_init(z8530_t *dev, inr_t inr, cir_t cir, void *cir_arg) |
{ |
z8530_instance_t *instance |
= malloc(sizeof(z8530_instance_t), FRAME_ATOMIC); |
if (instance) { |
instance->z8530 = dev; |
instance->kbrdin = NULL; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = z8530_claim; |
instance->irq.handler = z8530_irq_handler; |
instance->irq.instance = instance; |
instance->irq.cir = cir; |
instance->irq.cir_arg = cir_arg; |
} |
if (!instance) |
return false; |
return instance; |
} |
void z8530_wire(z8530_instance_t *instance, indev_t *kbrdin) |
{ |
ASSERT(instance); |
ASSERT(kbrdin); |
indev_initialize("z8530", &instance->kbrdin, &kbrdin_ops); |
instance->kbrdin = kbrdin; |
instance->z8530 = dev; |
irq_initialize(&instance->irq); |
instance->irq.devno = device_assign_devno(); |
instance->irq.inr = inr; |
instance->irq.claim = z8530_claim; |
instance->irq.handler = z8530_irq_handler; |
instance->irq.instance = instance; |
instance->irq.cir = cir; |
instance->irq.cir_arg = cir_arg; |
irq_register(&instance->irq); |
(void) z8530_read(&instance->z8530->ctl_a, RR8); |
(void) z8530_read(&dev->ctl_a, RR8); |
/* |
* Clear any pending TX interrupts or we never manage |
* to set FHC UART interrupt state to idle. |
*/ |
z8530_write(&instance->z8530->ctl_a, WR0, WR0_TX_IP_RST); |
z8530_write(&dev->ctl_a, WR0, WR0_TX_IP_RST); |
/* interrupt on all characters */ |
z8530_write(&instance->z8530->ctl_a, WR1, WR1_IARCSC); |
z8530_write(&dev->ctl_a, WR1, WR1_IARCSC); |
/* 8 bits per character and enable receiver */ |
z8530_write(&instance->z8530->ctl_a, WR3, WR3_RX8BITSCH | WR3_RX_ENABLE); |
z8530_write(&dev->ctl_a, WR3, WR3_RX8BITSCH | WR3_RX_ENABLE); |
/* Master Interrupt Enable. */ |
z8530_write(&instance->z8530->ctl_a, WR9, WR9_MIE); |
z8530_write(&dev->ctl_a, WR9, WR9_MIE); |
return &instance->kbrdin; |
} |
/** @} |
/branches/dd/kernel/genarch/src/srln/srln.c |
---|
41,18 → 41,20 |
#include <arch.h> |
#include <string.h> |
static indev_operations_t srln_raw_ops = { |
static indev_t srlnout; |
indev_operations_t srlnout_ops = { |
.poll = NULL |
}; |
static void ksrln(void *arg) |
{ |
srln_instance_t *instance = (srln_instance_t *) arg; |
indev_t *in = (indev_t *) arg; |
bool cr = false; |
uint32_t escape = 0; |
while (true) { |
wchar_t ch = indev_pop_character(&instance->raw); |
wchar_t ch = _getc(in); |
/* ANSI escape sequence processing */ |
if (escape != 0) { |
120,40 → 122,21 |
if (ch == 0x7f) |
ch = '\b'; |
indev_push_character(instance->sink, ch); |
indev_push_character(stdin, ch); |
} |
} |
srln_instance_t *srln_init(void) |
void srln_init(indev_t *devin) |
{ |
srln_instance_t *instance |
= malloc(sizeof(srln_instance_t), FRAME_ATOMIC); |
if (instance) { |
instance->thread |
= thread_create(ksrln, (void *) instance, TASK, 0, "ksrln", false); |
if (!instance->thread) { |
free(instance); |
return NULL; |
} |
instance->sink = NULL; |
indev_initialize("srln", &instance->raw, &srln_raw_ops); |
indev_initialize("srln", &srlnout, &srlnout_ops); |
thread_t *thread |
= thread_create(ksrln, devin, TASK, 0, "ksrln", false); |
if (thread) { |
stdin = &srlnout; |
thread_ready(thread); |
} |
return instance; |
} |
indev_t *srln_wire(srln_instance_t *instance, indev_t *sink) |
{ |
ASSERT(instance); |
ASSERT(sink); |
instance->sink = sink; |
thread_ready(instance->thread); |
return &instance->raw; |
} |
/** @} |
*/ |
/branches/dd/kernel/genarch/Makefile.inc |
---|
93,11 → 93,6 |
genarch/src/drivers/z8530/z8530.c |
endif |
ifeq ($(CONFIG_VIA_CUDA),y) |
GENARCH_SOURCES += \ |
genarch/src/drivers/via-cuda/cuda.c |
endif |
ifeq ($(CONFIG_PC_KBD),y) |
GENARCH_SOURCES += \ |
genarch/src/kbrd/kbrd.c \ |
/branches/dd/kernel/generic/include/console/chardev.h |
---|
89,13 → 89,10 |
extern void indev_initialize(char *name, indev_t *indev, |
indev_operations_t *op); |
extern void indev_push_character(indev_t *indev, wchar_t ch); |
extern wchar_t indev_pop_character(indev_t *indev); |
extern void outdev_initialize(char *name, outdev_t *outdev, |
outdev_operations_t *op); |
extern bool check_poll(indev_t *indev); |
#endif /* KERN_CHARDEV_H_ */ |
/** @} |
/branches/dd/kernel/generic/include/console/console.h |
---|
40,15 → 40,17 |
extern indev_t *stdin; |
extern outdev_t *stdout; |
extern bool silent; |
extern indev_t *stdin_wire(void); |
extern void console_init(void); |
extern void klog_init(void); |
extern void klog_update(void); |
extern bool check_poll(indev_t *indev); |
extern wchar_t getc(indev_t *indev); |
extern wchar_t _getc(indev_t *indev); |
extern count_t gets(indev_t *indev, char *buf, size_t buflen); |
extern unative_t sys_klog(int fd, const void *buf, size_t size); |
/branches/dd/kernel/generic/include/ipc/ipc.h |
---|
111,25 → 111,6 |
/* System-specific methods - only through special syscalls |
* These methods have special behaviour |
*/ |
/** Clone connection. |
* |
* The calling task clones one of its phones for the callee. |
* |
* - ARG1 - The caller sets ARG1 to the phone of the cloned connection. |
* - The callee gets the new phone from ARG1. |
* - on answer, the callee acknowledges the new connection by sending EOK back |
* or the kernel closes it |
*/ |
#define IPC_M_CONNECTION_CLONE 1 |
/** Protocol for CONNECT - ME |
* |
* Through this call, the recipient learns about the new cloned connection. |
* |
* - ARG5 - the kernel sets ARG5 to contain the hash of the used phone |
* - on asnwer, the callee acknowledges the new connection by sending EOK back |
* or the kernel closes it |
*/ |
#define IPC_M_CONNECT_ME 2 |
/** Protocol for CONNECT - TO - ME |
* |
* Calling process asks the callee to create a callback connection, |
146,7 → 127,7 |
* - the allocated phoneid is passed to userspace |
* (on the receiving side) as ARG5 of the call. |
*/ |
#define IPC_M_CONNECT_TO_ME 3 |
#define IPC_M_CONNECT_TO_ME 1 |
/** Protocol for CONNECT - ME - TO |
* |
* Calling process asks the callee to create for him a new connection. |
164,11 → 145,11 |
* - recepient may forward message. |
* |
*/ |
#define IPC_M_CONNECT_ME_TO 4 |
#define IPC_M_CONNECT_ME_TO 2 |
/** This message is sent to answerbox when the phone |
* is hung up |
*/ |
#define IPC_M_PHONE_HUNGUP 5 |
#define IPC_M_PHONE_HUNGUP 3 |
/** Send as_area over IPC. |
* - ARG1 - source as_area base address |
178,7 → 159,7 |
* on answer, the recipient must set: |
* - ARG1 - dst as_area base adress |
*/ |
#define IPC_M_SHARE_OUT 6 |
#define IPC_M_SHARE_OUT 4 |
/** Receive as_area over IPC. |
* - ARG1 - destination as_area base address |
190,7 → 171,7 |
* - ARG1 - source as_area base address |
* - ARG2 - flags that will be used for sharing |
*/ |
#define IPC_M_SHARE_IN 7 |
#define IPC_M_SHARE_IN 5 |
/** Send data to another address space over IPC. |
* - ARG1 - source address space virtual address |
201,7 → 182,7 |
* - ARG1 - final destination address space virtual address |
* - ARG2 - final size of data to be copied |
*/ |
#define IPC_M_DATA_WRITE 8 |
#define IPC_M_DATA_WRITE 6 |
/** Receive data from another address space over IPC. |
* - ARG1 - destination virtual address in the source address space |
212,13 → 193,13 |
* - ARG1 - source virtual address in the destination address space |
* - ARG2 - final size of data to be copied |
*/ |
#define IPC_M_DATA_READ 9 |
#define IPC_M_DATA_READ 7 |
/** Debug the recipient. |
* - ARG1 - specifies the debug method (from udebug_method_t) |
* - other arguments are specific to the debug method |
*/ |
#define IPC_M_DEBUG_ALL 10 |
#define IPC_M_DEBUG_ALL 8 |
/* Well-known methods */ |
#define IPC_M_LAST_SYSTEM 511 |
/branches/dd/kernel/generic/include/ipc/ipcrsc.h |
---|
35,11 → 35,8 |
#ifndef KERN_IPCRSC_H_ |
#define KERN_IPCRSC_H_ |
#include <proc/task.h> |
#include <ipc/ipc.h> |
extern call_t * get_call(unative_t callid); |
extern int phone_alloc(task_t *t); |
extern int phone_alloc(void); |
extern void phone_connect(int phoneid, answerbox_t *box); |
extern void phone_dealloc(int phoneid); |
/branches/dd/kernel/generic/include/byteorder.h |
---|
36,7 → 36,6 |
#define KERN_BYTEORDER_H_ |
#include <arch/byteorder.h> |
#include <arch/types.h> |
#if !(defined(ARCH_IS_BIG_ENDIAN) ^ defined(ARCH_IS_LITTLE_ENDIAN)) |
#error The architecture must be either big-endian or little-endian. |
/branches/dd/kernel/generic/src/main/kinit.c |
---|
218,11 → 218,19 |
} |
/* |
* Run user tasks. |
* Run user tasks with small delays |
* to avoid intermixed klog output. |
* |
* TODO: This certainly does not guarantee |
* anything, it just works in most of the |
* cases. Some better way how to achieve |
* nice klog output should be found. |
*/ |
for (i = 0; i < init.cnt; i++) { |
if (programs[i].task != NULL) |
if (programs[i].task != NULL) { |
program_ready(&programs[i]); |
thread_usleep(10000); |
} |
} |
#ifdef CONFIG_KCONSOLE |
/branches/dd/kernel/generic/src/main/main.c |
---|
250,10 → 250,10 |
count_t i; |
for (i = 0; i < init.cnt; i++) |
LOG("init[%" PRIc "].addr=%#" PRIp ", init[%" PRIc |
"].size=%#" PRIs, i, init.tasks[i].addr, i, |
"].size=%#" PRIs "\n", i, init.tasks[i].addr, i, |
init.tasks[i].size); |
} else |
printf("No init binaries found.\n"); |
printf("No init binaries found\n"); |
LOG_EXEC(ipc_init()); |
LOG_EXEC(event_init()); |
/branches/dd/kernel/generic/src/console/console.c |
---|
44,6 → 44,7 |
#include <ipc/event.h> |
#include <ipc/irq.h> |
#include <arch.h> |
#include <func.h> |
#include <print.h> |
#include <putchar.h> |
#include <atomic.h> |
69,6 → 70,9 |
/** Number of stored kernel log characters for uspace */ |
static size_t klog_uspace = 0; |
/** Silence output */ |
bool silent = false; |
/** Kernel log spinlock */ |
SPINLOCK_INITIALIZE(klog_lock); |
75,28 → 79,10 |
/** Physical memory area used for klog buffer */ |
static parea_t klog_parea; |
static indev_operations_t stdin_ops = { |
.poll = NULL |
}; |
/** Silence output */ |
bool silent = false; |
/** Standard input and output character devices */ |
indev_t *stdin = NULL; |
outdev_t *stdout = NULL; |
indev_t *stdin_wire(void) |
{ |
if (stdin == NULL) { |
stdin = malloc(sizeof(indev_t), FRAME_ATOMIC); |
if (stdin != NULL) |
indev_initialize("stdin", stdin, &stdin_ops); |
} |
return stdin; |
} |
/** Initialize kernel logging facility |
* |
* The shared area contains kernel cyclic buffer. Userspace application may |
124,14 → 110,8 |
void grab_console(void) |
{ |
bool prev = silent; |
silent = false; |
arch_grab_console(); |
/* Force the console to print the prompt */ |
if ((stdin) && (prev)) |
indev_push_character(stdin, '\n'); |
} |
void release_console(void) |
158,6 → 138,55 |
return true; |
} |
bool check_poll(indev_t *indev) |
{ |
if (indev == NULL) |
return false; |
if (indev->op == NULL) |
return false; |
return (indev->op->poll != NULL); |
} |
/** Get character from input character device. Do not echo character. |
* |
* @param indev Input character device. |
* @return Character read. |
* |
*/ |
wchar_t _getc(indev_t *indev) |
{ |
if (atomic_get(&haltstate)) { |
/* If we are here, we are hopefully on the processor that |
* issued the 'halt' command, so proceed to read the character |
* directly from input |
*/ |
if (check_poll(indev)) |
return indev->op->poll(indev); |
/* No other way of interacting with user */ |
interrupts_disable(); |
if (CPU) |
printf("cpu%u: ", CPU->id); |
else |
printf("cpu: "); |
printf("halted (no polling input)\n"); |
cpu_halt(); |
} |
waitq_sleep(&indev->wq); |
ipl_t ipl = interrupts_disable(); |
spinlock_lock(&indev->lock); |
wchar_t ch = indev->buffer[(indev->index - indev->counter) % INDEV_BUFLEN]; |
indev->counter--; |
spinlock_unlock(&indev->lock); |
interrupts_restore(ipl); |
return ch; |
} |
/** Get string from input character device. |
* |
* Read characters from input character device until first occurrence |
177,7 → 206,7 |
buf[offset] = 0; |
wchar_t ch; |
while ((ch = indev_pop_character(indev)) != '\n') { |
while ((ch = _getc(indev)) != '\n') { |
if (ch == '\b') { |
if (count > 0) { |
/* Space, backspace, space */ |
203,7 → 232,7 |
/** Get character from input device & echo it to screen */ |
wchar_t getc(indev_t *indev) |
{ |
wchar_t ch = indev_pop_character(indev); |
wchar_t ch = _getc(indev); |
putchar(ch); |
return ch; |
} |
/branches/dd/kernel/generic/src/console/cmd.c |
---|
956,7 → 956,6 |
release_console(); |
event_notify_0(EVENT_KCONSOLE); |
indev_pop_character(stdin); |
return 1; |
} |
/branches/dd/kernel/generic/src/console/chardev.c |
---|
35,9 → 35,6 |
#include <console/chardev.h> |
#include <synch/waitq.h> |
#include <synch/spinlock.h> |
#include <print.h> |
#include <func.h> |
#include <arch.h> |
/** Initialize input character device. |
* |
82,46 → 79,6 |
spinlock_unlock(&indev->lock); |
} |
/** Pop character from input character device. |
* |
* @param indev Input character device. |
* |
* @return Character read. |
* |
*/ |
wchar_t indev_pop_character(indev_t *indev) |
{ |
if (atomic_get(&haltstate)) { |
/* If we are here, we are hopefully on the processor that |
* issued the 'halt' command, so proceed to read the character |
* directly from input |
*/ |
if (check_poll(indev)) |
return indev->op->poll(indev); |
/* No other way of interacting with user */ |
interrupts_disable(); |
if (CPU) |
printf("cpu%u: ", CPU->id); |
else |
printf("cpu: "); |
printf("halted (no polling input)\n"); |
cpu_halt(); |
} |
waitq_sleep(&indev->wq); |
ipl_t ipl = interrupts_disable(); |
spinlock_lock(&indev->lock); |
wchar_t ch = indev->buffer[(indev->index - indev->counter) % INDEV_BUFLEN]; |
indev->counter--; |
spinlock_unlock(&indev->lock); |
interrupts_restore(ipl); |
return ch; |
} |
/** Initialize output character device. |
* |
* @param outdev Output character device. |
136,16 → 93,5 |
outdev->op = op; |
} |
bool check_poll(indev_t *indev) |
{ |
if (indev == NULL) |
return false; |
if (indev->op == NULL) |
return false; |
return (indev->op->poll != NULL); |
} |
/** @} |
*/ |
/branches/dd/kernel/generic/src/console/kconsole.c |
---|
245,7 → 245,7 |
current[0] = 0; |
while (true) { |
wchar_t ch = indev_pop_character(indev); |
wchar_t ch = _getc(indev); |
if (ch == '\n') { |
/* Enter */ |
582,7 → 582,7 |
case ARG_TYPE_STRING: |
buf = (char *) cmd->argv[i].buffer; |
str_ncpy(buf, cmd->argv[i].len, cmdline + start, |
end - start); |
(end - start) + 1); |
break; |
case ARG_TYPE_INT: |
if (!parse_int_arg(cmdline + start, end - start, |
653,7 → 653,7 |
printf("%s", msg); |
if (kcon) |
indev_pop_character(stdin); |
_getc(stdin); |
else |
printf("Type \"exit\" to leave the console.\n"); |
/branches/dd/kernel/generic/src/proc/program.c |
---|
133,7 → 133,7 |
/* Register image as the program loader */ |
ASSERT(program_loader == NULL); |
program_loader = image_addr; |
LOG("Registered program loader at 0x%" PRIp "\n", |
printf("Registered program loader at 0x%" PRIp "\n", |
image_addr); |
return EOK; |
} |
/branches/dd/kernel/generic/src/lib/string.c |
---|
641,12 → 641,10 |
{ |
wchar_t acc; |
size_t off = 0; |
size_t last = 0; |
while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) { |
if (acc == ch) |
return (str + last); |
last = off; |
return (str + off); |
} |
return NULL; |
/branches/dd/kernel/generic/src/mm/slab.c |
---|
936,7 → 936,7 |
void *malloc(unsigned int size, int flags) |
{ |
ASSERT(_slab_initialized); |
ASSERT(size <= (1 << SLAB_MAX_MALLOC_W)); |
ASSERT(size && size <= (1 << SLAB_MAX_MALLOC_W)); |
if (size < (1 << SLAB_MIN_MALLOC_W)) |
size = (1 << SLAB_MIN_MALLOC_W); |
/branches/dd/kernel/generic/src/syscall/syscall.c |
---|
59,19 → 59,9 |
unative_t a4, unative_t a5, unative_t a6, unative_t id) |
{ |
unative_t rc; |
#ifdef CONFIG_UDEBUG |
bool debug; |
/* |
* Early check for undebugged tasks. We do not lock anything as this |
* test need not be precise in either way. |
*/ |
debug = THREAD->udebug.active; |
if (debug) { |
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false); |
} |
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, 0, false); |
#endif |
if (id < SYSCALL_END) { |
86,17 → 76,14 |
thread_exit(); |
#ifdef CONFIG_UDEBUG |
if (debug) { |
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true); |
udebug_syscall_event(a1, a2, a3, a4, a5, a6, id, rc, true); |
/* |
* Stopping point needed for tasks that only invoke |
* non-blocking system calls. Not needed if the task |
* is not being debugged (it cannot block here). |
*/ |
udebug_stoppable_begin(); |
udebug_stoppable_end(); |
} |
/* |
* Stopping point needed for tasks that only invoke non-blocking |
* system calls. |
*/ |
udebug_stoppable_begin(); |
udebug_stoppable_end(); |
#endif |
return rc; |
/branches/dd/kernel/generic/src/ipc/ipc.c |
---|
328,10 → 328,12 |
list_remove(&phone->link); |
spinlock_unlock(&box->lock); |
call = ipc_call_alloc(0); |
IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP); |
call->flags |= IPC_CALL_DISCARD_ANSWER; |
_ipc_call(phone, box, call); |
if (phone->state != IPC_PHONE_SLAMMED) { |
call = ipc_call_alloc(0); |
IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP); |
call->flags |= IPC_CALL_DISCARD_ANSWER; |
_ipc_call(phone, box, call); |
} |
} |
phone->state = IPC_PHONE_HUNGUP; |
/branches/dd/kernel/generic/src/ipc/ipcrsc.c |
---|
160,29 → 160,27 |
return result; |
} |
/** Allocate new phone slot in the specified task. |
/** Allocate new phone slot in the current TASK structure. |
* |
* @param t Task for which to allocate a new phone. |
* |
* @return New phone handle or -1 if the phone handle limit is |
* exceeded. |
*/ |
int phone_alloc(task_t *t) |
int phone_alloc(void) |
{ |
int i; |
spinlock_lock(&t->lock); |
spinlock_lock(&TASK->lock); |
for (i = 0; i < IPC_MAX_PHONES; i++) { |
if (t->phones[i].state == IPC_PHONE_HUNGUP && |
atomic_get(&t->phones[i].active_calls) == 0) |
t->phones[i].state = IPC_PHONE_FREE; |
if (TASK->phones[i].state == IPC_PHONE_HUNGUP && |
atomic_get(&TASK->phones[i].active_calls) == 0) |
TASK->phones[i].state = IPC_PHONE_FREE; |
if (t->phones[i].state == IPC_PHONE_FREE) { |
t->phones[i].state = IPC_PHONE_CONNECTING; |
if (TASK->phones[i].state == IPC_PHONE_FREE) { |
TASK->phones[i].state = IPC_PHONE_CONNECTING; |
break; |
} |
} |
spinlock_unlock(&t->lock); |
spinlock_unlock(&TASK->lock); |
if (i == IPC_MAX_PHONES) |
return -1; |
/branches/dd/kernel/generic/src/ipc/kbox.c |
---|
84,10 → 84,10 |
interrupts_restore(ipl); |
if (have_kb_thread) { |
LOG("Join kb.thread."); |
LOG("join kb.thread..\n"); |
thread_join(TASK->kb.thread); |
thread_detach(TASK->kb.thread); |
LOG("...join done."); |
LOG("join done\n"); |
TASK->kb.thread = NULL; |
} |
108,10 → 108,12 |
{ |
ipl_t ipl; |
LOG("kbox_proc_phone_hungup()\n"); |
/* Was it our debugger, who hung up? */ |
if (call->sender == TASK->udebug.debugger) { |
/* Terminate debugging session (if any). */ |
LOG("Terminate debugging session."); |
LOG("kbox: terminate debug session\n"); |
ipl = interrupts_disable(); |
spinlock_lock(&TASK->lock); |
udebug_task_cleanup(TASK); |
118,10 → 120,10 |
spinlock_unlock(&TASK->lock); |
interrupts_restore(ipl); |
} else { |
LOG("Was not debugger."); |
LOG("kbox: was not debugger\n"); |
} |
LOG("Continue with hangup message."); |
LOG("kbox: continue with hangup message\n"); |
IPC_SET_RETVAL(call->data, 0); |
ipc_answer(&TASK->kb.box, call); |
143,7 → 145,7 |
} |
mutex_unlock(&TASK->kb.cleanup_lock); |
LOG("Phone list is empty."); |
LOG("phone list is empty\n"); |
*last = true; |
} else { |
*last = false; |
167,7 → 169,7 |
bool done; |
(void)arg; |
LOG("Starting."); |
LOG("kbox_thread_proc()\n"); |
done = false; |
while (!done) { |
199,7 → 201,7 |
} |
} |
LOG("Exiting."); |
LOG("kbox: finished\n"); |
} |
248,7 → 250,7 |
return EINVAL; |
} |
newphid = phone_alloc(TASK); |
newphid = phone_alloc(); |
if (newphid < 0) { |
mutex_unlock(&ta->kb.cleanup_lock); |
return ELIMIT; |
/branches/dd/kernel/generic/src/ipc/sysipc.c |
---|
93,8 → 93,6 |
static inline int method_is_forwardable(unative_t method) |
{ |
switch (method) { |
case IPC_M_CONNECTION_CLONE: |
case IPC_M_CONNECT_ME: |
case IPC_M_PHONE_HUNGUP: |
/* This message is meant only for the original recipient. */ |
return 0; |
142,8 → 140,6 |
static inline int answer_need_old(call_t *call) |
{ |
switch (IPC_GET_METHOD(call->data)) { |
case IPC_M_CONNECTION_CLONE: |
case IPC_M_CONNECT_ME: |
case IPC_M_CONNECT_TO_ME: |
case IPC_M_CONNECT_ME_TO: |
case IPC_M_SHARE_OUT: |
186,48 → 182,9 |
if (!olddata) |
return 0; |
if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECTION_CLONE) { |
phoneid = IPC_GET_ARG1(*olddata); |
phone_t *phone = &TASK->phones[phoneid]; |
if (IPC_GET_RETVAL(answer->data) != EOK) { |
/* |
* The recipient of the cloned phone rejected the offer. |
* In this case, the connection was established at the |
* request time and therefore we need to slam the phone. |
* We don't merely hangup as that would result in |
* sending IPC_M_HUNGUP to the third party on the |
* other side of the cloned phone. |
*/ |
mutex_lock(&phone->lock); |
if (phone->state == IPC_PHONE_CONNECTED) { |
spinlock_lock(&phone->callee->lock); |
list_remove(&phone->link); |
phone->state = IPC_PHONE_SLAMMED; |
spinlock_unlock(&phone->callee->lock); |
} |
mutex_unlock(&phone->lock); |
} |
} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_ME) { |
phone_t *phone = (phone_t *)IPC_GET_ARG5(*olddata); |
if (IPC_GET_RETVAL(answer->data) != EOK) { |
/* |
* The other party on the cloned phoned rejected our |
* request for connection on the protocol level. |
* We need to break the connection without sending |
* IPC_M_HUNGUP back. |
*/ |
mutex_lock(&phone->lock); |
if (phone->state == IPC_PHONE_CONNECTED) { |
spinlock_lock(&phone->callee->lock); |
list_remove(&phone->link); |
phone->state = IPC_PHONE_SLAMMED; |
spinlock_unlock(&phone->callee->lock); |
} |
mutex_unlock(&phone->lock); |
} |
} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_TO_ME) { |
if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_TO_ME) { |
phoneid = IPC_GET_ARG5(*olddata); |
if (IPC_GET_RETVAL(answer->data) != EOK) { |
if (IPC_GET_RETVAL(answer->data)) { |
/* The connection was not accepted */ |
phone_dealloc(phoneid); |
} else { |
239,7 → 196,7 |
} |
} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_ME_TO) { |
/* If the users accepted call, connect */ |
if (IPC_GET_RETVAL(answer->data) == EOK) { |
if (!IPC_GET_RETVAL(answer->data)) { |
ipc_phone_connect((phone_t *) IPC_GET_ARG5(*olddata), |
&TASK->answerbox); |
} |
351,48 → 308,8 |
int rc; |
switch (IPC_GET_METHOD(call->data)) { |
case IPC_M_CONNECTION_CLONE: { |
phone_t *cloned_phone; |
GET_CHECK_PHONE(cloned_phone, IPC_GET_ARG1(call->data), |
return ENOENT); |
if (cloned_phone < phone) { |
mutex_lock(&cloned_phone->lock); |
mutex_lock(&phone->lock); |
} else { |
mutex_lock(&phone->lock); |
mutex_lock(&cloned_phone->lock); |
} |
if ((cloned_phone->state != IPC_PHONE_CONNECTED) || |
phone->state != IPC_PHONE_CONNECTED) { |
mutex_unlock(&cloned_phone->lock); |
mutex_unlock(&phone->lock); |
return EINVAL; |
} |
/* |
* We can be pretty sure now that both tasks exist and we are |
* connected to them. As we continue to hold the phone locks, |
* we are effectively preventing them from finishing their |
* potential cleanup. |
*/ |
newphid = phone_alloc(phone->callee->task); |
if (newphid < 0) { |
mutex_unlock(&cloned_phone->lock); |
mutex_unlock(&phone->lock); |
return ELIMIT; |
} |
ipc_phone_connect(&phone->callee->task->phones[newphid], |
cloned_phone->callee); |
mutex_unlock(&cloned_phone->lock); |
mutex_unlock(&phone->lock); |
/* Set the new phone for the callee. */ |
IPC_SET_ARG1(call->data, newphid); |
break; |
} |
case IPC_M_CONNECT_ME: |
IPC_SET_ARG5(call->data, (unative_t) phone); |
break; |
case IPC_M_CONNECT_ME_TO: |
newphid = phone_alloc(TASK); |
newphid = phone_alloc(); |
if (newphid < 0) |
return ELIMIT; |
/* Set arg5 for server */ |
415,7 → 332,7 |
src = IPC_GET_ARG1(call->data); |
size = IPC_GET_ARG2(call->data); |
if (size > DATA_XFER_LIMIT) |
if ((size <= 0) || (size > DATA_XFER_LIMIT)) |
return ELIMIT; |
call->buffer = (uint8_t *) malloc(size, 0); |
482,7 → 399,7 |
int phoneid; |
if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME) { |
phoneid = phone_alloc(TASK); |
phoneid = phone_alloc(); |
if (phoneid < 0) { /* Failed to allocate phone */ |
IPC_SET_RETVAL(call->data, ELIMIT); |
ipc_answer(box, call); |
/branches/dd/kernel/generic/src/interrupt/interrupt.c |
---|
145,7 → 145,7 |
if (((i + 1) % 20) == 0) { |
printf(" -- Press any key to continue -- "); |
spinlock_unlock(&exctbl_lock); |
indev_pop_character(stdin); |
_getc(stdin); |
spinlock_lock(&exctbl_lock); |
printf("\n"); |
} |
/branches/dd/kernel/generic/src/udebug/udebug.c |
---|
98,6 → 98,27 |
waitq_sleep_finish(wq, rc, ipl); |
} |
/** Do a preliminary check that a debugging session is in progress. |
* |
* This only requires the THREAD->udebug.lock mutex (and not TASK->udebug.lock |
* mutex). For an undebugged task, this will never block (while there could be |
* collisions by different threads on the TASK mutex), thus improving SMP |
* perormance for undebugged tasks. |
* |
* @return True if the thread was in a debugging session when the function |
* checked, false otherwise. |
*/ |
static bool udebug_thread_precheck(void) |
{ |
bool res; |
mutex_lock(&THREAD->udebug.lock); |
res = THREAD->udebug.active; |
mutex_unlock(&THREAD->udebug.lock); |
return res; |
} |
/** Start of stoppable section. |
* |
* A stoppable section is a section of code where if the thread can be stoped. In other words, |
116,6 → 137,11 |
ASSERT(THREAD); |
ASSERT(TASK); |
/* Early check for undebugged tasks */ |
if (!udebug_thread_precheck()) { |
return; |
} |
mutex_lock(&TASK->udebug.lock); |
nsc = --TASK->udebug.not_stoppable_count; |
176,6 → 202,11 |
*/ |
void udebug_stoppable_end(void) |
{ |
/* Early check for undebugged tasks */ |
if (!udebug_thread_precheck()) { |
return; |
} |
restart: |
mutex_lock(&TASK->udebug.lock); |
mutex_lock(&THREAD->udebug.lock); |
224,6 → 255,11 |
etype = end_variant ? UDEBUG_EVENT_SYSCALL_E : UDEBUG_EVENT_SYSCALL_B; |
/* Early check for undebugged tasks */ |
if (!udebug_thread_precheck()) { |
return; |
} |
mutex_lock(&TASK->udebug.lock); |
mutex_lock(&THREAD->udebug.lock); |
235,7 → 271,7 |
return; |
} |
/* Fill in the GO response. */ |
//printf("udebug_syscall_event\n"); |
call = THREAD->udebug.go_call; |
THREAD->udebug.go_call = NULL; |
243,6 → 279,7 |
IPC_SET_ARG1(call->data, etype); |
IPC_SET_ARG2(call->data, id); |
IPC_SET_ARG3(call->data, rc); |
//printf("udebug_syscall_event/ipc_answer\n"); |
THREAD->udebug.syscall_args[0] = a1; |
THREAD->udebug.syscall_args[1] = a2; |
292,19 → 329,21 |
thread_attach(t, ta); |
LOG("Check state"); |
LOG("udebug_thread_b_event\n"); |
LOG("- check state\n"); |
/* Must only generate events when in debugging session */ |
if (THREAD->udebug.active != true) { |
LOG("udebug.active: %s, udebug.go: %s", |
THREAD->udebug.active ? "Yes(+)" : "No", |
THREAD->udebug.go ? "Yes(-)" : "No"); |
LOG("- udebug.active: %s, udebug.go: %s\n", |
THREAD->udebug.active ? "yes(+)" : "no(-)", |
THREAD->udebug.go ? "yes(-)" : "no(+)"); |
mutex_unlock(&THREAD->udebug.lock); |
mutex_unlock(&TASK->udebug.lock); |
return; |
} |
LOG("Trigger event"); |
LOG("- trigger event\n"); |
call = THREAD->udebug.go_call; |
THREAD->udebug.go_call = NULL; |
IPC_SET_RETVAL(call->data, 0); |
324,7 → 363,7 |
mutex_unlock(&THREAD->udebug.lock); |
mutex_unlock(&TASK->udebug.lock); |
LOG("Wait for Go"); |
LOG("- sleep\n"); |
udebug_wait_for_go(&THREAD->udebug.go_wq); |
} |
340,19 → 379,21 |
mutex_lock(&TASK->udebug.lock); |
mutex_lock(&THREAD->udebug.lock); |
LOG("Check state"); |
LOG("udebug_thread_e_event\n"); |
LOG("- check state\n"); |
/* Must only generate events when in debugging session. */ |
if (THREAD->udebug.active != true) { |
LOG("udebug.active: %s, udebug.go: %s", |
THREAD->udebug.active ? "Yes" : "No", |
THREAD->udebug.go ? "Yes" : "No"); |
/* printf("- udebug.active: %s, udebug.go: %s\n", |
THREAD->udebug.active ? "yes(+)" : "no(-)", |
THREAD->udebug.go ? "yes(-)" : "no(+)");*/ |
mutex_unlock(&THREAD->udebug.lock); |
mutex_unlock(&TASK->udebug.lock); |
return; |
} |
LOG("Trigger event"); |
LOG("- trigger event\n"); |
call = THREAD->udebug.go_call; |
THREAD->udebug.go_call = NULL; |
IPC_SET_RETVAL(call->data, 0); |
391,13 → 432,15 |
int flags; |
ipl_t ipl; |
LOG("udebug_task_cleanup()\n"); |
LOG("task %" PRIu64 "\n", ta->taskid); |
if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING && |
ta->udebug.dt_state != UDEBUG_TS_ACTIVE) { |
LOG("udebug_task_cleanup(): task not being debugged\n"); |
return EINVAL; |
} |
LOG("Task %" PRIu64, ta->taskid); |
/* Finish debugging of all userspace threads */ |
for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) { |
t = list_get_instance(cur, thread_t, th_link); |
427,7 → 470,7 |
t->udebug.go = false; |
/* Answer GO call */ |
LOG("Answer GO call with EVENT_FINISHED."); |
LOG("answer GO call with EVENT_FINISHED\n"); |
IPC_SET_RETVAL(t->udebug.go_call->data, 0); |
IPC_SET_ARG1(t->udebug.go_call->data, |
UDEBUG_EVENT_FINISHED); |
/branches/dd/kernel/generic/src/udebug/udebug_ops.c |
---|
181,11 → 181,15 |
thread_t *t; |
link_t *cur; |
LOG("Debugging task %llu", TASK->taskid); |
LOG("udebug_begin()\n"); |
mutex_lock(&TASK->udebug.lock); |
LOG("debugging task %llu\n", TASK->taskid); |
if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) { |
mutex_unlock(&TASK->udebug.lock); |
LOG("udebug_begin(): busy error\n"); |
return EBUSY; |
} |
213,6 → 217,10 |
} |
mutex_unlock(&TASK->udebug.lock); |
LOG("udebug_begin() done (%s)\n", |
reply ? "reply" : "stoppability wait"); |
return reply; |
} |
225,10 → 233,13 |
{ |
int rc; |
LOG("Task %" PRIu64, TASK->taskid); |
LOG("udebug_end()\n"); |
mutex_lock(&TASK->udebug.lock); |
LOG("task %" PRIu64 "\n", TASK->taskid); |
rc = udebug_task_cleanup(TASK); |
mutex_unlock(&TASK->udebug.lock); |
return rc; |
243,16 → 254,19 |
*/ |
int udebug_set_evmask(udebug_evmask_t mask) |
{ |
LOG("mask = 0x%x", mask); |
LOG("udebug_set_mask()\n"); |
mutex_lock(&TASK->udebug.lock); |
if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) { |
mutex_unlock(&TASK->udebug.lock); |
LOG("udebug_set_mask(): not active debuging session\n"); |
return EINVAL; |
} |
TASK->udebug.evmask = mask; |
mutex_unlock(&TASK->udebug.lock); |
return 0; |
303,7 → 317,7 |
{ |
int rc; |
LOG("udebug_stop()"); |
LOG("udebug_stop()\n"); |
/* |
* On success, this will lock t->udebug.lock. Note that this makes sure |
326,6 → 340,7 |
/* |
* Answer GO call. |
*/ |
LOG("udebug_stop - answering go call\n"); |
/* Make sure nobody takes this call away from us. */ |
call = t->udebug.go_call; |
333,6 → 348,7 |
IPC_SET_RETVAL(call->data, 0); |
IPC_SET_ARG1(call->data, UDEBUG_EVENT_STOP); |
LOG("udebug_stop/ipc_answer\n"); |
THREAD->udebug.cur_event = UDEBUG_EVENT_STOP; |
342,6 → 358,7 |
ipc_answer(&TASK->answerbox, call); |
mutex_unlock(&TASK->udebug.lock); |
LOG("udebog_stop/done\n"); |
return 0; |
} |
375,7 → 392,7 |
int flags; |
size_t max_ids; |
LOG("udebug_thread_read()"); |
LOG("udebug_thread_read()\n"); |
/* Allocate a buffer to hold thread IDs */ |
id_buffer = malloc(buf_size, 0); |
/branches/dd/boot/arch/sparc64/loader/Makefile |
---|
101,9 → 101,8 |
$(USPACEDIR)/srv/fb/fb \ |
$(USPACEDIR)/srv/kbd/kbd \ |
$(USPACEDIR)/srv/console/console \ |
$(USPACEDIR)/srv/pci/pci \ |
$(USPACEDIR)/srv/fs/devfs/devfs \ |
$(USPACEDIR)/srv/fs/tmpfs/tmpfs |
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \ |
$(USPACEDIR)/srv/pci/pci |
ifeq ($(MACHINE),generic) |
RD_SRVS += \ |
/branches/dd/boot/arch/sparc64/loader/asm.S |
---|
40,7 → 40,7 |
.global jump_to_kernel |
halt: |
ba %xcc, halt |
b halt |
nop |
memcpy: |
116,7 → 116,7 |
set subarchitecture, %g2 |
ldub [%g2], %g2 |
cmp %g2, 3 |
be %xcc, 1f |
be 1f |
nop |
0: |
call icache_flush |
/branches/dd/boot/arch/sparc64/loader/boot.S |
---|
43,7 → 43,7 |
.global start |
start: |
ba %xcc, 1f |
b 1f |
nop |
/* |
83,7 → 83,7 |
call ofw_init ! initialize OpenFirmware |
stx %o4, [%l0] |
ba %xcc, bootstrap |
b bootstrap |
nop |
.align STACK_ALIGNMENT |
/branches/dd/boot/arch/ia32/Makefile.inc |
---|
47,7 → 47,6 |
$(USPACEDIR)/srv/fb/fb \ |
$(USPACEDIR)/srv/kbd/kbd \ |
$(USPACEDIR)/srv/console/console \ |
$(USPACEDIR)/srv/fs/devfs/devfs \ |
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \ |
$(USPACEDIR)/srv/fs/fat/fat |
/branches/dd/boot/arch/ia64/loader/Makefile |
---|
100,7 → 100,6 |
$(USPACEDIR)/srv/fb/fb \ |
$(USPACEDIR)/srv/kbd/kbd \ |
$(USPACEDIR)/srv/console/console \ |
$(USPACEDIR)/srv/fs/devfs/devfs \ |
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \ |
$(USPACEDIR)/srv/fs/fat/fat |
/branches/dd/boot/arch/ppc32/Makefile.inc |
---|
32,10 → 32,8 |
$(BASE)/image.iso: depend arch/$(BARCH)/loader/image.boot |
mkdir -p $(TMP)/boot |
mkdir -p $(TMP)/ppc |
cp arch/$(BARCH)/loader/image.boot $(TMP)/boot/image.boot |
cp arch/$(BARCH)/yaboot/ofboot.b $(TMP)/boot/ofboot.b |
cp arch/$(BARCH)/yaboot/bootinfo.txt $(TMP)/ppc/bootinfo.txt |
cp arch/$(BARCH)/yaboot/yaboot $(TMP)/boot/yaboot |
cp arch/$(BARCH)/yaboot/yaboot.conf $(TMP)/boot/yaboot.conf |
mkisofs -hfs -part -map arch/$(BARCH)/yaboot/maps -no-desktop -hfs-volid "HelenOS" -hfs-bless $(TMP)/boot -r -o $@ $(TMP)/ |
/branches/dd/boot/arch/ppc32/yaboot/bootinfo.txt |
---|
File deleted |
/branches/dd/boot/arch/ppc32/yaboot/yaboot.conf |
---|
1,5 → 1,4 |
device=cd: |
timeout=0 |
image=/boot/image.boot |
label=HelenOS |
/branches/dd/boot/arch/ppc32/yaboot/ofboot.b |
---|
3,7 → 3,7 |
MacRISC |
</COMPATIBLE> |
<DESCRIPTION> |
HelenOS |
text |
</DESCRIPTION> |
<BOOT-SCRIPT> |
" screen" output |
/branches/dd/boot/arch/ppc32/loader/ofwarch.c |
---|
52,8 → 52,7 |
{ |
char device_name[BUF_SIZE]; |
if ((ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0) |
&& (ofw_get_property(ofw_aliases, "mac-io", device_name, sizeof(device_name)) <= 0)) |
if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0) |
return false; |
phandle device = ofw_find_device(device_name); |
/branches/dd/boot/arch/ppc32/loader/Makefile |
---|
88,7 → 88,6 |
$(USPACEDIR)/srv/fb/fb \ |
$(USPACEDIR)/srv/kbd/kbd \ |
$(USPACEDIR)/srv/console/console \ |
$(USPACEDIR)/srv/fs/devfs/devfs \ |
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \ |
$(USPACEDIR)/srv/fs/fat/fat |
/branches/dd/boot/arch/amd64/Makefile.inc |
---|
47,7 → 47,6 |
$(USPACEDIR)/srv/fb/fb \ |
$(USPACEDIR)/srv/kbd/kbd \ |
$(USPACEDIR)/srv/console/console \ |
$(USPACEDIR)/srv/fs/devfs/devfs \ |
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \ |
$(USPACEDIR)/srv/fs/fat/fat |
/branches/dd/boot/arch/mips32/loader/Makefile |
---|
101,10 → 101,8 |
$(USPACEDIR)/srv/fb/fb \ |
$(USPACEDIR)/srv/kbd/kbd \ |
$(USPACEDIR)/srv/console/console \ |
$(USPACEDIR)/srv/fs/devfs/devfs \ |
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \ |
$(USPACEDIR)/srv/fs/fat/fat \ |
$(USPACEDIR)/srv/bd/gxe_bd/gxe_bd |
$(USPACEDIR)/srv/fs/fat/fat |
RD_APPS = \ |
$(USPACEDIR)/app/tetris/tetris \ |
/branches/dd/boot/arch/arm32/loader/Makefile |
---|
89,7 → 89,6 |
$(USPACEDIR)/srv/fb/fb \ |
$(USPACEDIR)/srv/kbd/kbd \ |
$(USPACEDIR)/srv/console/console \ |
$(USPACEDIR)/srv/fs/devfs/devfs \ |
$(USPACEDIR)/srv/fs/tmpfs/tmpfs \ |
$(USPACEDIR)/srv/fs/fat/fat |
/branches/dd/HelenOS.config |
---|
290,6 → 290,12 |
% Deadlock detection support for spinlocks |
! [CONFIG_DEBUG=y&CONFIG_SMP=y] CONFIG_DEBUG_SPINLOCK (y/n) |
% Improved support for hyperthreading |
! [PLATFORM=amd64&CONFIG_SMP=y] CONFIG_HT (y/n) |
% Improved support for hyperthreading |
! [PLATFORM=ia32&PROCESSOR!=athlon_xp&PROCESSOR!=athlon_mp&PROCESSOR!=pentium3&CONFIG_SMP=y] CONFIG_HT (y/n) |
% Lazy FPU context switching |
! [CONFIG_FPU=y] CONFIG_FPU_LAZY (y/n) |
326,7 → 332,7 |
% Input device class |
@ "generic" Keyboard or serial line |
@ "none" No input device |
! [PLATFORM=ia32|PLATFORM=arm32|PLATFORM=amd64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_HID_IN (choice) |
! [PLATFORM=ia32|PLATFORM=arm32|PLATFORM=amd64|PLATFORM=mips32|PLATFORM=sparc64] CONFIG_HID_IN (choice) |
% Input device class |
@ "generic" Keyboard or serial line |
372,9 → 378,6 |
% Support for GXemul printer |
! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32] CONFIG_ARM_PRN (y/n) |
% Support for VIA CUDA controller |
! [CONFIG_HID_IN=generic&PLATFORM=ppc32] CONFIG_VIA_CUDA (y/n) |
% Support for NS16550 controller |
! [(CONFIG_HID_IN=generic|CONFIG_HID_IN=keyboard)&PLATFORM=sparc64&MACHINE=generic] CONFIG_NS16550 (y/n) |
/branches/dd/defaults/ppc32/Makefile.config |
---|
25,9 → 25,6 |
# Compile kernel tests |
CONFIG_TEST = y |
# Input device class |
CONFIG_HID_IN = generic |
# Output device class |
CONFIG_HID_OUT = generic |
/branches/dd/defaults/amd64/Makefile.config |
---|
16,6 → 16,9 |
# Support for SMP |
CONFIG_SMP = y |
# Improved support for hyperthreading |
CONFIG_HT = y |
# Lazy FPU context switching |
CONFIG_FPU_LAZY = y |
/branches/dd/defaults/ia32/Makefile.config |
---|
22,6 → 22,9 |
# Support for SMP |
CONFIG_SMP = y |
# Improved support for hyperthreading |
CONFIG_HT = y |
# Lazy FPU context switching |
CONFIG_FPU_LAZY = y |
/branches/dd/tools/mkfat.py |
---|
138,7 → 138,7 |
char name[8] /* file name */ |
char ext[3] /* file extension */ |
uint8_t attr /* file attributes */ |
uint8_t lcase /* file name case (NT extension) */ |
padding[1] /* reserved for NT */ |
uint8_t ctime_fine /* create time (fine resolution) */ |
uint16_t ctime /* create time */ |
uint16_t cdate /* create date */ |
217,7 → 217,6 |
else: |
dir_entry.attr = 0x20 |
dir_entry.lcase = 0x18 |
dir_entry.ctime_fine = 0 # FIXME |
dir_entry.ctime = 0 # FIXME |
dir_entry.cdate = 0 # FIXME |