/branches/tracing/uspace/app/init/init.c |
---|
34,30 → 34,107 |
* @file |
*/ |
#include <stdio.h> |
#include <unistd.h> |
#include <vfs/vfs.h> |
#include <bool.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <task.h> |
#include <malloc.h> |
#include "init.h" |
#include "version.h" |
#include <stdio.h> |
static void test_console(void) |
#define BUF_SIZE 150000 |
static char *buf; |
static void console_wait(void) |
{ |
int c; |
while (get_cons_phone() < 0) |
usleep(50000); // FIXME |
} |
while ((c = getchar()) != EOF) |
putchar(c); |
static bool mount_tmpfs(void) |
{ |
int rc = -1; |
while (rc < 0) { |
rc = mount("tmpfs", "/", "initrd"); |
switch (rc) { |
case EOK: |
printf(NAME ": Root filesystem mounted\n"); |
break; |
case EBUSY: |
printf(NAME ": Root filesystem already mounted\n"); |
break; |
case ELIMIT: |
printf(NAME ": Unable to mount root filesystem\n"); |
return false; |
default: |
sleep(5); // FIXME |
} |
} |
return true; |
} |
static void spawn(char *fname) |
{ |
printf(NAME ": Spawning %s\n", fname); |
int fd = open(fname, O_RDONLY); |
if (fd >= 0) { |
ssize_t rd; |
size_t len = 0; |
// FIXME: cannot do long reads yet |
do { |
rd = read(fd, buf + len, 1024); |
if (rd > 0) |
len += rd; |
} while (rd > 0); |
if (len > 0) { |
task_spawn(buf, len); |
sleep(1); // FIXME |
} |
close(fd); |
} |
} |
int main(int argc, char *argv[]) |
{ |
info_print(); |
sleep(5); // FIXME |
if (!mount_tmpfs()) { |
printf(NAME ": Exiting\n"); |
return -1; |
} |
buf = malloc(BUF_SIZE); |
// FIXME: spawn("/sbin/pci"); |
spawn("/sbin/fb"); |
spawn("/sbin/kbd"); |
spawn("/sbin/console"); |
console_wait(); |
version_print(); |
printf("This is init\n"); |
test_console(); |
printf("\nBye.\n"); |
spawn("/sbin/fat"); |
spawn("/sbin/tetris"); |
// FIXME: spawn("/sbin/tester"); |
spawn("/sbin/klog"); |
free(buf); |
return 0; |
} |
/** @} |
*/ |
/branches/tracing/uspace/app/init/version.c |
---|
35,6 → 35,7 |
#include <unistd.h> |
#include <stdio.h> |
#include "init.h" |
#include "version.h" |
char *release = RELEASE; |
51,6 → 52,11 |
char *timestamp = ""; |
#endif |
void info_print(void) |
{ |
printf(NAME ": HelenOS init\n"); |
} |
/** Print version information. */ |
void version_print(void) |
{ |
/branches/tracing/uspace/app/init/init.h |
---|
36,7 → 36,7 |
#ifndef __INIT_H__ |
#define __INIT_H__ |
#include "version.h" |
#define NAME "init" |
#endif |
/branches/tracing/uspace/app/init/version.h |
---|
36,6 → 36,7 |
#ifndef __VERSION_H__ |
#define __VERSION_H__ |
extern void info_print(void); |
extern void version_print(void); |
#endif |
/branches/tracing/uspace/app/sctrace/syscalls.c |
---|
36,7 → 36,7 |
#include "syscalls.h" |
const sc_desc_t syscall_desc[] = { |
[SYS_IO] ={ "io", 3, RV_INT_ERRNO }, |
[SYS_KLOG] ={ "klog", 3, RV_INT_ERRNO }, |
[SYS_TLS_SET] = { "tls_set", 1, RV_ERRNO }, |
[SYS_THREAD_CREATE] = { "thread_create", 3, RV_ERRNO }, |
[SYS_THREAD_EXIT] = { "thread_exit", 1, RV_ERRNO }, |
/branches/tracing/uspace/app/tester/debug/debug1.c |
---|
53,9 → 53,9 |
done = 0; |
asm ( |
"trap" |
); |
// asm ( |
// "trap" |
// ); |
/* while(1) { |
printf("."); |
/branches/tracing/uspace/app/tester/tester.c |
---|
129,10 → 129,15 |
printf("Unknown test\n\n"); |
else |
run_test(test); |
} else if (c == '*') |
} else if (c == '*') { |
run_safe_tests(); |
else |
} else if (c < 0) { |
/* got EOF */ |
break; |
} else { |
printf("Invalid test\n\n"); |
} |
} |
} |
/branches/tracing/uspace/app/tester/devmap/devmap1.c |
---|
32,7 → 32,7 |
#include <ipc/services.h> |
#include <async.h> |
#include <errno.h> |
#include <../../../srv/devmap/devmap.h> |
#include <ipc/devmap.h> |
#include "../tester.h" |
#include <time.h> |
/branches/tracing/uspace/app/tetris/scores.c |
---|
52,7 → 52,7 |
/* #include <err.h> */ |
/* #include <fcntl.h> */ |
/* #include <pwd.h> */ |
#include <stdio.h> |
#include <stdio.h> |
/* #include <stdlib.h> */ |
#include <string.h> |
/* #include <time.h> */ |
/branches/tracing/uspace/app/klog/klog.c |
---|
40,46 → 40,62 |
#include <ipc/services.h> |
#include <as.h> |
#include <sysinfo.h> |
#include <io/stream.h> |
#include <errno.h> |
#define NAME "klog" |
#define KLOG_SIZE PAGE_SIZE |
/* Pointer to klog area */ |
static char *klog; |
static void console_wait(void) |
{ |
while (get_cons_phone() < 0) |
usleep(50000); // FIXME |
} |
static void interrupt_received(ipc_callid_t callid, ipc_call_t *call) |
{ |
int i; |
async_serialize_start(); |
async_serialize_start(); |
for (i=0; klog[i + IPC_GET_ARG1(*call)] && i < IPC_GET_ARG2(*call); i++) |
putchar(klog[i + IPC_GET_ARG1(*call)]); |
putchar('\n'); |
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; |
for (i = klog_len - klog_stored; i < klog_len; i++) |
putchar(klog[(klog_start + i) % KLOG_SIZE]); |
async_serialize_end(); |
} |
int main(int argc, char *argv[]) |
{ |
int res; |
void *mapping; |
printf("Kernel console output.\n"); |
console_wait(); |
mapping = as_get_mappable_page(PAGE_SIZE); |
res = ipc_share_in_start_1_0(PHONE_NS, mapping, PAGE_SIZE, |
klog = (char *) as_get_mappable_page(KLOG_SIZE); |
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); |
if (res) { |
printf("Failed to initialize klog memarea\n"); |
_exit(1); |
if (res != EOK) { |
printf(NAME ": Error initializing memory area\n"); |
return -1; |
} |
klog = mapping; |
int inr = sysinfo_value("klog.inr"); |
int devno = sysinfo_value("klog.devno"); |
if (ipc_register_irq(inr, devno, 0, NULL)) { |
printf("Error registering for klog service.\n"); |
return 0; |
if (ipc_register_irq(inr, devno, 0, NULL) != EOK) { |
printf(NAME ": Error registering klog notifications\n"); |
return -1; |
} |
async_set_interrupt_received(interrupt_received); |
klog_update(); |
async_manager(); |
return 0; |