Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 4262 → Rev 4263

/branches/network/uspace/app/bdsh/input.c
34,6 → 34,10
#include <string.h>
#include <io/stream.h>
#include <console.h>
#include <kbd/kbd.h>
#include <kbd/keycode.h>
#include <errno.h>
#include <bool.h>
 
#include "config.h"
#include "util.h"
96,30 → 100,44
 
static void read_line(char *buffer, int n)
{
char c;
int chars;
kbd_event_t ev;
size_t offs, otmp;
wchar_t dec;
 
chars = 0;
while (chars < n - 1) {
c = getchar();
if (c < 0)
offs = 0;
while (true) {
fflush(stdout);
if (kbd_get_event(&ev) < 0)
return;
if (c == '\n')
if (ev.type == KE_RELEASE)
continue;
 
if (ev.key == KC_ENTER || ev.key == KC_NENTER)
break;
if (c == '\b') {
if (chars > 0) {
if (ev.key == KC_BACKSPACE) {
if (offs > 0) {
/*
* Back up until we reach valid start of
* character.
*/
while (offs > 0) {
--offs; otmp = offs;
dec = str_decode(buffer, &otmp, n);
if (dec != U_SPECIAL)
break;
}
putchar('\b');
--chars;
}
continue;
}
if (c >= ' ') {
putchar(c);
buffer[chars++] = c;
if (ev.c >= ' ') {
//putchar(ev.c);
if (chr_encode(ev.c, buffer, &offs, n - 1) == EOK)
console_putchar(ev.c);
}
}
putchar('\n');
buffer[chars] = '\0';
buffer[offs] = '\0';
}
 
/* TODO:
/branches/network/uspace/app/bdsh/cmds/modules/kcon/kcon.h
0,0 → 1,8
#ifndef KCON_H
#define KCON_H
 
/* Prototypes for the kcon command, excluding entry points */
 
 
#endif /* KCON_H */
 
/branches/network/uspace/app/bdsh/cmds/modules/kcon/entry.h
0,0 → 1,9
#ifndef KCON_ENTRY_H
#define KCON_ENTRY_H
 
/* Entry points for the kcon command */
extern int cmd_kcon(char **);
extern void help_cmd_kcon(unsigned int);
 
#endif /* KCON_ENTRY_H */
 
/branches/network/uspace/app/bdsh/cmds/modules/kcon/kcon.c
0,0 → 1,72
/* Copyright (c) 2008, Tim Post <tinkertim@gmail.com>
* 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.
*
* Neither the name of the original program's authors nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <console.h>
#include "config.h"
#include "util.h"
#include "errors.h"
#include "entry.h"
#include "kcon.h"
#include "cmds.h"
 
static char *cmdname = "kcon";
 
/* Dispays help for kcon in various levels */
void help_cmd_kcon(unsigned int level)
{
printf("`kcon' switches to the kernel debug console.\n");
 
if (level != HELP_SHORT) {
printf("Usage: %s\n", cmdname);
}
 
return;
}
 
/* Main entry point for kcon, accepts an array of arguments */
int cmd_kcon(char **argv)
{
unsigned int argc;
 
argc = cli_count_args(argv);
 
if (argc != 1) {
printf("%s - incorrect number of arguments. Try `%s --help'\n",
cmdname, cmdname);
return CMD_FAILURE;
}
 
console_kcon_enable();
 
return CMD_SUCCESS;
}
 
/branches/network/uspace/app/bdsh/cmds/modules/kcon/kcon_def.h
0,0 → 1,7
{
"kcon",
"Switch to kernel console",
&cmd_kcon,
&help_cmd_kcon,
},
 
/branches/network/uspace/app/bdsh/cmds/modules/modules.h
26,6 → 26,7
#include "pwd/entry.h"
#include "sleep/entry.h"
#include "cp/entry.h"
#include "kcon/entry.h"
 
/* Each .def function fills the module_t struct with the individual name, entry
* point, help entry point, etc. You can use config.h to control what modules
41,6 → 42,7
#include "pwd/pwd_def.h"
#include "sleep/sleep_def.h"
#include "cp/cp_def.h"
#include "kcon/kcon_def.h"
{NULL, NULL, NULL, NULL}
};
 
/branches/network/uspace/app/bdsh/Makefile
57,6 → 57,7
cmds/modules/pwd/ \
cmds/modules/sleep/ \
cmds/modules/cp/ \
cmds/modules/kcon/ \
cmds/builtins/ \
cmds/builtins/exit/\
cmds/builtins/cd/
71,6 → 72,7
cmds/modules/pwd/pwd.c \
cmds/modules/sleep/sleep.c \
cmds/modules/cp/cp.c \
cmds/modules/kcon/kcon.c \
cmds/builtins/exit/exit.c \
cmds/builtins/cd/cd.c \
cmds/mod_cmds.c \
/branches/network/uspace/app/init/init.c
44,6 → 44,7
#include <task.h>
#include <malloc.h>
#include <macros.h>
#include <console.h>
#include "init.h"
#include "version.h"
 
/branches/network/uspace/app/tester/tester.c
47,6 → 47,7
test_t tests[] = {
#include "thread/thread1.def"
#include "print/print1.def"
#include "print/print4.def"
#include "fault/fault1.def"
#include "fault/fault2.def"
#include "ipc/register.def"
/branches/network/uspace/app/tester/print/print4.c
0,0 → 1,92
/*
* Copyright (c) 2009 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.
*/
 
#include <stdio.h>
#include <unistd.h>
#include "../tester.h"
 
#define PRIx8 "x"
 
char *test_print4(bool quiet)
{
if (!quiet) {
printf("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n");
uint8_t group;
for (group = 1; group < 4; group++) {
printf("%#" PRIx8 ": ", group << 5);
uint8_t index;
for (index = 0; index < 32; index++)
printf("%c", (char) ((group << 5) + index));
printf(" ");
for (index = 0; index < 32; index++)
printf("%lc", (wchar_t) ((group << 5) + index));
printf("\n");
}
printf("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n");
for (group = 4; group < 8; group++) {
printf("%#" PRIx8 ": ", group << 5);
uint8_t index;
for (index = 0; index < 32; index++)
printf("%lc", (wchar_t) ((group << 5) + index));
printf("\n");
}
printf("\nUTF-8 strings using printf(\"%%s\"):\n");
printf("English: %s\n", "Quick brown fox jumps over the lazy dog");
printf("Czech: %s\n", "Příliš žluťoučký kůň úpěl ďábelské ódy");
printf("Greek: %s\n", "Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε");
printf("Hebrew: %s\n", "משוואת ברנולי היא משוואה בהידרודינמיקה");
printf("Arabic: %s\n", "التوزيع الجغرافي للحمل العنقودي");
printf("Russian: %s\n", "Леннон познакомился с художницей-авангардисткой");
printf("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական");
printf("\nUTF-32 strings using printf(\"%%ls\"):\n");
printf("English: %ls\n", L"Quick brown fox jumps over the lazy dog");
printf("Czech: %ls\n", L"Příliš žluťoučký kůň úpěl ďábelské ódy");
printf("Greek: %ls\n", L"Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε");
printf("Hebrew: %ls\n", L"משוואת ברנולי היא משוואה בהידרודינמיקה");
printf("Arabic: %ls\n", L"التوزيع الجغرافي للحمل العنقودي");
printf("Russian: %ls\n", L"Леннон познакомился с художницей-авангардисткой");
printf("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական");
 
printf("Test: [%d] '%lc'\n", L'\x0161', L'\x0161');
}
 
printf("[Press a key]\n");
getchar();
return NULL;
}
Property changes:
Added: svn:mergeinfo
/branches/network/uspace/app/tester/print/print4.def
0,0 → 1,6
{
"print4",
"Unicode test",
&test_print4,
true
},
Property changes:
Added: svn:mergeinfo
/branches/network/uspace/app/tester/tester.h
60,6 → 60,7
 
extern char * test_thread1(bool quiet);
extern char * test_print1(bool quiet);
extern char * test_print4(bool quiet);
extern char * test_fault1(bool quiet);
extern char * test_fault2(bool quiet);
extern char * test_register(bool quiet);
/branches/network/uspace/app/tester/Makefile
45,6 → 45,7
SOURCES = tester.c \
thread/thread1.c \
print/print1.c \
print/print4.c \
fault/fault1.c \
fault/fault2.c \
ipc/register.c \
/branches/network/uspace/app/tetris/scores.c
55,6 → 55,9
#include <stdio.h>
/* #include <stdlib.h> */
#include <string.h>
#include <kbd/kbd.h>
#include <kbd/keycode.h>
#include <stdlib.h>
/* #include <time.h> */
/* #include <term.h> */
/* #include <unistd.h> */
122,32 → 125,57
void insertscore(int score, int level)
{
int i,j;
int key;
 
size_t off;
kbd_event_t ev;
clear_screen();
moveto(10 , 10);
puts("Insert your name: ");
strncpy(scores[NUMSPOTS - 1].hs_name, "Player", MAXLOGNAME);
i = 6;
i = 6; off = 6;
 
moveto(10 , 28);
printf("%s%.*s",scores[NUMSPOTS - 1].hs_name,MAXLOGNAME-i,"........................................");
key = getchar();
while(key != '\n') {
if (key == '\b') {
if (i > 0)
scores[NUMSPOTS - 1].hs_name[--i] = '\0';
} else {
if (i < (MAXLOGNAME - 1))
scores[NUMSPOTS - 1].hs_name[i++] = key;
scores[NUMSPOTS - 1].hs_name[i] = '\0';
 
while (1) {
fflush(stdout);
if (kbd_get_event(&ev) != EOK)
exit(1);
 
if (ev.type == KE_RELEASE)
continue;
 
if (ev.key == KC_ENTER || ev.key == KC_NENTER)
break;
 
if (ev.key == KC_BACKSPACE) {
if (i > 0) {
wchar_t uc;
 
--i;
while (off > 0) {
--off;
size_t otmp = off;
uc = str_decode(scores[NUMSPOTS - 1].hs_name,
&otmp, STR_BOUNDS(MAXLOGNAME) + 1);
if (uc != U_SPECIAL)
break;
}
 
scores[NUMSPOTS - 1].hs_name[off] = '\0';
}
} else if (ev.c != '\0') {
if (i < (MAXLOGNAME - 1)) {
if (chr_encode(ev.c, scores[NUMSPOTS - 1].hs_name,
&off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) {
++i;
}
scores[NUMSPOTS - 1].hs_name[off] = '\0';
}
}
moveto(10 , 28);
printf("%s%.*s",scores[NUMSPOTS - 1].hs_name,MAXLOGNAME-i,"........................................");
key = getchar();
}
scores[NUMSPOTS - 1].hs_score = score;
/branches/network/uspace/app/tetris/input.c
58,6 → 58,7
 
#include <async.h>
#include <ipc/console.h>
#include <console.h>
#include <kbd/kbd.h>
 
/* return true iff the given timeval is positive */
114,7 → 115,7
if (!lastchar) {
again:
if (!getchar_inprog) {
cons_phone = get_console_phone();
cons_phone = console_phone_get(true);
getchar_inprog = async_send_2(cons_phone,
CONSOLE_GETKEY, 0, 0, &charcall);
}
/branches/network/uspace/app/tetris/screen.c
117,11 → 117,6
console_goto(r, c);
}
 
static void fflush(void)
{
console_flush();
}
 
winsize_t winsize;
 
static int get_display_size(winsize_t *ws)
274,7 → 269,7
}
if (cur_so)
resume_normal();
fflush();
fflush(stdout);
}
 
/*
/branches/network/uspace/app/tetris/scores.h
45,9 → 45,11
* Tetris scores.
*/
#include <sys/time.h>
#include <string.h>
 
#define MAXLOGNAME 16
struct highscore {
char hs_name[MAXLOGNAME + 1]; /* login name */
char hs_name[STR_BOUNDS(MAXLOGNAME) + 1]; /* login name */
int hs_score; /* raw score */
int hs_level; /* play level */
// time_t hs_time; /* time at game end */
/branches/network/uspace/app/tetris/tetris.c
390,7 → 390,7
scr_update();
scr_msg(key_msg, 0);
scr_msg(msg, 1);
// (void) fflush(stdout);
(void) fflush(stdout);
} while (rwait((struct timeval *)NULL) == -1);
scr_msg(msg, 0);
scr_msg(key_msg, 1);
/branches/network/uspace/app/klog/klog.c
41,25 → 41,27
#include <as.h>
#include <sysinfo.h>
#include <io/stream.h>
#include <console.h>
#include <event.h>
#include <errno.h>
 
#define NAME "klog"
 
#define KLOG_SIZE PAGE_SIZE
 
/* Pointer to klog area */
static char *klog;
static wchar_t *klog;
static count_t klog_length;
 
static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
{
async_serialize_start();
size_t klog_start = (size_t) IPC_GET_ARG1(*call);
size_t klog_len = (size_t) IPC_GET_ARG2(*call);
size_t klog_stored = (size_t) IPC_GET_ARG3(*call);
size_t i;
count_t klog_start = (count_t) IPC_GET_ARG1(*call);
count_t klog_len = (count_t) IPC_GET_ARG2(*call);
count_t klog_stored = (count_t) IPC_GET_ARG3(*call);
count_t i;
for (i = klog_len - klog_stored; i < klog_len; i++)
putchar(klog[(klog_start + i) % KLOG_SIZE]);
putchar(klog[(klog_start + i) % klog_length]);
async_serialize_end();
}
68,29 → 70,32
{
console_wait();
klog = (char *) as_get_mappable_page(KLOG_SIZE);
count_t klog_pages = sysinfo_value("klog.pages");
size_t klog_size = klog_pages * PAGE_SIZE;
klog_length = klog_size / sizeof(wchar_t);
klog = (wchar_t *) as_get_mappable_page(klog_pages);
if (klog == NULL) {
printf(NAME ": Error allocating memory area\n");
return -1;
}
int res = ipc_share_in_start_1_0(PHONE_NS, (void *) klog, KLOG_SIZE,
SERVICE_MEM_KLOG);
int res = ipc_share_in_start_1_0(PHONE_NS, (void *) klog,
klog_size, SERVICE_MEM_KLOG);
if (res != EOK) {
printf(NAME ": Error initializing memory area\n");
return -1;
}
// int inr = sysinfo_value("klog.inr");
// if (ipc_register_irq(inr, devno, 0, NULL) != EOK) {
// printf(NAME ": Error registering klog notifications\n");
// return -1;
// }
if (event_subscribe(EVENT_KLOG, 0) != EOK) {
printf(NAME ": Error registering klog notifications\n");
return -1;
}
async_set_interrupt_received(interrupt_received);
klog_update();
async_manager();
 
return 0;
}
 
/branches/network/uspace/app/trace/syscalls.c
65,6 → 65,8
[SYS_IPC_REGISTER_IRQ] = { "ipc_register_irq", 4, V_ERRNO },
[SYS_IPC_UNREGISTER_IRQ] = { "ipc_unregister_irq", 2, V_ERRNO },
 
[SYS_EVENT_SUBSCRIBE] = { "event_subscribe", 2, V_ERRNO },
 
[SYS_CAP_GRANT] = { "cap_grant", 2, V_ERRNO },
[SYS_CAP_REVOKE] = { "cap_revoke", 2, V_ERRNO },
[SYS_PHYSMEM_MAP] = { "physmem_map", 4, V_ERRNO },