Add more wrappers: dump_dlls, dump_services, dump_shmem, int3

This commit is contained in:
2026-04-03 11:45:02 +01:00
parent 14554a6ac3
commit 0f5a74c123
28 changed files with 1272 additions and 751 deletions
+1 -10
View File
@@ -1,10 +1 @@
make mkfs.* use config files (-c for mkfs.xfs)
export and initialize mouse_delay and mouse_speed_factor (test and cover func mouse_acceleration)
lsstat to decrease tests size
separate dirs for each image
include umka_os to tests
tests with writing to block devices (read-only base image + discardable image for writing)
library loader
validate against the reference XFS implementation
stressing via ref impl (how?)
multithreaded: kofu one.t two.t
moved to the common kolibrios .td files
+2 -1
View File
@@ -92,7 +92,8 @@ kolibri.raw () {
mcopy -moi $img ../spray.cur ::SPRAY.CUR
mcopy -moi $img ../apps/board_cycle ::LOADER
mmd -i $img ::LIB
# mcopy -moi $img ../network.obj ::LIB/NETWORK.OBJ
mcopy -moi $img ../apps/network.obj ::LIB/NETWORK.OBJ
mcopy -moi $img ../apps/console.obj ::LIB/CONSOLE.OBJ
}
jfs.qcow2 () {
+19 -13
View File
@@ -3,7 +3,7 @@ ifndef KOLIBRIOS
endif
FASM_EXE ?= fasm
FASM_FLAGS=-dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 -dHOST=$(HOST) -m 2000000 -dlang=en_US
FASM_FLAGS=-dextended_primary_loader=1 -dHOST=$(HOST) -m 2000000 -dlang=en_US
HOST ?= linux
CC ?= gcc
@@ -27,7 +27,7 @@ else
$(error your compiler is not supported)
endif
CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c11 -g -O0 -DNDEBUG -masm=intel \
CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c23 -g -O0 -DNDEBUG -masm=intel \
-D_POSIX_C_SOURCE=200809L -I$(HOST) -Ideps -I. -fno-pie -D_POSIX \
-fno-common
CFLAGS_32=$(CFLAGS) -m32 -D_FILE_OFFSET_BITS=64 -D__USE_TIME_BITS64
@@ -67,11 +67,11 @@ endif
test: umka_shell
@cd test && make clean all && cd ../
umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o \
vdisk/raw.o vdisk/qcow2.o deps/em_inflate/em_inflate.o vnet.o \
$(HOST)/vnet/tap.o vnet/file.o vnet/null.o deps/lodepng/lodepng.o \
$(HOST)/pci.o $(HOST)/thread.o umkaio.o umkart.o \
deps/optparse/optparse.o deps/isocline/src/isocline.o
umka_shell: umka_shell.o umka.o monitor.o shell.o trace.o trace_lbr.o vkbd.o \
vdisk.o vdisk/raw.o vdisk/qcow2.o deps/em_inflate/em_inflate.o \
vnet.o $(HOST)/vnet/tap.o vnet/file.o vnet/null.o \
deps/lodepng/lodepng.o $(HOST)/pci.o $(HOST)/thread.o umkaio.o \
umkart.o deps/optparse/optparse.o deps/isocline/src/isocline.o
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld $(LIBS)
umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o vdisk/raw.o \
@@ -79,11 +79,11 @@ umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o vdisk/raw.o \
$(HOST)/thread.o umkaio.o
$(CC) $(LDFLAGS_32) $^ -o $@ `pkg-config fuse3 --libs` -T umka.ld
umka_os: umka_os.o umka.o shell.o deps/lodepng/lodepng.o vdisk.o vdisk/raw.o \
vdisk/qcow2.o deps/em_inflate/em_inflate.o vnet.o $(HOST)/vnet/tap.o \
vnet/file.o vnet/null.o trace.o trace_lbr.o $(HOST)/pci.o \
$(HOST)/thread.o umkaio.o umkart.o deps/isocline/src/isocline.o \
deps/optparse/optparse.o
umka_os: umka_os.o umka.o monitor.o shell.o deps/lodepng/lodepng.o vkbd.o \
vdisk.o vdisk/raw.o vdisk/qcow2.o deps/em_inflate/em_inflate.o vnet.o \
$(HOST)/vnet/tap.o vnet/file.o vnet/null.o trace.o trace_lbr.o \
$(HOST)/pci.o $(HOST)/thread.o umkaio.o umkart.o \
deps/isocline/src/isocline.o deps/optparse/optparse.o
$(CC) $(LDFLAGS_32) $^ `sdl2-config --libs` -o $@ -T umka.ld
umka_gen_devices_dat: umka_gen_devices_dat.o umka.o $(HOST)/pci.o \
@@ -93,7 +93,10 @@ umka_gen_devices_dat: umka_gen_devices_dat.o umka.o $(HOST)/pci.o \
umka.o umka.fas: umka.asm
$(FASM) $< umka.o -s umka.fas
shell.o: shell.c deps/lodepng/lodepng.h
monitor.o: monitor.c monitor.h umka.h
$(CC) $(CFLAGS_32) -c $<
shell.o: shell.c shell.h monitor.h umka.h deps/lodepng/lodepng.h
$(CC) $(CFLAGS_32) -c $<
umkaio.o: umkaio.c umkaio.h
@@ -160,6 +163,9 @@ deps/em_inflate/em_inflate.o: deps/em_inflate/em_inflate.c deps/em_inflate/em_in
$(CC) $(CFLAGS_32) -c $< -o $@ -Wno-sign-compare -Wno-unused-parameter \
-Wno-switch-enum -Wno-unused-function
vkbd.o: vkbd.c vkbd.h
$(CC) $(CFLAGS_32) -c $<
vnet.o: vnet.c vnet.h
$(CC) $(CFLAGS_32) -c $<
+306
View File
@@ -0,0 +1,306 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
monitor - the command interface
Copyright (C) 2025 Ivan Baravy <dunkaist@gmail.com>
*/
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include "umka.h"
#include "monitor.h"
#include "trace.h"
#define MONITOR_CMD_BUF_LEN 0x10
enum {
MONITOR_CMD_STATUS_EMPTY,
MONITOR_CMD_STATUS_READY,
MONITOR_CMD_STATUS_DONE,
};
struct umka_cmd umka_cmd_buf[MONITOR_CMD_BUF_LEN];
struct monitor_ctx *
monitor_init(atomic_int *running) {
struct monitor_ctx *monitor = malloc(sizeof(struct monitor_ctx));
monitor->running = running;
monitor->fout = stdout;
pthread_cond_init(&monitor->cmd_done, NULL);
pthread_mutex_init(&monitor->cmd_mutex, NULL);
/*
if (running) {
pthread_create(&io->iot, NULL, thread_io, NULL);
}
*/
return monitor;
}
static void
thread_cmd_runner(void *arg);
void
monitor_cmd_boot(struct monitor_ctx *ctx) {
if (*ctx->running != UMKA_RUNNING_NEVER) {
char *stack = malloc(UMKA_DEFAULT_THREAD_STACK_SIZE);
char *stack_top = stack + UMKA_DEFAULT_THREAD_STACK_SIZE;
size_t tid = umka_new_sys_threads(0, thread_cmd_runner, stack_top, ctx,
"cmd_runner");
(void)tid;
}
}
void
monitor_cmd_send_scancodes(struct monitor_ctx *mon, uint8_t *scancodes) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
cmd->type = UMKA_CMD_SEND_SCANCODE;
struct cmd_send_scancode_arg *c = &cmd->send_scancode.arg;
for (uint8_t *sc = scancodes; *sc; sc++) {
c->scancode = *sc;
monitor_run_cmd(mon);
monitor_clear_cmd(cmd);
}
}
void
monitor_cmd_csleep(struct monitor_ctx *mon, uint32_t csec) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
struct cmd_sys_csleep_arg *c = &cmd->sys_csleep.arg;
cmd->type = UMKA_CMD_SYS_CSLEEP;
c->csec = csec;
monitor_run_cmd(mon);
monitor_clear_cmd(cmd);
}
void
monitor_cmd_wait_for_idle(struct monitor_ctx *mon) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
cmd->type = UMKA_CMD_WAIT_FOR_IDLE;
monitor_run_cmd(mon);
monitor_clear_cmd(cmd);
}
void
monitor_cmd_wait_for_os_idle(struct monitor_ctx *mon) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
cmd->type = UMKA_CMD_WAIT_FOR_OS_IDLE;
monitor_run_cmd(mon);
monitor_clear_cmd(cmd);
}
void
monitor_cmd_wait_for_window(struct monitor_ctx *mon, char *wnd_title) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
cmd->type = UMKA_CMD_WAIT_FOR_WINDOW;
struct cmd_wait_for_window_arg *c = &cmd->wait_for_window.arg;
c->wnd_title = wnd_title;
monitor_run_cmd(mon);
monitor_clear_cmd(cmd);
}
void
monitor_cmd_mouse_move(struct monitor_ctx *mon, uint32_t btn_state,
int32_t xmoving, int32_t ymoving, int32_t vscroll,
int32_t hscroll) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
cmd->type = UMKA_CMD_SET_MOUSE_DATA;
struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg;
c->btn_state = btn_state;
c->xmoving = xmoving;
c->ymoving = ymoving;
c->vscroll = vscroll;
c->hscroll = hscroll;
monitor_run_cmd(mon);
monitor_clear_cmd(cmd);
}
struct f7080ret
monitor_cmd_sys_lfn(struct monitor_ctx *mon, enum f70or80 f70or80,
union f7080arg *fX0) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
struct cmd_sys_lfn_arg *c = &cmd->sys_lfn.arg;
cmd->type = UMKA_CMD_SYS_LFN;
c->f70or80 = f70or80;
c->bufptr = fX0;
struct f7080ret ret;
c->r = &ret;
monitor_run_cmd(mon);
monitor_clear_cmd(cmd);
return ret;
}
void
monitor_cmd_sys_set_mouse_pos_screen(struct monitor_ctx *mon, int16_t x,
int16_t y) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
cmd->type = UMKA_CMD_SYS_SET_MOUSE_POS_SCREEN;
struct cmd_sys_set_mouse_pos_screen_arg *c = &cmd->sys_set_mouse_pos_screen.arg;
struct point16s pos;
pos.x = x;
pos.y = y;
c->pos = pos;
monitor_run_cmd(mon);
monitor_clear_cmd(cmd);
}
static uint32_t
umka_wait_for_idle_test(void) {
return (uint32_t)(atomic_load_explicit(&idle_scheduled, memory_order_acquire));
}
static void
umka_wait_for_idle(void) {
atomic_store_explicit(&idle_scheduled, 0, memory_order_release);
kos_wait_events(umka_wait_for_idle_test, NULL);
}
static uint32_t
monitor_run_cmd_wait_test(void /* struct appdata * with wait_param is in ebx */) {
struct appdata *app;
__asm__ __volatile__ __inline__ ("":"=b"(app)::);
struct umka_cmd *cmd = (struct umka_cmd*)app->wait_param;
return (uint32_t)(atomic_load_explicit(&cmd->status, memory_order_acquire) == MONITOR_CMD_STATUS_READY);
}
static void
monitor_run_cmd_sync(struct monitor_ctx *ctx);
static void
thread_cmd_runner(void *arg) {
umka_sti();
struct monitor_ctx *ctx = arg;
while (1) {
kos_wait_events(monitor_run_cmd_wait_test, umka_cmd_buf);
monitor_run_cmd_sync(ctx);
}
}
static uint32_t
umka_wait_for_os_test(void) {
return (uint32_t)(atomic_load_explicit(&os_scheduled, memory_order_acquire));
}
static void
umka_wait_for_os_idle(void) {
atomic_store_explicit(&os_scheduled, 0, memory_order_release);
kos_wait_events(umka_wait_for_os_test, NULL);
atomic_store_explicit(&idle_scheduled, 0, memory_order_release);
kos_wait_events(umka_wait_for_idle_test, NULL);
}
static uint32_t
umka_wait_for_window_test(void) {
struct appdata *app;
struct wdata *wdata;
__asm__ __volatile__ __inline__ ("":"=b"(app)::);
const char *wnd_title = (const char *)app->wait_param;
for (size_t i = 0; i < 256; i++) {
app = kos_slot_base + i;
wdata = kos_window_data + i;
if (app->state != KOS_TSTATE_FREE && wdata->caption
&& !strcmp(wdata->caption, wnd_title)) {
return 1;
}
}
return 0;
}
static void
umka_wait_for_window(char *wnd_title) {
kos_wait_events(umka_wait_for_window_test, wnd_title);
}
static void
monitor_run_cmd_sync(struct monitor_ctx *mon) {
struct umka_cmd *cmd = monitor_get_cmd(mon);
switch (cmd->type) {
case UMKA_CMD_WAIT_FOR_IDLE: {
COVERAGE_ON();
umka_wait_for_idle();
COVERAGE_OFF();
break;
}
case UMKA_CMD_WAIT_FOR_OS_IDLE: {
COVERAGE_ON();
umka_wait_for_os_idle();
COVERAGE_OFF();
break;
}
case UMKA_CMD_WAIT_FOR_WINDOW: {
struct cmd_wait_for_window_arg *c = &cmd->wait_for_window.arg;
COVERAGE_ON();
umka_wait_for_window(c->wnd_title);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SYS_CSLEEP: {
struct cmd_sys_csleep_arg *c = &cmd->sys_csleep.arg;
COVERAGE_ON();
umka_sys_csleep(c->csec);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SET_MOUSE_DATA: {
struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg;
COVERAGE_ON();
kos_set_mouse_data(c->btn_state, c->xmoving, c->ymoving, c->vscroll,
c->hscroll);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SEND_SCANCODE: {
struct cmd_send_scancode_arg *c = &cmd->send_scancode.arg;
COVERAGE_ON();
umka_set_keyboard_data(c->scancode);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SYS_SET_MOUSE_POS_SCREEN: {
struct cmd_sys_set_mouse_pos_screen_arg *c = &cmd->sys_set_mouse_pos_screen.arg;
COVERAGE_ON();
umka_sys_set_mouse_pos_screen(c->pos);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SYS_LFN: {
struct cmd_sys_lfn_arg *c = &cmd->sys_lfn.arg;
COVERAGE_ON();
umka_sys_lfn(c->bufptr, c->r, c->f70or80);
COVERAGE_OFF();
break;
}
default:
fprintf(mon->fout, "[!monitor] unknown command: %u\n", cmd->type);
break;
}
atomic_store_explicit(&cmd->status, MONITOR_CMD_STATUS_DONE,
memory_order_release);
pthread_cond_signal(&mon->cmd_done);
}
struct umka_cmd *
monitor_get_cmd(struct monitor_ctx *monitor) {
(void)monitor;
return umka_cmd_buf;
}
void
monitor_run_cmd(struct monitor_ctx *ctx) {
struct umka_cmd *cmd = umka_cmd_buf;
atomic_store_explicit(&cmd->status, MONITOR_CMD_STATUS_READY,
memory_order_release);
if (atomic_load_explicit(ctx->running, memory_order_acquire) == UMKA_RUNNING_YES) {
pthread_cond_wait(&ctx->cmd_done, &ctx->cmd_mutex);
} else {
monitor_run_cmd_sync(ctx);
}
}
void
monitor_clear_cmd(struct umka_cmd *cmd) {
atomic_store_explicit(&cmd->status, MONITOR_CMD_STATUS_EMPTY,
memory_order_release);
}
+209
View File
@@ -0,0 +1,209 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
monitor - the command interface
Copyright (C) 2025 Ivan Baravy <dunkaist@gmail.com>
*/
#ifndef MONITOR_H_INCLUDED
#define MONITOR_H_INCLUDED
#include <pthread.h>
#include <stdatomic.h>
#include "umka.h"
struct monitor_ctx {
const atomic_int *running;
pthread_cond_t cmd_done;
pthread_mutex_t cmd_mutex;
FILE *fout;
};
enum {
UMKA_CMD_NONE,
UMKA_CMD_SET_MOUSE_DATA,
UMKA_CMD_WAIT_FOR_IDLE,
UMKA_CMD_WAIT_FOR_OS_IDLE,
UMKA_CMD_WAIT_FOR_WINDOW,
UMKA_CMD_SYS_CSLEEP,
UMKA_CMD_SYS_PROCESS_INFO,
UMKA_CMD_SYS_GET_MOUSE_POS_SCREEN,
UMKA_CMD_SYS_SET_MOUSE_POS_SCREEN,
UMKA_CMD_SYS_LFN,
UMKA_CMD_SEND_SCANCODE,
};
struct cmd_set_mouse_data_arg {
uint32_t btn_state;
int32_t xmoving;
int32_t ymoving;
int32_t vscroll;
int32_t hscroll;
};
struct cmd_set_mouse_data_ret {
char stub;
};
struct cmd_set_mouse_data {
struct cmd_set_mouse_data_arg arg;
struct cmd_set_mouse_data_ret ret;
};
struct cmd_sys_lfn_arg {
enum f70or80 f70or80;
union f7080arg *bufptr;
struct f7080ret *r;
};
struct cmd_sys_lfn_ret {
struct f7080ret status;
};
struct cmd_sys_lfn {
struct cmd_sys_lfn_arg arg;
struct cmd_sys_lfn_ret ret;
};
struct cmd_sys_process_info_arg {
int32_t pid;
void *param;
};
struct cmd_sys_process_info_ret {
char stub;
};
struct cmd_sys_process_info {
struct cmd_sys_process_info_arg arg;
struct cmd_sys_process_info_ret ret;
};
struct cmd_sys_get_mouse_pos_screen_arg {
char stub;
};
struct cmd_sys_get_mouse_pos_screen_ret {
struct point16s pos;
};
struct cmd_sys_get_mouse_pos_screen {
struct cmd_sys_get_mouse_pos_screen_arg arg;
struct cmd_sys_get_mouse_pos_screen_ret ret;
};
struct cmd_sys_set_mouse_pos_screen_arg {
struct point16s pos;
};
struct cmd_sys_set_mouse_pos_screen_ret {
char stub;
};
struct cmd_sys_set_mouse_pos_screen {
struct cmd_sys_set_mouse_pos_screen_arg arg;
struct cmd_sys_set_mouse_pos_screen_ret ret;
};
struct cmd_sys_csleep_arg {
uint32_t csec;
};
struct cmd_sys_csleep_ret {
char stub;
};
struct cmd_sys_csleep {
struct cmd_sys_csleep_arg arg;
struct cmd_sys_csleep_ret ret;
};
struct cmd_wait_for_window_arg {
char *wnd_title;
};
struct cmd_wait_for_window_ret {
char stub;
};
struct cmd_wait_for_window {
struct cmd_wait_for_window_arg arg;
struct cmd_wait_for_window_ret ret;
};
struct cmd_send_scancode_arg {
int scancode;
};
struct cmd_send_scancode_ret {
char stub;
};
struct cmd_send_scancode {
struct cmd_send_scancode_arg arg;
struct cmd_send_scancode_ret ret;
};
struct umka_cmd {
atomic_int status;
uint32_t type;
union {
// internal funcs
struct cmd_set_mouse_data set_mouse_data;
struct cmd_send_scancode send_scancode;
struct cmd_wait_for_window wait_for_window;
// syscalls
struct cmd_sys_csleep sys_csleep;
struct cmd_sys_process_info sys_process_info;
struct cmd_sys_lfn sys_lfn;
struct cmd_sys_get_mouse_pos_screen sys_get_mouse_pos_screen;
struct cmd_sys_set_mouse_pos_screen sys_set_mouse_pos_screen;
};
};
struct umka_cmd *
monitor_get_cmd(struct monitor_ctx *mon);
void
monitor_run_cmd(struct monitor_ctx *mon);
void
monitor_clear_cmd(struct umka_cmd *cmd);
struct monitor_ctx *
monitor_init(atomic_int *running);
void
monitor_cmd_send_scancodes(struct monitor_ctx *mon, uint8_t *scancodes);
void
monitor_cmd_boot(struct monitor_ctx *mon);
void
monitor_cmd_csleep(struct monitor_ctx *mon, uint32_t csec);
void
monitor_cmd_wait_for_idle(struct monitor_ctx *mon);
void
monitor_cmd_wait_for_os_idle(struct monitor_ctx *mon);
void
monitor_cmd_wait_for_window(struct monitor_ctx *mon, char *wnd_title);
void
monitor_cmd_mouse_move(struct monitor_ctx *mon, uint32_t btn_state,
int32_t xmoving, int32_t ymoving, int32_t vscroll,
int32_t hscroll);
struct f7080ret
monitor_cmd_sys_lfn(struct monitor_ctx *on, enum f70or80 f70or80,
union f7080arg *fX0);
void
monitor_cmd_sys_set_mouse_pos_screen(struct monitor_ctx *mon, int16_t x,
int16_t y);
#endif // MONITOR_H_INCLUDED
+209 -311
View File
@@ -2,9 +2,9 @@
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
umka_shell - the shell
shell - the shell
Copyright (C) 2017-2023 Ivan Baravy <dunkaist@gmail.com>
Copyright (C) 2017-2025 Ivan Baravy <dunkaist@gmail.com>
Copyright (C) 2021 Magomed Kostoev <mkostoevr@yandex.ru>
*/
@@ -31,6 +31,7 @@
#endif
#include "shell.h"
#include "monitor.h"
#include "vdisk.h"
#include "vnet.h"
#include "umka.h"
@@ -49,16 +50,6 @@
#define DEFAULT_READDIR_ENCODING UTF8
#define DEFAULT_PATH_ENCODING UTF8
#define SHELL_CMD_BUF_LEN 0x10
enum {
SHELL_CMD_STATUS_EMPTY,
SHELL_CMD_STATUS_READY,
SHELL_CMD_STATUS_DONE,
};
struct umka_cmd umka_cmd_buf[SHELL_CMD_BUF_LEN];
char prompt_line[PATH_MAX];
char cur_dir[PATH_MAX] = "/";
const char *last_dir = cur_dir;
@@ -69,27 +60,6 @@ typedef struct {
void (*func) (struct shell_ctx *, int, char **);
} func_table_t;
static uint32_t
shell_run_cmd_wait_test(void /* struct appdata * with wait_param is in ebx */) {
appdata_t *app;
__asm__ __volatile__ __inline__ ("":"=b"(app)::);
struct umka_cmd *cmd = (struct umka_cmd*)app->wait_param;
return (uint32_t)(atomic_load_explicit(&cmd->status, memory_order_acquire) == SHELL_CMD_STATUS_READY);
}
static void
shell_run_cmd_sync(struct shell_ctx *ctx);
static void
thread_cmd_runner(void *arg) {
umka_sti();
struct shell_ctx *ctx = arg;
while (1) {
kos_wait_events(shell_run_cmd_wait_test, umka_cmd_buf);
shell_run_cmd_sync(ctx);
}
}
const char *f70_status_name[] = {
"success",
"disk_base",
@@ -140,7 +110,7 @@ convert_f70_file_attr(uint32_t attr, char s[KF_ATTR_CNT+1]) {
}
static void
print_f70_status(struct shell_ctx *ctx, f7080ret_t *r, int use_ebx) {
print_f70_status(struct shell_ctx *ctx, struct f7080ret *r, int use_ebx) {
fprintf(ctx->fout, "status = %d %s", r->status,
get_f70_status_name(r->status));
if (use_ebx
@@ -420,16 +390,13 @@ cmd_send_scancode(struct shell_ctx *ctx, int argc, char **argv) {
argc -= 1;
argv += 1;
struct umka_cmd *cmd = shell_get_cmd(ctx);
cmd->type = UMKA_CMD_SEND_SCANCODE;
struct cmd_send_scancode_arg *c = &cmd->send_scancode.arg;
uint8_t scancodes[128];
uint8_t *scancode = scancodes;
while (argc) {
char *endptr;
size_t code = strtoul(argv[0], &endptr, 0);
if (*endptr == '\0') {
c->scancode = code;
shell_run_cmd(ctx);
shell_clear_cmd(cmd);
*scancode++ = code;
argc--;
argv++;
} else {
@@ -438,6 +405,7 @@ cmd_send_scancode(struct shell_ctx *ctx, int argc, char **argv) {
return;
}
}
monitor_cmd_send_scancodes(ctx->monitor, scancodes);
}
static void
@@ -455,13 +423,7 @@ cmd_umka_boot(struct shell_ctx *ctx, int argc, char **argv) {
umka_boot();
COVERAGE_OFF();
if (*ctx->running != UMKA_RUNNING_NEVER) {
char *stack = malloc(UMKA_DEFAULT_THREAD_STACK_SIZE);
char *stack_top = stack + UMKA_DEFAULT_THREAD_STACK_SIZE;
size_t tid = umka_new_sys_threads(0, thread_cmd_runner, stack_top, ctx,
"cmd_runner");
(void)tid;
}
monitor_cmd_boot(ctx->monitor);
}
static void
@@ -509,29 +471,14 @@ cmd_umka_set_boot_params(struct shell_ctx *ctx, int argc, char **argv) {
static void
cmd_csleep(struct shell_ctx *ctx, int argc, char **argv) {
const char *usage = \
"usage: csleep\n";
"usage: csleep <cs>\n"
" cs sleep time in centiseconds\n";
if (argc != 2) {
fputs(usage, ctx->fout);
return;
}
struct umka_cmd *cmd = umka_cmd_buf;
struct cmd_sys_csleep_arg *c = &cmd->sys_csleep.arg;
cmd->type = UMKA_CMD_SYS_CSLEEP;
c->csec = strtoul(argv[1], NULL, 0);
shell_run_cmd(ctx);
atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_EMPTY,
memory_order_release);
}
static uint32_t
umka_wait_for_idle_test(void) {
return (uint32_t)(atomic_load_explicit(&idle_scheduled, memory_order_acquire));
}
static void
umka_wait_for_idle(void) {
atomic_store_explicit(&idle_scheduled, 0, memory_order_release);
kos_wait_events(umka_wait_for_idle_test, NULL);
uint32_t csec = strtoul(argv[1], NULL, 0);
monitor_cmd_csleep(ctx->monitor, csec);
}
static void
@@ -543,24 +490,7 @@ cmd_wait_for_idle(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
struct umka_cmd *cmd = umka_cmd_buf;
cmd->type = UMKA_CMD_WAIT_FOR_IDLE;
shell_run_cmd(ctx);
atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_EMPTY,
memory_order_release);
}
static uint32_t
umka_wait_for_os_test(void) {
return (uint32_t)(atomic_load_explicit(&os_scheduled, memory_order_acquire));
}
static void
umka_wait_for_os_idle(void) {
atomic_store_explicit(&os_scheduled, 0, memory_order_release);
kos_wait_events(umka_wait_for_os_test, NULL);
atomic_store_explicit(&idle_scheduled, 0, memory_order_release);
kos_wait_events(umka_wait_for_idle_test, NULL);
monitor_cmd_wait_for_idle(ctx->monitor);
}
static void
@@ -572,33 +502,7 @@ cmd_wait_for_os_idle(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
struct umka_cmd *cmd = umka_cmd_buf;
cmd->type = UMKA_CMD_WAIT_FOR_OS_IDLE;
shell_run_cmd(ctx);
atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_EMPTY,
memory_order_release);
}
static uint32_t
umka_wait_for_window_test(void) {
appdata_t *app;
wdata_t *wdata;
__asm__ __volatile__ __inline__ ("":"=b"(app)::);
const char *wnd_title = (const char *)app->wait_param;
for (size_t i = 0; i < 256; i++) {
app = kos_slot_base + i;
wdata = kos_window_data + i;
if (app->state != KOS_TSTATE_FREE && wdata->caption
&& !strcmp(wdata->caption, wnd_title)) {
return 1;
}
}
return 0;
}
static void
umka_wait_for_window(char *wnd_title) {
kos_wait_events(umka_wait_for_window_test, wnd_title);
monitor_cmd_wait_for_os_idle(ctx->monitor);
}
static void
@@ -610,13 +514,8 @@ cmd_wait_for_window(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
struct umka_cmd *cmd = umka_cmd_buf;
cmd->type = UMKA_CMD_WAIT_FOR_WINDOW;
struct cmd_wait_for_window_arg *c = &cmd->wait_for_window.arg;
c->wnd_title = argv[1];
shell_run_cmd(ctx);
atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_EMPTY,
memory_order_release);
char *wnd_title = argv[1];
monitor_cmd_wait_for_window(ctx->monitor, wnd_title);
}
static void
@@ -692,7 +591,7 @@ bytes_to_kmgtpe(uint64_t *bytes, const char **kmg) {
}
static void
disk_list_partitions(struct shell_ctx *ctx, disk_t *d) {
disk_list_partitions(struct shell_ctx *ctx, struct disk *d) {
uint64_t kmgtpe_count = d->media_info.sector_size * d->media_info.capacity;
const char *kmgtpe = NULL;
bytes_to_kmgtpe(&kmgtpe_count, &kmgtpe);
@@ -700,7 +599,7 @@ disk_list_partitions(struct shell_ctx *ctx, disk_t *d) {
" %s), num_partitions=%u\n", d->name, d->media_info.sector_size,
d->media_info.capacity, kmgtpe_count, kmgtpe, d->num_partitions);
for (size_t i = 0; i < d->num_partitions; i++) {
partition_t *p = d->partitions[i];
struct partition *p = d->partitions[i];
const char *fsname;
if (p->fs_user_functions == xfs_user_functions) {
fsname = "xfs";
@@ -793,7 +692,7 @@ cmd_disk_add(struct shell_ctx *ctx, int argc, char **argv) {
cache_size, ctx->io);
if (umka_disk) {
COVERAGE_ON();
disk_t *disk = disk_add(&umka_disk->diskfunc, disk_name, umka_disk, 0);
struct disk *disk = disk_add(&umka_disk->diskfunc, disk_name, umka_disk, 0);
COVERAGE_OFF();
if (disk) {
COVERAGE_ON();
@@ -809,7 +708,7 @@ cmd_disk_add(struct shell_ctx *ctx, int argc, char **argv) {
static void
disk_del_by_name(struct shell_ctx *ctx, const char *name) {
for(disk_t *d = disk_list.next; d != &disk_list; d = d->next) {
for(struct disk *d = disk_list.next; d != &disk_list; d = d->next) {
if (!strcmp(d->name, name)) {
COVERAGE_ON();
disk_del(d);
@@ -1021,7 +920,7 @@ cmd_dump_wdata(struct shell_ctx *ctx, int argc, char **argv) {
if (argc > 2 && !strcmp(argv[2], "-p")) {
show_pointers = 1;
}
wdata_t *w = kos_window_data + idx;
struct wdata *w = kos_window_data + idx;
fprintf(ctx->fout, "captionEncoding: %u\n", w->caption_encoding);
fprintf(ctx->fout, "caption: %s\n", w->caption);
@@ -1036,9 +935,101 @@ cmd_dump_wdata(struct shell_ctx *ctx, int argc, char **argv) {
}
}
static void
cmd_dump_services(struct shell_ctx *sh, int argc, char **argv) {
const char *usage = \
"usage: dump_services [-p]\n"
" -p print fields that are pointers\n";
if (argc < 1) {
fputs(usage, sh->fout);
return;
}
int show_pointers = 0;
if (argc > 1 && !strcmp(argv[1], "-p")) {
show_pointers = 1;
}
for (struct srv *srv = srv_list.fd; srv != &srv_list; srv = srv->fd) {
fprintf(sh->fout, "srv_name: %s\n", srv->srv_name);
if (show_pointers) {
fprintf(sh->fout, "base: %p\n", (void*)srv->base);
}
}
}
static void
cmd_dump_shmem(struct shell_ctx *sh, int argc, char **argv) {
const char *usage = \
"usage: dump_shmem [-p]\n"
" -p print fields that are pointers\n";
if (argc < 1) {
fputs(usage, sh->fout);
return;
}
int show_pointers = 0;
if (argc > 1 && !strcmp(argv[1], "-p")) {
show_pointers = 1;
}
for (struct smem *smem = shmem_list.fd; smem != &shmem_list; smem = smem->fd) {
fprintf(sh->fout, "name: %s\n", smem->name);
fprintf(sh->fout, "size: %" PRIu32 "\n", smem->size);
fprintf(sh->fout, "refcount: %" PRIu32 "\n", smem->refcount);
if (show_pointers) {
fprintf(sh->fout, "base: %p\n", (void*)smem->base);
}
}
}
static void
cmd_dump_dlls(struct shell_ctx *sh, int argc, char **argv) {
const char *usage = \
"usage: dump_dlls [-p]\n"
" -p print fields that are pointers\n";
if (argc < 1) {
fputs(usage, sh->fout);
return;
}
int show_pointers = 0;
if (argc > 1 && !strcmp(argv[1], "-p")) {
show_pointers = 1;
}
for (struct dlldescr *dll = dll_list.fd; dll != &dll_list; dll = dll->fd) {
fprintf(sh->fout, "name: %s\n", dll->name);
fprintf(sh->fout, "size: %" PRIu32 "\n", dll->size);
fprintf(sh->fout, "refcount: %" PRIu32 "\n", dll->refcount);
fprintf(sh->fout, "symbols_num: %" PRIu32 "\n", dll->symbols_num);
if (show_pointers) {
fprintf(sh->fout, "data: %p\n", (void*)dll->data);
fprintf(sh->fout, "defaultbase: %p\n", (void*)dll->defaultbase);
fprintf(sh->fout, "coff_hdr: %p\n", (void*)dll->coff_hdr);
fprintf(sh->fout, "symbols_ptr: %p\n", (void*)dll->symbols_ptr);
fprintf(sh->fout, "symbols_lim: %p\n", (void*)dll->symbols_lim);
fprintf(sh->fout, "exports: %p\n", (void*)dll->exports);
}
}
}
static void
dump_proc(struct shell_ctx *sh, struct proc *p, int show_pointers) {
fprintf(sh->fout, "mem_used: %u\n", p->mem_used);
if (show_pointers) {
fprintf(sh->fout, "dlls_list_ptr: %p\n", (void*)p->dlls_list_ptr);
}
if (p->dlls_list_ptr) {
for (struct hdll *hdll = p->dlls_list_ptr->fd; hdll != p->dlls_list_ptr; hdll = hdll->fd) {
if (show_pointers) {
fprintf(sh->fout, "base: %p\n", (void*)hdll->base);
fprintf(sh->fout, "parent: %p\n", (void*)hdll->parent);
}
fprintf(sh->fout, "size: %u\n", hdll->size);
fprintf(sh->fout, "pid: %u\n", hdll->pid);
fprintf(sh->fout, "refcount: %u\n", hdll->refcount);
fprintf(sh->fout, "parent.name: %s\n", hdll->parent->name);
}
}
}
static void
cmd_dump_appdata(struct shell_ctx *ctx, int argc, char **argv) {
(void)ctx;
const char *usage = \
"usage: dump_appdata <index> [-p]\n"
" index index into appdata array to dump\n"
@@ -1052,13 +1043,14 @@ cmd_dump_appdata(struct shell_ctx *ctx, int argc, char **argv) {
if (argc > 2 && !strcmp(argv[2], "-p")) {
show_pointers = 1;
}
appdata_t *a = kos_slot_base + idx;
struct appdata *a = kos_slot_base + idx;
fprintf(ctx->fout, "app_name: %s\n", a->app_name);
if (show_pointers) {
fprintf(ctx->fout, "process: %p\n", (void*)a->process);
fprintf(ctx->fout, "fpu_state: %p\n", (void*)a->fpu_state);
fprintf(ctx->fout, "exc_handler: %p\n", (void*)a->exc_handler);
}
dump_proc(ctx, a->process, show_pointers);
fprintf(ctx->fout, "except_mask: %" PRIx32 "\n", a->except_mask);
if (show_pointers) {
fprintf(ctx->fout, "pl0_stack: %p\n", (void*)a->pl0_stack);
@@ -1083,11 +1075,11 @@ cmd_dump_appdata(struct shell_ctx *ctx, int argc, char **argv) {
if (show_pointers) {
fprintf(ctx->fout, " %p", (void*)a->in_schedule.prev);
}
fprintf(ctx->fout, " (%u), next", (appdata_t*)a->in_schedule.prev - kos_slot_base);
fprintf(ctx->fout, " (%u), next", (struct appdata*)a->in_schedule.prev - kos_slot_base);
if (show_pointers) {
fprintf(ctx->fout, " %p", (void*)a->in_schedule.next);
}
fprintf(ctx->fout, " (%u)\n", (appdata_t*)a->in_schedule.next - kos_slot_base);
fprintf(ctx->fout, " (%u)\n", (struct appdata*)a->in_schedule.next - kos_slot_base);
}
static void
@@ -1268,16 +1260,8 @@ cmd_mouse_move(struct shell_ctx *ctx, int argc, char **argv) {
}
uint32_t btn_state = lbheld + (rbheld << 1) + (mbheld << 2) + (yabs << 30)
+ (xabs << 31);
struct umka_cmd *cmd = shell_get_cmd(ctx);
cmd->type = UMKA_CMD_SET_MOUSE_DATA;
struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg;
c->btn_state = btn_state;
c->xmoving = xmoving;
c->ymoving = ymoving;
c->vscroll = vscroll;
c->hscroll = hscroll;
shell_run_cmd(ctx);
shell_clear_cmd(cmd);
monitor_cmd_mouse_move(ctx->monitor, btn_state, xmoving, ymoving, vscroll, hscroll);
}
static void
@@ -1289,7 +1273,7 @@ cmd_process_info(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
process_information_t info;
struct process_information info;
ssize_t pid;
shell_parse_sint(ctx, &pid, argv[1]);
COVERAGE_ON();
@@ -1386,11 +1370,11 @@ cmd_set_window_colors(struct shell_ctx *ctx, int argc, char **argv) {
" <grab_text> <work> <work_button> <work_button_text> <work_text>"
" <work_graph>\n"
" * all colors are in hex\n";
if (argc != (1 + sizeof(system_colors_t)/4)) {
if (argc != (1 + sizeof(struct system_colors)/4)) {
fputs(usage, ctx->fout);
return;
}
system_colors_t colors;
struct system_colors colors;
colors.frame = strtoul(argv[1], NULL, 16);
colors.grab = strtoul(argv[2], NULL, 16);
colors.work_3d_dark = strtoul(argv[3], NULL, 16);
@@ -1416,7 +1400,7 @@ cmd_get_window_colors(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
system_colors_t colors;
struct system_colors colors;
memset(&colors, 0xaa, sizeof(colors));
COVERAGE_ON();
umka_sys_get_window_colors(&colors);
@@ -1460,7 +1444,7 @@ cmd_get_screen_area(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
rect_t wa;
struct rect wa;
COVERAGE_ON();
umka_sys_get_screen_area(&wa);
COVERAGE_OFF();
@@ -1483,7 +1467,7 @@ cmd_set_screen_area(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
rect_t wa;
struct rect wa;
wa.left = strtoul(argv[1], NULL, 0);
wa.top = strtoul(argv[2], NULL, 0);
wa.right = strtoul(argv[3], NULL, 0);
@@ -1503,7 +1487,7 @@ cmd_get_skin_margins(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
rect_t wa;
struct rect wa;
COVERAGE_ON();
umka_sys_get_skin_margins(&wa);
COVERAGE_OFF();
@@ -1899,12 +1883,10 @@ cmd_set_mouse_pos_screen(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
struct point16s pos;
pos.x = strtol(argv[1], NULL, 0);
pos.y = strtol(argv[2], NULL, 0);
COVERAGE_ON();
umka_sys_set_mouse_pos_screen(pos);
COVERAGE_OFF();
int16_t x = strtol(argv[1], NULL, 0);
int16_t y = strtol(argv[2], NULL, 0);
monitor_cmd_sys_set_mouse_pos_screen(ctx->monitor, x, y);
}
static void
@@ -2513,8 +2495,7 @@ cmd_cd(struct shell_ctx *ctx, int argc, char **argv) {
}
static void
ls_range(struct shell_ctx *ctx, f7080s1arg_t *fX0, f70or80_t f70or80) {
f7080ret_t r;
ls_range(struct shell_ctx *sh, struct f7080s1arg *fX0, enum f70or80 f70or80) {
size_t bdfe_len = (fX0->encoding == CP866) ? BDFE_LEN_CP866 :
BDFE_LEN_UNICODE;
uint32_t requested = fX0->size;
@@ -2525,12 +2506,11 @@ ls_range(struct shell_ctx *ctx, f7080s1arg_t *fX0, f70or80_t f70or80) {
if (fX0->size > requested) {
fX0->size = requested;
}
COVERAGE_ON();
umka_sys_lfn(fX0, &r, f70or80);
COVERAGE_OFF();
struct f7080ret r = monitor_cmd_sys_lfn(sh->monitor, f70or80,
(union f7080arg*)fX0);
fX0->offset += fX0->size;
print_f70_status(ctx, &r, 1);
f7080s1info_t *dir = fX0->buf;
print_f70_status(sh, &r, 1);
struct f7080s1info *dir = fX0->buf;
int ok = (r.count <= fX0->size);
ok &= (dir->cnt == r.count);
ok &= (r.status == KOS_ERROR_SUCCESS && r.count == fX0->size)
@@ -2538,12 +2518,12 @@ ls_range(struct shell_ctx *ctx, f7080s1arg_t *fX0, f70or80_t f70or80) {
assert(ok);
if (!ok)
break;
bdfe_t *bdfe = dir->bdfes;
struct bdfe *bdfe = dir->bdfes;
for (size_t i = 0; i < dir->cnt; i++) {
char fattr[KF_ATTR_CNT+1];
convert_f70_file_attr(bdfe->attr, fattr);
fprintf(ctx->fout, "%s %s\n", fattr, bdfe->name);
bdfe = (bdfe_t*)((uintptr_t)bdfe + bdfe_len);
fprintf(sh->fout, "%s %s\n", fattr, bdfe->name);
bdfe = (struct bdfe*)((uintptr_t)bdfe + bdfe_len);
}
if (r.status == KOS_ERROR_END_OF_FILE) {
break;
@@ -2552,25 +2532,16 @@ ls_range(struct shell_ctx *ctx, f7080s1arg_t *fX0, f70or80_t f70or80) {
}
static void
ls_all(struct shell_ctx *ctx, f7080s1arg_t *fX0, f70or80_t f70or80) {
f7080ret_t r;
ls_all(struct shell_ctx *ctx, struct f7080s1arg *fX0, enum f70or80 f70or80) {
size_t bdfe_len = (fX0->encoding == CP866) ? BDFE_LEN_CP866 :
BDFE_LEN_UNICODE;
while (true) {
struct umka_cmd *cmd = umka_cmd_buf;
struct cmd_sys_lfn_arg *c = &cmd->sys_lfn.arg;
cmd->type = UMKA_CMD_SYS_LFN;
c->f70or80 = f70or80;
c->bufptr = fX0;
c->r = &r;
shell_run_cmd(ctx);
atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_EMPTY,
memory_order_release);
struct f7080ret r = monitor_cmd_sys_lfn(ctx->monitor, f70or80,
(union f7080arg*)fX0);
print_f70_status(ctx, &r, 1);
assert((r.status == ERROR_SUCCESS && r.count == fX0->size)
|| (r.status == ERROR_END_OF_FILE && r.count < fX0->size));
f7080s1info_t *dir = fX0->buf;
struct f7080s1info *dir = fX0->buf;
fX0->offset += dir->cnt;
int ok = (r.count <= fX0->size);
ok &= (dir->cnt == r.count);
@@ -2580,12 +2551,12 @@ ls_all(struct shell_ctx *ctx, f7080s1arg_t *fX0, f70or80_t f70or80) {
if (!ok)
break;
fprintf(ctx->fout, "total = %"PRIi32"\n", dir->total_cnt);
bdfe_t *bdfe = dir->bdfes;
struct bdfe *bdfe = dir->bdfes;
for (size_t i = 0; i < dir->cnt; i++) {
char fattr[KF_ATTR_CNT+1];
convert_f70_file_attr(bdfe->attr, fattr);
fprintf(ctx->fout, "%s %s\n", fattr, bdfe->name);
bdfe = (bdfe_t*)((uintptr_t)bdfe + bdfe_len);
bdfe = (struct bdfe*)((uintptr_t)bdfe + bdfe_len);
}
if (r.status == KOS_ERROR_END_OF_FILE) {
break;
@@ -2593,9 +2564,9 @@ ls_all(struct shell_ctx *ctx, f7080s1arg_t *fX0, f70or80_t f70or80) {
}
}
static fs_enc_t
static enum fs_enc
parse_encoding(const char *str) {
fs_enc_t enc;
enum fs_enc enc;
if (!strcmp(str, "default")) {
enc = DEFAULT_ENCODING;
} else if (!strcmp(str, "cp866")) {
@@ -2620,17 +2591,15 @@ cmd_exec(struct shell_ctx *ctx, int argc, char **argv) {
fputs(usage, ctx->fout);
return;
}
f7080s7arg_t fX0 = {.sf = 7};
f7080ret_t r;
struct f7080s7arg fX0 = {.sf = 7};
int opt = 1;
fX0.u.f70.zero = 0;
fX0.u.f70.path = argv[opt++];
fX0.flags = 0;
fX0.params = "test";
COVERAGE_ON();
umka_sys_lfn(&fX0, &r, F70);
COVERAGE_OFF();
struct f7080ret r = monitor_cmd_sys_lfn(ctx->monitor, F70,
(union f7080arg*)&fX0);
if (r.status < 0) {
r.status = -r.status;
} else {
@@ -2642,7 +2611,7 @@ cmd_exec(struct shell_ctx *ctx, int argc, char **argv) {
static void
cmd_ls(struct shell_ctx *ctx, int argc, char **argv, const char *usage,
f70or80_t f70or80) {
enum f70or80 f70or80) {
(void)ctx;
if (!argc) {
fputs(usage, ctx->fout);
@@ -2680,10 +2649,11 @@ cmd_ls(struct shell_ctx *ctx, int argc, char **argv, const char *usage,
size_t bdfe_len = (readdir_enc <= CP866) ? BDFE_LEN_CP866 :
BDFE_LEN_UNICODE;
f7080s1info_t *dir = (f7080s1info_t*)malloc(sizeof(f7080s1info_t) +
bdfe_len * MAX_DIRENTS_TO_READ);
f7080s1arg_t fX0 = {.sf = 1, .offset = from_idx, .encoding = readdir_enc,
.size = count, .buf = dir};
struct f7080s1info *dir = (struct f7080s1info*)malloc(sizeof(struct f7080s1info) +
bdfe_len * MAX_DIRENTS_TO_READ);
struct f7080s1arg fX0 = {.sf = 1, .offset = from_idx,
.encoding = readdir_enc, .size = count,
.buf = dir};
if (f70or80 == F70) {
fX0.u.f70.zero = 0;
fX0.u.f70.path = path;
@@ -2725,7 +2695,7 @@ cmd_ls80(struct shell_ctx *ctx, int argc, char **argv) {
}
static void
cmd_stat(struct shell_ctx *ctx, int argc, char **argv, f70or80_t f70or80) {
cmd_stat(struct shell_ctx *ctx, int argc, char **argv, enum f70or80 f70or80) {
const char *usage = \
"usage: stat <file> [-c] [-m] [-a]\n"
" file path/to/file\n"
@@ -2738,9 +2708,8 @@ cmd_stat(struct shell_ctx *ctx, int argc, char **argv, f70or80_t f70or80) {
}
optparse_init(&ctx->opts, argv);
bool force_ctime = false, force_mtime = false, force_atime = false;
f7080s5arg_t fX0 = {.sf = 5, .flags = 0};
f7080ret_t r;
bdfe_t file;
struct f7080s5arg fX0 = {.sf = 5, .flags = 0};
struct bdfe file;
fX0.buf = &file;
if (f70or80 == F70) {
fX0.u.f70.zero = 0;
@@ -2749,9 +2718,8 @@ cmd_stat(struct shell_ctx *ctx, int argc, char **argv, f70or80_t f70or80) {
fX0.u.f80.path_encoding = DEFAULT_PATH_ENCODING;
fX0.u.f80.path = optparse_arg(&ctx->opts);
}
COVERAGE_ON();
umka_sys_lfn(&fX0, &r, f70or80);
COVERAGE_OFF();
struct f7080ret r = monitor_cmd_sys_lfn(ctx->monitor, f70or80,
(union f7080arg*)&fX0);
print_f70_status(ctx, &r, 0);
if (r.status != KOS_ERROR_SUCCESS)
return;
@@ -2817,15 +2785,15 @@ cmd_stat80(struct shell_ctx *ctx, int argc, char **argv) {
}
static void
cmd_read(struct shell_ctx *ctx, int argc, char **argv, f70or80_t f70or80,
cmd_read(struct shell_ctx *ctx, int argc, char **argv, enum f70or80 f70or80,
const char *usage) {
(void)ctx;
if (argc < 3) {
fputs(usage, ctx->fout);
return;
}
f7080s0arg_t fX0 = {.sf = 0};
f7080ret_t r;
struct f7080s0arg fX0 = {.sf = 0};
struct f7080ret r;
bool dump_bytes = false, dump_hash = false;
int opt = 1;
if (f70or80 == F70) {
@@ -3071,13 +3039,25 @@ cmd_load_dll(struct shell_ctx *ctx, int argc, char **argv) {
COVERAGE_ON();
void *export = umka_sys_load_dll(argv[1]);
COVERAGE_OFF();
// if (ctx->reproducible)
fprintf(ctx->fout, "### export: %p\n", export);
if (!ctx->reproducible) {
fprintf(ctx->fout, "### export: %p\n", export);
}
}
static void
cmd_int3(struct shell_ctx *sh, int argc, char **argv) {
(void)argv;
const char *usage = \
"usage: int3\n";
if (argc != 1) {
fputs(usage, sh->fout);
return;
}
__asm__ __inline__ __volatile__ ( "int3" : : : "memory" );
}
static void
cmd_stack_init(struct shell_ctx *ctx, int argc, char **argv) {
(void)ctx;
(void)argv;
const char *usage = \
"usage: stack_init\n";
@@ -3115,7 +3095,7 @@ cmd_net_add_device(struct shell_ctx *ctx, int argc, char **argv) {
return;
}
}
struct vnet *vnet = vnet_init(devtype, ctx->running); // TODO: list like block devices
struct vnet *vnet = vnet_init(devtype, ctx->monitor->running); // TODO: list like block devices
COVERAGE_ON();
int32_t dev_num = kos_net_add_device(&vnet->eth.net);
COVERAGE_OFF();
@@ -3391,7 +3371,7 @@ cmd_net_open_socket(struct shell_ctx *ctx, int argc, char **argv) {
uint32_t type = strtoul(argv[2], NULL, 0);
uint32_t protocol = strtoul(argv[3], NULL, 0);
COVERAGE_ON();
f75ret_t r = umka_sys_net_open_socket(domain, type, protocol);
struct f75ret r = umka_sys_net_open_socket(domain, type, protocol);
COVERAGE_OFF();
fprintf(ctx->fout, "value: 0x%" PRIx32 "\n", r.value);
fprintf(ctx->fout, "errorcode: 0x%" PRIx32 "\n", r.errorcode);
@@ -3410,7 +3390,7 @@ cmd_net_close_socket(struct shell_ctx *ctx, int argc, char **argv) {
}
uint32_t fd = strtoul(argv[1], NULL, 0);
COVERAGE_ON();
f75ret_t r = umka_sys_net_close_socket(fd);
struct f75ret r = umka_sys_net_close_socket(fd);
COVERAGE_OFF();
fprintf(ctx->fout, "value: 0x%" PRIx32 "\n", r.value);
fprintf(ctx->fout, "errorcode: 0x%" PRIx32 "\n", r.errorcode);
@@ -3439,7 +3419,7 @@ cmd_net_bind(struct shell_ctx *ctx, int argc, char **argv) {
sa.sin_addr.s_addr = addr;
fprintf(ctx->fout, "sockaddr at %p\n", (void*)&sa);
COVERAGE_ON();
f75ret_t r = umka_sys_net_bind(fd, &sa, sizeof(struct sockaddr_in));
struct f75ret r = umka_sys_net_bind(fd, &sa, sizeof(struct sockaddr_in));
COVERAGE_OFF();
fprintf(ctx->fout, "value: 0x%" PRIx32 "\n", r.value);
fprintf(ctx->fout, "errorcode: 0x%" PRIx32 "\n", r.errorcode);
@@ -3459,7 +3439,7 @@ cmd_net_listen(struct shell_ctx *ctx, int argc, char **argv) {
uint32_t fd = strtoul(argv[1], NULL, 0);
uint32_t backlog = strtoul(argv[2], NULL, 0);
COVERAGE_ON();
f75ret_t r = umka_sys_net_listen(fd, backlog);
struct f75ret r = umka_sys_net_listen(fd, backlog);
COVERAGE_OFF();
fprintf(ctx->fout, "value: 0x%" PRIx32 "\n", r.value);
fprintf(ctx->fout, "errorcode: 0x%" PRIx32 "\n", r.errorcode);
@@ -3488,7 +3468,7 @@ cmd_net_connect(struct shell_ctx *ctx, int argc, char **argv) {
sa.sin_addr.s_addr = addr;
fprintf(ctx->fout, "sockaddr at %p\n", (void*)&sa);
COVERAGE_ON();
f75ret_t r = umka_sys_net_connect(fd, &sa, sizeof(struct sockaddr_in));
struct f75ret r = umka_sys_net_connect(fd, &sa, sizeof(struct sockaddr_in));
COVERAGE_OFF();
fprintf(ctx->fout, "value: 0x%" PRIx32 "\n", r.value);
fprintf(ctx->fout, "errorcode: 0x%" PRIx32 "\n", r.errorcode);
@@ -3517,7 +3497,7 @@ cmd_net_accept(struct shell_ctx *ctx, int argc, char **argv) {
sa.sin_addr.s_addr = addr;
fprintf(ctx->fout, "sockaddr at %p\n", (void*)&sa);
COVERAGE_ON();
f75ret_t r = umka_sys_net_accept(fd, &sa, sizeof(struct sockaddr_in));
struct f75ret r = umka_sys_net_accept(fd, &sa, sizeof(struct sockaddr_in));
COVERAGE_OFF();
fprintf(ctx->fout, "value: 0x%" PRIx32 "\n", r.value);
fprintf(ctx->fout, "errorcode: 0x%" PRIx32 "\n", r.errorcode);
@@ -3535,7 +3515,7 @@ cmd_net_eth_read_mac(struct shell_ctx *ctx, int argc, char **argv) {
}
uint32_t dev_num = strtoul(argv[1], NULL, 0);
COVERAGE_ON();
f76ret_t r = umka_sys_net_eth_read_mac(dev_num);
struct f76ret r = umka_sys_net_eth_read_mac(dev_num);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3559,7 +3539,7 @@ cmd_net_ipv4_get_addr(struct shell_ctx *ctx, int argc, char **argv) {
}
uint32_t dev_num = strtoul(argv[1], NULL, 0);
COVERAGE_ON();
f76ret_t r = umka_sys_net_ipv4_get_addr(dev_num);
struct f76ret r = umka_sys_net_ipv4_get_addr(dev_num);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3585,7 +3565,7 @@ cmd_net_ipv4_set_addr(struct shell_ctx *ctx, int argc, char **argv) {
char *addr_str = argv[2];
uint32_t addr = inet_addr(addr_str);
COVERAGE_ON();
f76ret_t r = umka_sys_net_ipv4_set_addr(dev_num, addr);
struct f76ret r = umka_sys_net_ipv4_set_addr(dev_num, addr);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3606,7 +3586,7 @@ cmd_net_ipv4_get_dns(struct shell_ctx *ctx, int argc, char **argv) {
}
uint32_t dev_num = strtoul(argv[1], NULL, 0);
COVERAGE_ON();
f76ret_t r = umka_sys_net_ipv4_get_dns(dev_num);
struct f76ret r = umka_sys_net_ipv4_get_dns(dev_num);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3631,7 +3611,7 @@ cmd_net_ipv4_set_dns(struct shell_ctx *ctx, int argc, char **argv) {
uint32_t dev_num = strtoul(argv[1], NULL, 0);
uint32_t dns = inet_addr(argv[2]);
COVERAGE_ON();
f76ret_t r = umka_sys_net_ipv4_set_dns(dev_num, dns);
struct f76ret r = umka_sys_net_ipv4_set_dns(dev_num, dns);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3652,7 +3632,7 @@ cmd_net_ipv4_get_subnet(struct shell_ctx *ctx, int argc, char **argv) {
}
uint32_t dev_num = strtoul(argv[1], NULL, 0);
COVERAGE_ON();
f76ret_t r = umka_sys_net_ipv4_get_subnet(dev_num);
struct f76ret r = umka_sys_net_ipv4_get_subnet(dev_num);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3678,7 +3658,7 @@ cmd_net_ipv4_set_subnet(struct shell_ctx *ctx, int argc, char **argv) {
char *subnet_str = argv[2];
uint32_t subnet = inet_addr(subnet_str);
COVERAGE_ON();
f76ret_t r = umka_sys_net_ipv4_set_subnet(dev_num, subnet);
struct f76ret r = umka_sys_net_ipv4_set_subnet(dev_num, subnet);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3699,7 +3679,7 @@ cmd_net_ipv4_get_gw(struct shell_ctx *ctx, int argc, char **argv) {
}
uint32_t dev_num = strtoul(argv[1], NULL, 0);
COVERAGE_ON();
f76ret_t r = umka_sys_net_ipv4_get_gw(dev_num);
struct f76ret r = umka_sys_net_ipv4_get_gw(dev_num);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3725,7 +3705,7 @@ cmd_net_ipv4_set_gw(struct shell_ctx *ctx, int argc, char **argv) {
char *gw_str = argv[2];
uint32_t gw = inet_addr(gw_str);
COVERAGE_ON();
f76ret_t r = umka_sys_net_ipv4_set_gw(dev_num, gw);
struct f76ret r = umka_sys_net_ipv4_set_gw(dev_num, gw);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3746,7 +3726,7 @@ cmd_net_arp_get_count(struct shell_ctx *ctx, int argc, char **argv) {
}
uint32_t dev_num = strtoul(argv[1], NULL, 0);
COVERAGE_ON();
f76ret_t r = umka_sys_net_arp_get_count(dev_num);
struct f76ret r = umka_sys_net_arp_get_count(dev_num);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3770,7 +3750,7 @@ cmd_net_arp_get_entry(struct shell_ctx *ctx, int argc, char **argv) {
uint32_t arp_num = strtoul(argv[2], NULL, 0);
arp_entry_t arp;
COVERAGE_ON();
f76ret_t r = umka_sys_net_arp_get_entry(dev_num, arp_num, &arp);
struct f76ret r = umka_sys_net_arp_get_entry(dev_num, arp_num, &arp);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3813,7 +3793,7 @@ cmd_net_arp_add_entry(struct shell_ctx *ctx, int argc, char **argv) {
arp.status = strtoul(argv[4], NULL, 0);
arp.ttl = strtoul(argv[5], NULL, 0);
COVERAGE_ON();
f76ret_t r = umka_sys_net_arp_add_entry(dev_num, &arp);
struct f76ret r = umka_sys_net_arp_add_entry(dev_num, &arp);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -3834,7 +3814,7 @@ cmd_net_arp_del_entry(struct shell_ctx *ctx, int argc, char **argv) {
uint32_t dev_num = strtoul(argv[1], NULL, 0);
int32_t arp_num = strtoul(argv[2], NULL, 0);
COVERAGE_ON();
f76ret_t r = umka_sys_net_arp_del_entry(dev_num, arp_num);
struct f76ret r = umka_sys_net_arp_del_entry(dev_num, arp_num);
COVERAGE_OFF();
if (r.eax == UINT32_MAX) {
fprintf(ctx->fout, "status: fail\n");
@@ -4103,7 +4083,10 @@ func_table_t cmd_cmds[] = {
{ "draw_rect", cmd_draw_rect },
{ "draw_window", cmd_draw_window },
{ "dump_appdata", cmd_dump_appdata },
{ "dump_dlls", cmd_dump_dlls },
{ "dump_key_buff", cmd_dump_key_buff },
{ "dump_services", cmd_dump_services },
{ "dump_shmem", cmd_dump_shmem },
{ "dump_wdata", cmd_dump_wdata },
{ "dump_win_pos", cmd_dump_win_pos },
{ "dump_win_stack", cmd_dump_win_stack },
@@ -4126,6 +4109,7 @@ func_table_t cmd_cmds[] = {
{ "get_window_colors", cmd_get_window_colors },
{ "help", cmd_help },
{ "i40", cmd_i40 },
{ "int3", cmd_int3 },
// f68
{ "kos_sys_misc_init_heap", cmd_kos_sys_misc_init_heap }, // 11
{ "kos_sys_misc_load_file", cmd_kos_sys_misc_load_file }, // 27
@@ -4210,91 +4194,6 @@ func_table_t cmd_cmds[] = {
{ NULL, NULL },
};
static void
shell_run_cmd_sync(struct shell_ctx *ctx) {
struct umka_cmd *cmd = umka_cmd_buf;
switch (cmd->type) {
case UMKA_CMD_WAIT_FOR_IDLE: {
COVERAGE_ON();
umka_wait_for_idle();
COVERAGE_OFF();
break;
}
case UMKA_CMD_WAIT_FOR_OS_IDLE: {
COVERAGE_ON();
umka_wait_for_os_idle();
COVERAGE_OFF();
break;
}
case UMKA_CMD_WAIT_FOR_WINDOW: {
struct cmd_wait_for_window_arg *c = &cmd->wait_for_window.arg;
COVERAGE_ON();
umka_wait_for_window(c->wnd_title);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SYS_CSLEEP: {
struct cmd_sys_csleep_arg *c = &cmd->sys_csleep.arg;
COVERAGE_ON();
umka_sys_csleep(c->csec);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SET_MOUSE_DATA: {
struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg;
COVERAGE_ON();
kos_set_mouse_data(c->btn_state, c->xmoving, c->ymoving, c->vscroll,
c->hscroll);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SEND_SCANCODE: {
struct cmd_send_scancode_arg *c = &cmd->send_scancode.arg;
COVERAGE_ON();
umka_set_keyboard_data(c->scancode);
COVERAGE_OFF();
break;
}
case UMKA_CMD_SYS_LFN: {
struct cmd_sys_lfn_arg *c = &cmd->sys_lfn.arg;
COVERAGE_ON();
umka_sys_lfn(c->bufptr, c->r, c->f70or80);
COVERAGE_OFF();
break;
}
default:
fprintf(ctx->fout, "[!] unknown command: %u\n", cmd->type);
break;
}
atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_DONE,
memory_order_release);
pthread_cond_signal(&ctx->cmd_done);
}
struct umka_cmd *
shell_get_cmd(struct shell_ctx *shell) {
(void)shell;
return umka_cmd_buf;
}
void
shell_run_cmd(struct shell_ctx *ctx) {
struct umka_cmd *cmd = umka_cmd_buf;
atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_READY,
memory_order_release);
if (atomic_load_explicit(ctx->running, memory_order_acquire) == UMKA_RUNNING_YES) {
pthread_cond_wait(&ctx->cmd_done, &ctx->cmd_mutex);
} else {
shell_run_cmd_sync(ctx);
}
}
void
shell_clear_cmd(struct umka_cmd *cmd) {
atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_EMPTY,
memory_order_release);
}
static void
cmd_help(struct shell_ctx *ctx, int argc, char **argv) {
const char *usage = \
@@ -4341,7 +4240,7 @@ run_test(struct shell_ctx *ctx) {
ic_enable_multiline(0);
ic_enable_beep(0);
pthread_mutex_lock(&ctx->cmd_mutex);
pthread_mutex_lock(&ctx->monitor->cmd_mutex); // should this be done in monitor?
int is_tty = isatty(fileno(stdin));
char **argv = (char**)calloc(MAX_COMMAND_ARGS + 1, sizeof(char*));
ic_set_default_completer(completer, NULL);
@@ -4385,7 +4284,7 @@ run_test(struct shell_ctx *ctx) {
}
free(argv);
pthread_mutex_unlock(&ctx->cmd_mutex);
pthread_mutex_unlock(&ctx->monitor->cmd_mutex);
if (fdstdin != -1) {
close(STDIN_FILENO);
@@ -4397,18 +4296,17 @@ run_test(struct shell_ctx *ctx) {
struct shell_ctx *
shell_init(const int reproducible, const char *hist_file,
const struct umka_ctx *umka, const struct umka_io *io, FILE *fin) {
const struct umka_ctx *umka, const struct umka_io *io,
struct monitor_ctx *monitor, FILE *fin) {
struct shell_ctx *ctx = malloc(sizeof(struct shell_ctx));
ctx->umka = umka;
ctx->io = io;
ctx->monitor = monitor;
ctx->reproducible = reproducible;
ctx->hist_file = hist_file;
ctx->var = NULL;
ctx->fin = fin;
ctx->fout = stdout;
ctx->running = &umka->running;
pthread_cond_init(&ctx->cmd_done, NULL);
pthread_mutex_init(&ctx->cmd_mutex, NULL);
return ctx;
}
+4 -140
View File
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <pthread.h>
#include "umka.h"
#include "monitor.h"
#include "umkaio.h"
#include "optparse/optparse.h"
@@ -38,20 +39,19 @@ struct shell_var {
struct shell_ctx {
const struct umka_ctx *umka;
const struct umka_io *io;
struct monitor_ctx *monitor;
int reproducible;
const char *hist_file;
struct shell_var *var;
FILE *fin;
FILE *fout;
const atomic_int *running;
pthread_cond_t cmd_done;
pthread_mutex_t cmd_mutex;
struct optparse opts;
};
struct shell_ctx *
shell_init(const int reproducible, const char *hist_file,
const struct umka_ctx *umka, const struct umka_io *io, FILE *fin);
const struct umka_ctx *umka, const struct umka_io *io,
struct monitor_ctx *monitor, FILE *fin);
void
shell_close(struct shell_ctx *shell);
@@ -59,140 +59,4 @@ shell_close(struct shell_ctx *shell);
void *
run_test(struct shell_ctx *ctx);
enum {
UMKA_CMD_NONE,
UMKA_CMD_SET_MOUSE_DATA,
UMKA_CMD_WAIT_FOR_IDLE,
UMKA_CMD_WAIT_FOR_OS_IDLE,
UMKA_CMD_WAIT_FOR_WINDOW,
UMKA_CMD_SYS_CSLEEP,
UMKA_CMD_SYS_PROCESS_INFO,
UMKA_CMD_SYS_GET_MOUSE_POS_SCREEN,
UMKA_CMD_SYS_LFN,
UMKA_CMD_SEND_SCANCODE,
};
struct cmd_set_mouse_data_arg {
uint32_t btn_state;
int32_t xmoving;
int32_t ymoving;
int32_t vscroll;
int32_t hscroll;
};
struct cmd_set_mouse_data_ret {
char stub;
};
struct cmd_set_mouse_data {
struct cmd_set_mouse_data_arg arg;
struct cmd_set_mouse_data_ret ret;
};
struct cmd_sys_lfn_arg {
f70or80_t f70or80;
f7080s1arg_t *bufptr;
f7080ret_t *r;
};
struct cmd_sys_lfn_ret {
f7080ret_t status;
};
struct cmd_sys_lfn {
struct cmd_sys_lfn_arg arg;
struct cmd_sys_lfn_ret ret;
};
struct cmd_sys_process_info_arg {
int32_t pid;
void *param;
};
struct cmd_sys_process_info_ret {
char stub;
};
struct cmd_sys_process_info {
struct cmd_sys_process_info_arg arg;
struct cmd_sys_process_info_ret ret;
};
struct cmd_sys_get_mouse_pos_screen_arg {
char stub;
};
struct cmd_sys_get_mouse_pos_screen_ret {
struct point16s pos;
};
struct cmd_sys_get_mouse_pos_screen {
struct cmd_sys_get_mouse_pos_screen_arg arg;
struct cmd_sys_get_mouse_pos_screen_ret ret;
};
struct cmd_sys_csleep_arg {
uint32_t csec;
};
struct cmd_sys_csleep_ret {
char stub;
};
struct cmd_sys_csleep {
struct cmd_sys_csleep_arg arg;
struct cmd_sys_csleep_ret ret;
};
struct cmd_wait_for_window_arg {
char *wnd_title;
};
struct cmd_wait_for_window_ret {
char stub;
};
struct cmd_wait_for_window {
struct cmd_wait_for_window_arg arg;
struct cmd_wait_for_window_ret ret;
};
struct cmd_send_scancode_arg {
int scancode;
};
struct cmd_send_scancode_ret {
char stub;
};
struct cmd_send_scancode {
struct cmd_send_scancode_arg arg;
struct cmd_send_scancode_ret ret;
};
struct umka_cmd {
atomic_int status;
uint32_t type;
union {
// internal funcs
struct cmd_set_mouse_data set_mouse_data;
struct cmd_send_scancode send_scancode;
struct cmd_wait_for_window wait_for_window;
// syscalls
struct cmd_sys_csleep sys_csleep;
struct cmd_sys_process_info sys_process_info;
struct cmd_sys_lfn sys_lfn;
struct cmd_sys_get_mouse_pos_screen sys_get_mouse_pos_screen;
};
};
struct umka_cmd *
shell_get_cmd(struct shell_ctx *shell);
void
shell_run_cmd(struct shell_ctx *ctx);
void
shell_clear_cmd(struct umka_cmd *cmd);
#endif // SHELL_H_INCLUDED
-3
View File
@@ -1,3 +0,0 @@
umka_init
ramdisk_init ../img/kolibri.img
load_dll /sys/lib/network.obj
+12 -12
View File
@@ -110,12 +110,12 @@ total = 7
status = 6 end_of_file, count = 7
total = 7
----f .
----f ..
----f d
----f 48@f'
----f f'f'f'
----f f'iØ=Üf'
----f 48@3
----- 
-----
-----
-----
-----
-----
/> ls70 /hd0/1/â¦â¦â¦/ -e utf8
status = 5 file_not_found
/> ls70 /hd0/1/â¦â¦â¦/ -e utf16
@@ -167,12 +167,12 @@ total = 7
status = 6 end_of_file, count = 7
total = 7
----f .
----f ..
----f d
----f 48@f'
----f f'f'f'
----f f'iØ=Üf'
----f 48@3
r-s-f 
--s-f 
-hs-f
rhs-f
--slf
---lf
/> ls80 /hd0/1/â¦â¦â¦/ -e utf8
status = 6 end_of_file, count = 3
total = 3
+1
View File
@@ -58,6 +58,7 @@ font smoothing: 0 - off
1: 1
/> dump_appdata 2
app_name: OS
mem_used: 0
except_mask: 0
dbg_state: 0
cur_dir:
+12
View File
@@ -0,0 +1,12 @@
umka_boot
ramdisk_init ../../img/kolibri.raw
set_skin /sys/DEFAULT.SKN
dump_services
dump_shmem
dump_dlls
load_dll /sys/lib/console.obj
dump_dlls
dump_appdata 2
load_dll /sys/lib/network.obj
dump_dlls
dump_appdata 2
+1
View File
@@ -59,6 +59,7 @@ font smoothing: 0 - off
1: 1
/> dump_appdata 2
app_name: OS
mem_used: 0
except_mask: 0
dbg_state: 0
cur_dir:
+1
View File
@@ -59,6 +59,7 @@ font smoothing: 0 - off
1: 1
/> dump_appdata 2
app_name: OS
mem_used: 0
except_mask: 0
dbg_state: 0
cur_dir:
+37 -1
View File
@@ -114,6 +114,12 @@ pubsym sys_getkey, 'kos_get_key'
pubsym syslang, 'kos_syslang'
pubsym keyboard, 'kos_keyboard'
; There is no actual srv_list, only its .fd and .bk fields
srv_list = srv.fd - SRV.fd
pubsym srv_list
pubsym dll_list
pubsym shmem_list
pubsym disk_add, 16
pubsym disk_del, 4
pubsym disk_list
@@ -241,7 +247,7 @@ macro int n {
}
section '.app' executable writable align 64
rb 64*1024
rb 1024*1024
section '.text' executable align 64
@@ -291,6 +297,8 @@ ends
NUM_EXCEPTIONS = 32
CDBlockSize = 2048
macro tss pew {}
include 'const.inc'
purge tss
@@ -324,6 +332,9 @@ common
end if
}
MIN_DEFAULT_DLL_ADDR = umka_dlls_from
MAX_DEFAULT_DLL_ADDR = umka_dlls_to
include 'system.inc'
include 'fdo.inc'
@@ -674,6 +685,7 @@ proc umka_init c uses ebx esi edi ebp, _running
mov [eax+umka_ctx.booted], 0
mov ecx, [_running]
mov [eax+umka_ctx.running], ecx
mov [dll_cur_addr], umka_dlls_from
ret
endp
@@ -1144,12 +1156,19 @@ pubsym coverage_table
; bt for boot; otherwide fasm complains with 'name too long' for MS COFF
section '.data.bt' writeable align 0x1000
;virtual at MIN_DEFAULT_DLL_ADDR
umka_dlls_from:
umka_dlls rb 256*1024*1024
umka_dlls_to:
;end virtual
BOOT boot_data
virtual at BOOT
BOOT_LO boot_data
end virtual
; fasm doesn't align on 65536, but ld script does
; 64 for align on 64k; otherwide fasm complains with 'name too long' for MS COFF
section '.data.64' writeable align 0x1000
@@ -1195,8 +1214,10 @@ align 4
bios32_entry dd ?
tmp_page_tabs dd ?
align 0x1000
page_tabs:
rb 256*1024*1024
v86_irqhooks rd IRQ_RESERVED*2
cache_ide0 IDE_CACHE
cache_ide1 IDE_CACHE
@@ -1274,4 +1295,19 @@ forward
db x
end if
}
;macro cmp target, source {
; if src eq MAX_DEFAULT_DLL_ADDR-MIN_DEFAULT_DLL_ADDR2
; cmp ebx, 0x10000000
; else
; cmp target, source
; end if
;}
MIN_DEFAULT_DLL_ADDR equ pew_MIN_DEFAULT_DLL_ADDR
MAX_DEFAULT_DLL_ADDR equ pew_MAX_DEFAULT_DLL_ADDR
include 'data32.inc'
restore MIN_DEFAULT_DLL_ADDR
restore MAX_DEFAULT_DLL_ADDR
;purge cmp
MIN_DEFAULT_DLL_ADDR = umka_dlls_from
MAX_DEFAULT_DLL_ADDR = umka_dlls_to
+242 -164
View File
@@ -141,19 +141,19 @@ struct mouse_state_events {
struct mouse_events ev;
};
typedef struct {
struct rect {
uint32_t left, top, right, bottom;
} rect_t;
};
typedef struct {
struct box {
uint32_t left, top, width, height;
} box_t;
};
typedef struct {
struct dbg_regs {
uint32_t dr0, dr1, dr2, dr3, dr7;
} dbg_regs_t;
};
typedef struct {
struct __attribute__((packed)) process_information {
uint32_t cpu_usage;
uint16_t window_stack_position;
uint16_t window_stack_value;
@@ -162,19 +162,19 @@ typedef struct {
uint32_t memory_start;
uint32_t used_memory;
uint32_t pid;
box_t box;
struct box box;
uint16_t slot_state;
uint16_t pad2;
box_t client_box;
struct box client_box;
uint8_t wnd_state;
uint8_t pad3[1024-71];
} __attribute__((packed)) process_information_t;
};
static_assert(sizeof(process_information_t) == 0x400,
static_assert(sizeof(struct process_information) == 0x400,
"must be 0x400 bytes long");
typedef struct wdata {
box_t box;
struct __attribute__((packed)) wdata {
struct box box;
uint32_t cl_workarea;
uint32_t cl_titlebar;
uint32_t cl_frames;
@@ -182,25 +182,25 @@ typedef struct wdata {
uint8_t fl_wstate;
uint8_t fl_wdrawn;
uint8_t fl_redraw;
box_t clientbox;
struct box clientbox;
uint8_t *shape;
uint32_t shape_scale;
char *caption;
uint8_t caption_encoding;
uint8_t pad0[3];
box_t saved_box;
struct box saved_box;
void *cursor;
void *temp_cursor;
uint32_t draw_bgr_x;
uint32_t draw_bgr_y;
rect_t draw_data;
struct rect draw_data;
struct appdata *thread;
uint8_t pad1[12];
} __attribute__((packed)) wdata_t;
};
static_assert(sizeof(struct wdata) == 0x80, "must be 0x80 bytes long");
typedef struct {
struct system_colors {
uint32_t frame;
uint32_t grab;
uint32_t work_3d_dark;
@@ -211,20 +211,20 @@ typedef struct {
uint32_t work_button_text;
uint32_t work_text;
uint32_t work_graph;
} system_colors_t;
};
typedef enum {
enum fs_enc {
DEFAULT_ENCODING,
CP866,
UTF16,
UTF8,
INVALID_ENCODING,
} fs_enc_t;
};
typedef enum {
enum f70or80 {
F70 = 70,
F80 = 80,
} f70or80_t;
};
enum {
KOS_ERROR_SUCCESS,
@@ -242,55 +242,54 @@ enum {
KOS_ERROR_OUT_OF_MEMORY,
};
typedef struct lhead lhead_t;
struct lhead {
void *next;
void *prev;
};
typedef struct {
lhead_t wait_list;
struct mutex {
struct lhead wait_list;
uint32_t count;
} mutex_t;
};
struct rwsem {
struct lhead wait_list;
uint32_t count;
};
struct board_get_ret {
uint32_t value;
uint32_t status;
};
typedef mutex_t rwsem_t;
typedef struct {
struct diskmediainfo {
uint32_t flags;
uint32_t sector_size;
uint64_t capacity; // in sectors
uint32_t last_session_sector;
} diskmediainfo_t;
};
typedef struct {
struct disk_cache {
uintptr_t pointer;
uint32_t data_size;
uintptr_t data;
uint32_t sad_size;
uint32_t search_start;
uint32_t sector_size_log;
} disk_cache_t;
};
typedef struct {
struct partition {
uint64_t first_sector;
uint64_t length; // in sectors
void *disk;
void *fs_user_functions;
} partition_t;
};
typedef struct disk_t disk_t;
typedef struct {
struct diskfunc {
uint32_t strucsize;
STDCALL void (*close)(void *userdata);
STDCALL void (*closemedia)(void *userdata);
STDCALL int (*querymedia)(void *userdata, diskmediainfo_t *info);
STDCALL int (*querymedia)(void *userdata, struct diskmediainfo *info);
STDCALL int (*read)(void *userdata, void *buffer, off_t startsector,
size_t *numsectors);
STDCALL int (*write)(void *userdata, void *buffer, off_t startsector,
@@ -299,31 +298,33 @@ typedef struct {
STDCALL unsigned int (*adjust_cache_size)(void *userdata,
size_t suggested_size);
STDCALL int (*loadtray)(void *userdata, int flags);
} diskfunc_t;
};
struct disk_t {
disk_t *next;
disk_t *prev;
diskfunc_t *functions;
struct disk;
struct disk {
struct disk *next;
struct disk *prev;
struct diskfunc *functions;
const char *name;
void *userdata;
uint32_t driver_flags;
uint32_t ref_count;
mutex_t media_lock;
struct mutex media_lock;
uint8_t media_inserted;
uint8_t media_used;
uint16_t padding;
uint32_t media_ref_count;
diskmediainfo_t media_info;
struct diskmediainfo media_info;
uint32_t num_partitions;
partition_t **partitions;
struct partition **partitions;
uint32_t cache_size;
mutex_t cache_lock;
disk_cache_t sys_cache;
disk_cache_t app_cache;
struct mutex cache_lock;
struct disk_cache sys_cache;
struct disk_cache app_cache;
};
typedef struct {
struct bdfe {
uint32_t attr;
uint32_t enc;
uint32_t ctime;
@@ -334,14 +335,14 @@ typedef struct {
uint32_t mdate;
uint64_t size;
char name[0x777]; // how to handle this properly? FIXME
} bdfe_t;
};
typedef struct {
struct f7080ret {
int32_t status;
uint32_t count;
} f7080ret_t;
};
typedef struct {
struct __attribute__((packed)) f7080s0arg {
uint32_t sf;
uint64_t offset;
uint32_t count;
@@ -356,9 +357,9 @@ typedef struct {
const char *path;
} f80;
} u;
} __attribute__((packed)) f7080s0arg_t;
};
typedef struct {
struct __attribute__((packed)) f7080s1arg {
uint32_t sf;
uint32_t offset;
uint32_t encoding;
@@ -374,17 +375,17 @@ typedef struct {
const char *path;
} f80;
} u;
} __attribute__((packed)) f7080s1arg_t;
};
typedef struct {
struct f7080s1info {
uint32_t version;
uint32_t cnt;
uint32_t total_cnt;
uint32_t zeroed[5];
bdfe_t bdfes[];
} f7080s1info_t;
struct bdfe bdfes[];
};
typedef struct {
struct __attribute__((packed)) f7080s5arg {
uint32_t sf;
uint32_t reserved1;
uint32_t flags;
@@ -400,9 +401,9 @@ typedef struct {
const char *path;
} f80;
} u;
} __attribute__((packed)) f7080s5arg_t;
};
typedef struct {
struct __attribute__((packed)) f7080s7arg {
uint32_t sf;
uint32_t flags;
char *params;
@@ -418,7 +419,14 @@ typedef struct {
const char *path;
} f80;
} u;
} __attribute__((packed)) f7080s7arg_t;
};
union f7080arg {
struct f7080s0arg s0;
struct f7080s1arg s1;
struct f7080s5arg s5;
struct f7080s7arg s7;
};
#define KF_READONLY 0x01
#define KF_HIDDEN 0x02
@@ -585,14 +593,14 @@ i40(void);
time_t
kos_time_to_epoch(uint32_t *time);
STDCALL disk_t *
disk_add(diskfunc_t *disk, const char *name, void *userdata, uint32_t flags);
STDCALL struct disk *
disk_add(struct diskfunc *disk, const char *name, void *userdata, uint32_t flags);
STDCALL void *
disk_media_changed(disk_t *disk, int inserted);
disk_media_changed(struct disk *disk, int inserted);
STDCALL void
disk_del(disk_t *disk);
disk_del(struct disk *disk);
void
hash_oneshot(void *ctx, void *data, size_t len);
@@ -609,7 +617,7 @@ extern uint8_t iso9660_user_functions[];
extern char kos_ramdisk[RAMDISK_MAX_LEN];
disk_t *
struct disk *
kos_ramdisk_init(void);
STDCALL void
@@ -719,15 +727,15 @@ kos_pci_walk_tree(struct pci_dev *node,
STDCALL void* (*clbk)(struct pci_dev *node, void *arg),
void *arg);
typedef struct {
struct f75ret {
uint32_t value;
uint32_t errorcode;
} f75ret_t;
};
typedef struct {
struct f76ret {
uint32_t eax;
uint32_t ebx;
} f76ret_t;
};
static inline void
umka_stack_init(void) {
@@ -756,7 +764,7 @@ STDCALL void
kos_window_set_screen(ssize_t left, ssize_t top, ssize_t right, ssize_t bottom,
ssize_t proc);
typedef struct {
struct __attribute__((packed)) display {
int32_t x;
int32_t y;
size_t width;
@@ -766,7 +774,7 @@ typedef struct {
void *current_lfb;
size_t lfb_pitch;
rwsem_t win_map_lock;
struct rwsem win_map_lock;
uint8_t *win_map;
size_t win_map_pitch;
size_t win_map_size;
@@ -801,19 +809,19 @@ typedef struct {
void *get_rect;
void *get_image;
void *get_line;
} __attribute__((packed)) display_t;
};
extern display_t kos_display;
extern struct display kos_display;
typedef struct {
struct e820entry {
uint64_t addr;
uint64_t size;
uint32_t type;
} e820entry_t;
};
#define MAX_MEMMAP_BLOCKS 32
typedef struct {
struct __attribute__((packed)) boot_data {
uint8_t bpp; // bits per pixel
uint16_t pitch; // scanline length
uint8_t pad1[5];
@@ -850,14 +858,14 @@ typedef struct {
uint8_t bios_hd_cnt; // number of BIOS hard disks
uint8_t bios_hd[0x80]; // BIOS hard disks
size_t memmap_block_cnt; // available physical memory map: number of blocks
e820entry_t memmap_blocks[MAX_MEMMAP_BLOCKS];
struct e820entry memmap_blocks[MAX_MEMMAP_BLOCKS];
uint8_t acpi_usage;
} __attribute__((packed)) boot_data_t;
};
extern uint8_t kos_msg_board_data[];
extern uint32_t kos_msg_board_count;
extern boot_data_t kos_boot;
extern struct boot_data kos_boot;
void
umka_cli(void);
@@ -879,36 +887,103 @@ extern struct coverage_branch coverage_table[];
extern uint8_t coverage_begin[];
extern uint8_t coverage_end[];
typedef struct appobj_t appobj_t;
struct appobj;
struct appobj_t {
struct appobj {
uint32_t magic;
void *destroy; // internal destructor
appobj_t *fd; // next object in list
appobj_t *bk; // prev object in list
struct appobj *fd; // next object in list
struct appobj *bk; // prev object in list
uint32_t pid; // owner id
};
typedef struct {
struct event {
uint32_t magic;
void *destroy; // internal destructor
appobj_t *fd; // next object in list
appobj_t *bk; // prev object in list
struct appobj *fd; // next object in list
struct appobj *bk; // prev object in list
uint32_t pid; // owner id
uint32_t id; // event uid
uint32_t state; // internal flags
uint32_t code;
uint32_t pad[5];
} event_t;
};
typedef struct {
lhead_t list;
lhead_t thr_list;
mutex_t heap_lock;
struct smem;
struct smem {
struct smem *bk; // +0
struct smem *fd; // +4
void *base; // +8
size_t size; // +12
uint32_t access; // +16
size_t refcount; // +20
char name[32]; // +24
};
struct srv {
char srv_name[16]; // +0 ASCIIZ string
uint32_t magic; // +16 'SRV '
size_t size; // +20 size of structure SRV
struct srv *fd; // +24 next SRV descriptor
struct srv *bk; // +28 prev SRV descriptor
void *base; // +32 service base address
void *entry; // +36 service START function
void *srv_proc; // +40 user mode service handler
void *srv_proc_ex; // +44 kernel mode service handler
};
struct pcidev;
struct pcidev {
struct pcidev *bk; // +0
struct pcidev *fd; // +4
uint32_t vendor_device_id; // +8
uint32_t class; // +12
uint8_t devfn; // +16
uint8_t bus; // +17
uint8_t pad[2]; // +18
struct srv *owner; // +20 pointer to SRV or 0
};
struct dlldescr;
struct dlldescr {
struct dlldescr *bk; // +0
struct dlldescr *fd; // +4
void *data; // +8
size_t size; // +12
uint64_t timestamp; // +16
uint32_t refcount; // +24
void *defaultbase; // +28
void *coff_hdr; // +32
void *symbols_ptr; // +36
uint32_t symbols_num; // +40
void *symbols_lim; // +44
void *exports; // +48 export table
char name[260];
};
struct hdll;
struct hdll {
struct hdll *fd; // +0
struct hdll *bk; // +4
uint32_t pid; // +8 owner id
void *base; // +12 mapped base
size_t size; // +16 mapped size
uint32_t refcount; // +20 reference counter for this process and this lib
struct dlldescr *parent; // +24 dlldescr
};
struct proc {
struct lhead list;
struct lhead thr_list;
struct mutex heap_lock;
void *heap_base;
void *heap_top;
uint32_t mem_used;
void *dlls_list_ptr;
struct hdll *dlls_list_ptr;
void *pdt_0_phys;
void *pdt_1_phys;
void *io_map_0;
@@ -919,25 +994,25 @@ typedef struct {
void *ht_next;
void *htab[(1024-18*4)/4];
void *pdt_0[1024];
} proc_t;
};
static_assert(sizeof(proc_t) == 0x1400, "must be 0x1400 bytes long");
static_assert(sizeof(struct proc) == 0x1400, "must be 0x1400 bytes long");
typedef struct appdata {
struct appdata {
char app_name[11];
uint8_t pad1[5];
lhead_t list; // +16
proc_t *process; // +24
struct lhead list; // +16
struct proc *process; // +24
void *fpu_state; // +28
void *exc_handler; // +32
uint32_t except_mask; // +36
void *pl0_stack; // +40
uint32_t pad2; // +44
event_t *fd_ev; // +48
event_t *bk_ev; // +52
appobj_t *fd_obj; // +56
appobj_t *bk_obj; // +60
struct event *fd_ev; // +48
struct event *bk_ev; // +52
struct appobj *fd_obj; // +56
struct appobj *bk_obj; // +60
void *saved_esp; // +64
uint32_t io_map[2]; // +68
uint32_t dbg_state; // +76
@@ -969,26 +1044,26 @@ typedef struct appdata {
uint8_t pad9[3]; // +181
char *exec_params; // +184
void *dbg_event_mem; // +188
dbg_regs_t dbg_regs; // +192
struct dbg_regs dbg_regs; // +192
uint32_t pad10; // +212
uint32_t pad11[4]; // +216
uint32_t priority; // +232
lhead_t in_schedule; // +236
struct lhead in_schedule; // +236
uint32_t counter_add; // +244
uint32_t cpu_usage; // +248
uint32_t pad12; // +252
} appdata_t;
};
static_assert(sizeof(struct appdata) == 256, "must be 0x100 bytes long");
extern uint8_t kos_redraw_background;
extern size_t kos_task_count;
extern wdata_t kos_window_data[];
extern appdata_t kos_slot_base[];
extern struct wdata kos_window_data[];
extern struct appdata kos_slot_base[];
extern uint32_t kos_current_process;
extern appdata_t *kos_current_slot;
extern struct appdata *kos_current_slot;
extern uint32_t kos_current_slot_idx;
extern void umka_do_change_task(appdata_t *new);
extern void umka_do_change_task(struct appdata *new);
extern void scheduler_add_thread(void);
extern void find_next_task(void);
extern uint8_t kos_lfb_base[];
@@ -1002,7 +1077,10 @@ extern uint32_t kos_acpi_usage;
extern uint32_t kos_acpi_node_alloc_cnt;
extern uint32_t kos_acpi_node_free_cnt;
extern uint32_t kos_acpi_count_nodes(void *ctx) STDCALL;
extern disk_t disk_list;
extern struct srv srv_list;
extern struct dlldescr dll_list;
extern struct smem shmem_list;
extern struct disk disk_list;
extern uint8_t kos_key_count;
extern uint8_t kos_key_buff[120*2 + 2*2];
extern uint8_t kos_keyboard_mode;
@@ -1010,7 +1088,7 @@ extern uint32_t kos_syslang;
extern uint32_t kos_keyboard;
static inline void
umka_scheduler_add_thread(appdata_t *thread, int32_t priority) {
umka_scheduler_add_thread(struct appdata *thread, int32_t priority) {
__asm__ __inline__ __volatile__ (
"call do_change_thread"
:
@@ -1027,7 +1105,7 @@ umka_scheduler_add_thread(appdata_t *thread, int32_t priority) {
#define SCHEDULE_ANY_PRIORITY 0
#define SCHEDULE_HIGHER_PRIORITY 1
extern appdata_t *kos_scheduler_current[KOS_NR_SCHED_QUEUES];
extern struct appdata *kos_scheduler_current[KOS_NR_SCHED_QUEUES];
void
i40_asm(uint32_t eax,
@@ -1176,7 +1254,7 @@ umka_new_sys_threads(uint32_t flags, void (*entry)(void *), void *stack_top,
void *arg, const char *app_name) {
kos_thread_t entry_noparam = (kos_thread_t)entry;
size_t tid = kos_new_sys_threads(flags, entry_noparam, stack_top);
appdata_t *t = kos_slot_base + tid;
struct appdata *t = kos_slot_base + tid;
strncpy(t->app_name, app_name, 11);
*(void**)((char*)t->saved_esp0-12) = arg; // param for the thread
// -12 here because in UMKa, unlike real hardware, we don't switch between
@@ -1743,7 +1821,7 @@ umka_sys_get_skin_height(void) {
}
static inline void
umka_sys_get_screen_area(rect_t *wa) {
umka_sys_get_screen_area(struct rect *wa) {
uint32_t eax, ebx;
__asm__ __inline__ __volatile__ (
"call i40"
@@ -1759,7 +1837,7 @@ umka_sys_get_screen_area(rect_t *wa) {
}
static inline void
umka_sys_set_screen_area(rect_t *wa) {
umka_sys_set_screen_area(struct rect *wa) {
uint32_t ecx, edx;
ecx = (wa->left << 16) + wa->right;
edx = (wa->top << 16) + wa->bottom;
@@ -1774,7 +1852,7 @@ umka_sys_set_screen_area(rect_t *wa) {
}
static inline void
umka_sys_get_skin_margins(rect_t *wa) {
umka_sys_get_skin_margins(struct rect *wa) {
uint32_t eax, ebx;
__asm__ __inline__ __volatile__ (
"call i40"
@@ -1972,7 +2050,7 @@ kos_sys_misc_load_file(const char *fname) {
}
static inline void
umka_sys_lfn(void *f7080sXarg, f7080ret_t *r, f70or80_t f70or80) {
umka_sys_lfn(void *f7080sXarg, struct f7080ret *r, enum f70or80 f70or80) {
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r->status),
@@ -2140,9 +2218,9 @@ umka_sys_net_get_link_status(uint8_t dev_num) {
return status;
}
static inline f75ret_t
static inline struct f75ret
umka_sys_net_open_socket(uint32_t domain, uint32_t type, uint32_t protocol) {
f75ret_t r;
struct f75ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.value),
@@ -2156,9 +2234,9 @@ umka_sys_net_open_socket(uint32_t domain, uint32_t type, uint32_t protocol) {
return r;
}
static inline f75ret_t
static inline struct f75ret
umka_sys_net_close_socket(uint32_t fd) {
f75ret_t r;
struct f75ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.value),
@@ -2170,9 +2248,9 @@ umka_sys_net_close_socket(uint32_t fd) {
return r;
}
static inline f75ret_t
static inline struct f75ret
umka_sys_net_bind(uint32_t fd, void *sockaddr, size_t sockaddr_len) {
f75ret_t r;
struct f75ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.value),
@@ -2186,9 +2264,9 @@ umka_sys_net_bind(uint32_t fd, void *sockaddr, size_t sockaddr_len) {
return r;
}
static inline f75ret_t
static inline struct f75ret
umka_sys_net_listen(uint32_t fd, uint32_t backlog) {
f75ret_t r;
struct f75ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.value),
@@ -2201,9 +2279,9 @@ umka_sys_net_listen(uint32_t fd, uint32_t backlog) {
return r;
}
static inline f75ret_t
static inline struct f75ret
umka_sys_net_connect(uint32_t fd, void *sockaddr, size_t sockaddr_len) {
f75ret_t r;
struct f75ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.value),
@@ -2217,9 +2295,9 @@ umka_sys_net_connect(uint32_t fd, void *sockaddr, size_t sockaddr_len) {
return r;
}
static inline f75ret_t
static inline struct f75ret
umka_sys_net_accept(uint32_t fd, void *sockaddr, size_t sockaddr_len) {
f75ret_t r;
struct f75ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.value),
@@ -2233,9 +2311,9 @@ umka_sys_net_accept(uint32_t fd, void *sockaddr, size_t sockaddr_len) {
return r;
}
static inline f75ret_t
static inline struct f75ret
umka_sys_net_send(uint32_t fd, void *buf, size_t buf_len, uint32_t flags) {
f75ret_t r;
struct f75ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.value),
@@ -2250,9 +2328,9 @@ umka_sys_net_send(uint32_t fd, void *buf, size_t buf_len, uint32_t flags) {
return r;
}
static inline f75ret_t
static inline struct f75ret
umka_sys_net_receive(uint32_t fd, void *buf, size_t buf_len, uint32_t flags) {
f75ret_t r;
struct f75ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.value),
@@ -2267,9 +2345,9 @@ umka_sys_net_receive(uint32_t fd, void *buf, size_t buf_len, uint32_t flags) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_eth_read_mac(uint32_t dev_num) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2283,9 +2361,9 @@ umka_sys_net_eth_read_mac(uint32_t dev_num) {
// Function 76, Protocol 1 - IPv4, Subfunction 0, Read # Packets sent =
// Function 76, Protocol 1 - IPv4, Subfunction 1, Read # Packets rcvd =
static inline f76ret_t
static inline struct f76ret
umka_sys_net_ipv4_get_addr(uint32_t dev_num) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2296,9 +2374,9 @@ umka_sys_net_ipv4_get_addr(uint32_t dev_num) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_ipv4_set_addr(uint32_t dev_num, uint32_t addr) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2310,9 +2388,9 @@ umka_sys_net_ipv4_set_addr(uint32_t dev_num, uint32_t addr) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_ipv4_get_dns(uint32_t dev_num) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2323,9 +2401,9 @@ umka_sys_net_ipv4_get_dns(uint32_t dev_num) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_ipv4_set_dns(uint32_t dev_num, uint32_t dns) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2337,9 +2415,9 @@ umka_sys_net_ipv4_set_dns(uint32_t dev_num, uint32_t dns) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_ipv4_get_subnet(uint32_t dev_num) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2350,9 +2428,9 @@ umka_sys_net_ipv4_get_subnet(uint32_t dev_num) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_ipv4_set_subnet(uint32_t dev_num, uint32_t subnet) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2364,9 +2442,9 @@ umka_sys_net_ipv4_set_subnet(uint32_t dev_num, uint32_t subnet) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_ipv4_get_gw(uint32_t dev_num) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2377,9 +2455,9 @@ umka_sys_net_ipv4_get_gw(uint32_t dev_num) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_ipv4_set_gw(uint32_t dev_num, uint32_t gw) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2399,9 +2477,9 @@ umka_sys_net_ipv4_set_gw(uint32_t dev_num, uint32_t gw) {
// Function 76, Protocol 4 - TCP, Subfunction 1, Read # Packets rcvd ==
// Function 76, Protocol 5 - ARP, Subfunction 0, Read # Packets sent ==
// Function 76, Protocol 5 - ARP, Subfunction 1, Read # Packets rcvd ==
static inline f76ret_t
static inline struct f76ret
umka_sys_net_arp_get_count(uint32_t dev_num) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2412,9 +2490,9 @@ umka_sys_net_arp_get_count(uint32_t dev_num) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_arp_get_entry(uint32_t dev_num, uint32_t arp_num, void *buf) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2427,9 +2505,9 @@ umka_sys_net_arp_get_entry(uint32_t dev_num, uint32_t arp_num, void *buf) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_arp_add_entry(uint32_t dev_num, void *buf) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
@@ -2441,9 +2519,9 @@ umka_sys_net_arp_add_entry(uint32_t dev_num, void *buf) {
return r;
}
static inline f76ret_t
static inline struct f76ret
umka_sys_net_arp_del_entry(uint32_t dev_num, int32_t arp_num) {
f76ret_t r;
struct f76ret r;
__asm__ __inline__ __volatile__ (
"call i40"
: "=a"(r.eax),
+12
View File
@@ -35,6 +35,18 @@ SECTIONS
}
INSERT AFTER .data;
/*
SECTIONS
{
.dlls BLOCK(0x1000) : AT(0x70000000)
{
*(.dlls)
}
}
INSERT AFTER .data;
*/
SECTIONS
{
.bss.aligned BLOCK(0x100000) :
+31 -31
View File
@@ -48,7 +48,7 @@ umka_fuse_close(struct umka_fuse_ctx *ctx) {
}
static void
bdfe_to_stat(bdfe_t *kf, struct stat *st) {
bdfe_to_stat(struct bdfe *kf, struct stat *st) {
// if (kf->attr & KF_FOLDER) {
if (st) {
st->st_mode = S_IFDIR | 0755;
@@ -80,17 +80,17 @@ fs_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi) {
(void) fi;
int res = 0;
bdfe_t file;
f7080s5arg_t fX0 = {.sf = 5,
.flags = 0,
.buf = &file,
.u = {.f80 = {.path_encoding = UTF8,
.path = path
}
}
};
f7080ret_t r;
umka_sys_lfn(&fX0, &r, F80);
struct bdfe file;
struct f7080s5arg fX0 = {.sf = 5,
.flags = 0,
.buf = &file,
.u = {.f80 = {.path_encoding = UTF8,
.path = path
}
}
};
struct f7080ret r;
umka_sys_lfn(&fX0, &r, F80); // monitor?
bdfe_to_stat(&file, stbuf);
// res = -ENOENT;
@@ -104,24 +104,24 @@ fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset,
(void) fi;
(void) flags;
f7080s1info_t *dir = (f7080s1info_t*)malloc(sizeof(f7080s1info_t) +
struct f7080s1info *dir = (struct f7080s1info*)malloc(sizeof(struct f7080s1info) +
BDFE_LEN_UNICODE * DIRENTS_TO_READ);
f7080s1arg_t fX0 = {.sf = 1,
.offset = 0,
.encoding = UTF8,
.size = DIRENTS_TO_READ,
.buf = dir,
.u = {.f80 = {.path_encoding = UTF8,
.path = path
}
}
};
f7080ret_t r;
struct f7080s1arg fX0 = {.sf = 1,
.offset = 0,
.encoding = UTF8,
.size = DIRENTS_TO_READ,
.buf = dir,
.u = {.f80 = {.path_encoding = UTF8,
.path = path
}
}
};
struct f7080ret r;
umka_sys_lfn(&fX0, &r, F80);
bdfe_t *bdfe = dir->bdfes;
struct bdfe *bdfe = dir->bdfes;
for (size_t i = 0; i < dir->cnt; i++) {
filler(buf, bdfe->name, NULL, 0, 0);
bdfe = (bdfe_t*)((uintptr_t)bdfe + BDFE_LEN_UNICODE);
bdfe = (struct bdfe*)((uintptr_t)bdfe + BDFE_LEN_UNICODE);
}
free(dir);
return 0;
@@ -144,10 +144,10 @@ fs_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi) {
(void) fi;
f7080s0arg_t fX0 = {.sf = 0, .offset = offset, .count = size, .buf = buf,
.u = {.f80 = {.path_encoding = UTF8, .path = path}}};
f7080ret_t r;
umka_sys_lfn(&fX0, &r, F80);
struct f7080s0arg fX0 = {.sf = 0, .offset = offset, .count = size, .buf = buf,
.u = {.f80 = {.path_encoding = UTF8, .path = path}}};
struct f7080ret r;
umka_sys_lfn(&fX0, &r, F80); // monitor?
return size;
}
@@ -171,7 +171,7 @@ main(int argc, char *argv[]) {
umka_boot();
struct vdisk *umka_disk = vdisk_init(argv[2], 1, 0u, ctx->io);
disk_t *disk = disk_add(&umka_disk->diskfunc, "hd0", umka_disk, 0);
struct disk *disk = disk_add(&umka_disk->diskfunc, "hd0", umka_disk, 0);
disk_media_changed(disk, 1);
return fuse_main(argc-1, argv, &umka_oper, ctx);
}
+106 -59
View File
@@ -26,6 +26,7 @@
#include "shell.h"
#include "trace.h"
#include "vnet.h"
#include "vkbd.h"
#include "isocline/include/isocline.h"
#include "optparse/optparse.h"
@@ -37,11 +38,13 @@
struct umka_os_ctx {
struct umka_ctx *umka;
struct umka_io *io;
struct monitor_ctx *monitor;
struct shell_ctx *shell;
FILE *fboardlog;
};
struct umka_os_ctx *os;
struct vkbd *vkbd;
char history_filename[PATH_MAX];
@@ -58,8 +61,9 @@ umka_os_init(FILE *fstartup, FILE *fboardlog) {
ctx->fboardlog = fboardlog;
ctx->umka = umka_init(UMKA_RUNNING_NOT_YET);
ctx->io = io_init(&ctx->umka->running);
ctx->monitor = monitor_init(&ctx->umka->running);
ctx->shell = shell_init(SHELL_LOG_NONREPRODUCIBLE, history_filename,
ctx->umka, ctx->io, fstartup);
ctx->umka, ctx->io, ctx->monitor, fstartup);
return ctx;
}
@@ -86,8 +90,8 @@ static void
dump_procs(void) {
for (int i = 0; i < KOS_NR_SCHED_QUEUES; i++) {
fprintf(stderr, "[os] sched queue #%i:", i);
appdata_t *p_begin = kos_scheduler_current[i];
appdata_t *p = p_begin;
struct appdata *p_begin = kos_scheduler_current[i];
struct appdata *p = p_begin;
do {
fprintf(stderr, " %p", (void*)p);
p = p->in_schedule.next;
@@ -95,7 +99,7 @@ dump_procs(void) {
putchar('\n');
}
for (size_t i = 0; i < 256; i++) {
appdata_t *app = kos_slot_base + i;
struct appdata *app = kos_slot_base + i;
if (app->state != KOS_TSTATE_FREE && app->app_name[0]) {
printf("slot %2.2d: %s\n", i, app->app_name);
}
@@ -163,6 +167,61 @@ update_display(SDL_Surface *window_surface, SDL_Window *window) {
return;
}
static void
convert_scancode_hid_to_ps2(int hid, int is_release, uint8_t *ps2) {
switch (hid) {
case SDL_SCANCODE_RIGHT:
*ps2 = 0xe0;
*++ps2 = 0x4d;
break;
case SDL_SCANCODE_LEFT:
*ps2 = 0xe0;
*++ps2 = 0x4b;
break;
case SDL_SCANCODE_DOWN:
*ps2 = 0xe0;
*++ps2 = 0x50;
break;
case SDL_SCANCODE_UP:
*ps2 = 0xe0;
*++ps2 = 0x48;
break;
case SDL_SCANCODE_TAB:
*ps2 = 0x0f;
break;
case SDL_SCANCODE_SPACE:
*ps2 = 0x39;
break;
default:
fprintf(stderr, "[sdl] ignore hid scancode: %i 0x%x\n", hid, hid);
break;
}
if (is_release) {
*ps2 |= 0x80;
}
}
static uint32_t
mouse_btn_state_sdl_to_umka(uint32_t sdl_btn_state) {
uint32_t btn_state = 0;
if ((sdl_btn_state & SDL_BUTTON_LMASK)) {
btn_state |= 0x01;
}
if ((sdl_btn_state & SDL_BUTTON_RMASK)) {
btn_state |= 0x02;
}
if ((sdl_btn_state & SDL_BUTTON_MMASK)) {
btn_state |= 0x04;
}
return btn_state;
}
static void
grab_sdl_window(SDL_Window *window, bool grab) {
SDL_SetWindowMouseGrab(window, grab);
SDL_SetWindowKeyboardGrab(window, grab);
SDL_SetRelativeMouseMode(grab);
}
static void *
umka_display(void *arg) {
(void)arg;
@@ -218,64 +277,42 @@ umka_display(void *arg) {
case SDL_WINDOWEVENT:
break;
case SDL_MOUSEBUTTONDOWN:
if (!input_grabbed) {
int x, y;
SDL_GetMouseState(&x, &y);
monitor_cmd_sys_set_mouse_pos_screen(os->monitor, x, y);
input_grabbed = true;
grab_sdl_window(window, true);
}
[[fallthrough]];
case SDL_MOUSEBUTTONUP: {
if (!input_grabbed) {
break;
}
struct umka_cmd *cmd = shell_get_cmd(os->shell);
cmd->type = UMKA_CMD_SET_MOUSE_DATA;
struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg;
c->btn_state = event.button.state;
c->xmoving = 0;
c->ymoving = 0;
c->vscroll = 0;
c->hscroll = 0;
shell_run_cmd(os->shell);
shell_clear_cmd(cmd);
uint32_t btn_state =
mouse_btn_state_sdl_to_umka(SDL_GetMouseState(NULL, NULL));
monitor_cmd_mouse_move(os->monitor, btn_state, 0, 0, 0, 0);
break;
}
case SDL_MOUSEMOTION: {
if (!input_grabbed) {
break;
}
struct umka_cmd *cmd = shell_get_cmd(os->shell);
cmd->type = UMKA_CMD_SET_MOUSE_DATA;
struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg;
c->btn_state = 0;
c->xmoving = event.motion.xrel;
c->ymoving = -event.motion.yrel;
c->vscroll = 0;
c->hscroll = 0;
shell_run_cmd(os->shell);
shell_clear_cmd(cmd);
uint32_t btn_state =
mouse_btn_state_sdl_to_umka(SDL_GetMouseState(NULL, NULL));
monitor_cmd_mouse_move(os->monitor, btn_state,
event.motion.xrel, -event.motion.yrel,
event.wheel.y, event.wheel.x);
break;
}
case SDL_MOUSEWHEEL: {
if (!input_grabbed) {
break;
}
uint32_t btn_state = SDL_GetMouseState(NULL, NULL);
struct umka_cmd *cmd = shell_get_cmd(os->shell);
cmd->type = UMKA_CMD_SET_MOUSE_DATA;
struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg;
c->btn_state = 0;
if ((btn_state & SDL_BUTTON_LMASK)) {
c->btn_state |= 0x01;
}
/*
if ((btn_state & SDL_BUTTON_RMASK)) {
c->btn_state |= 0x02;
}
if ((btn_state & SDL_BUTTON_MMASK)) {
c->btn_state |= 0x04;
}
*/
c->xmoving = 0;
c->ymoving = 0;
c->vscroll = event.wheel.y;
c->hscroll = event.wheel.x;
shell_run_cmd(os->shell);
shell_clear_cmd(cmd);
uint32_t btn_state =
mouse_btn_state_sdl_to_umka(SDL_GetMouseState(NULL, NULL));
monitor_cmd_mouse_move(os->monitor, btn_state, 0, 0,
event.wheel.y, event.wheel.x);
break;
}
case SDL_KEYDOWN: {
@@ -283,19 +320,19 @@ umka_display(void *arg) {
&& (event.key.keysym.mod & KMOD_CTRL)
&& (event.key.keysym.mod & KMOD_ALT)) {
input_grabbed = !input_grabbed;
SDL_SetWindowMouseGrab(window, input_grabbed);
SDL_SetWindowKeyboardGrab(window, input_grabbed);
SDL_SetRelativeMouseMode(input_grabbed);
grab_sdl_window(window, input_grabbed);
}
/*
if (!input_grabbed) {
break;
}
struct umka_cmd *cmd = shell_get_cmd(os->shell);
cmd->type = UMKA_CMD_SEND_SCANCODE;
struct cmd_send_scancode_arg *c = &cmd->send_scancode.arg;
c->scancode = event.key.keysym.scancode;
shell_run_cmd(os->shell);
shell_clear_cmd(cmd);
*/
uint8_t scancodes[16];
memset(scancodes, 0, 16);
convert_scancode_hid_to_ps2(event.key.keysym.scancode, false, scancodes);
monitor_cmd_send_scancodes(os->monitor, scancodes);
convert_scancode_hid_to_ps2(event.key.keysym.scancode, true, scancodes);
monitor_cmd_send_scancodes(os->monitor, scancodes);
break;
}
case SDL_KEYUP:
@@ -309,7 +346,9 @@ umka_display(void *arg) {
}
break;
default:
fprintf(stderr, "[sdl] unknown event type: 0x%x\n", event.type);
if (!(event.type & SDL_WINDOWEVENT)) { // filter out SDL3 window events
fprintf(stderr, "[sdl] unknown event type: 0x%x\n", event.type);
}
update_display(window_surface, window);
}
} else {
@@ -321,7 +360,7 @@ umka_display(void *arg) {
}
static void *
umka_monitor(void *arg) {
umka_shell(void *arg) {
struct shell_ctx *sh = arg;
run_test(sh);
exit(0);
@@ -483,6 +522,8 @@ main(int argc, char *argv[]) {
// load_app("/rd/1/loader");
vkbd = vkbd_init();
struct vnet *vnet = vnet_init(VNET_DEVTYPE_TAP, &os->umka->running);
if (vnet) {
kos_net_add_device(&vnet->eth.net);
@@ -499,7 +540,7 @@ main(int argc, char *argv[]) {
}
// network setup should be done from the userspace app, e.g. via zeroconf
f76ret_t r76;
struct f76ret r76;
r76 = umka_sys_net_ipv4_set_subnet(1, inet_addr("255.255.255.0"));
if (r76.eax == (uint32_t)-1) {
fprintf(stderr, "[!] set subnet error\n");
@@ -530,11 +571,17 @@ main(int argc, char *argv[]) {
load_app_host("../apps/loader", UMKA_LDR_BASE);
// load_app_host("../apps/justawindow", KOS_APP_BASE);
load_app_host("../apps/asciivju", KOS_APP_BASE);
// load_app_host("../apps/eyes", KOS_APP_BASE);
// load_app_host("../apps/board", KOS_APP_BASE);
// load_app_host("../apps/calc", KOS_APP_BASE);
// load_app_host("../apps/unvwater", KOS_APP_BASE);
// load_app_host("../apps/clicks", KOS_APP_BASE);
// load_app_host("../apps/testcon", KOS_APP_BASE);
dump_procs();
pthread_t thread_monitor;
pthread_create(&thread_monitor, NULL, umka_monitor, os->shell);
pthread_create(&thread_monitor, NULL, umka_shell, os->shell);
if (show_display) {
pthread_t thread_display;
+3 -1
View File
@@ -26,6 +26,7 @@
struct umka_shell_ctx {
struct umka_ctx *umka;
struct umka_io *io;
struct monitor_ctx *monitor;
struct shell_ctx *shell;
};
@@ -36,8 +37,9 @@ umka_shell_init(int reproducible, FILE *fin) {
struct umka_shell_ctx *ctx = malloc(sizeof(struct umka_shell_ctx));
ctx->umka = umka_init(UMKA_RUNNING_NEVER);
ctx->io = io_init(&ctx->umka->running);
ctx->monitor = monitor_init(&ctx->umka->running);
ctx->shell = shell_init(reproducible, history_filename, ctx->umka, ctx->io,
fin);
ctx->monitor, fin);
return ctx;
}
+1 -1
View File
@@ -165,7 +165,7 @@ io_init(atomic_int *running) {
struct umka_io *io = malloc(sizeof(struct umka_io));
io->running = running;
if (running) {
pthread_create(&io->iot, NULL, thread_io, NULL);
pthread_create(&io->iot, NULL, thread_io, NULL); // can this be merged to monitor?
}
return io;
}
+1 -1
View File
@@ -20,7 +20,7 @@
#include "vdisk/qcow2.h"
STDCALL int
vdisk_querymedia(void *userdata, diskmediainfo_t *minfo) {
vdisk_querymedia(void *userdata, struct diskmediainfo *minfo) {
COVERAGE_OFF();
struct vdisk *disk = userdata;
minfo->flags = 0u;
+1 -1
View File
@@ -14,7 +14,7 @@
#include "umka.h"
struct vdisk {
diskfunc_t diskfunc;
struct diskfunc diskfunc;
uint32_t sect_size;
uint64_t sect_cnt;
unsigned cache_size;
+1 -1
View File
@@ -206,7 +206,7 @@ vdisk_init_qcow2(const char *fname, const struct umka_io *io) {
return NULL;
}
d->vdisk.diskfunc = (diskfunc_t) {.strucsize = sizeof(diskfunc_t),
d->vdisk.diskfunc = (struct diskfunc) {.strucsize = sizeof(struct diskfunc),
.close = vdisk_qcow2_close,
.read = vdisk_qcow2_read,
.write = vdisk_qcow2_write,
+1 -1
View File
@@ -70,7 +70,7 @@ vdisk_init_raw(const char *fname, const struct umka_io *io) {
}
struct vdisk_raw *disk = (struct vdisk_raw*)malloc(sizeof(struct vdisk_raw));
*disk = (struct vdisk_raw){
.vdisk = {.diskfunc = {.strucsize = sizeof(diskfunc_t),
.vdisk = {.diskfunc = {.strucsize = sizeof(struct diskfunc),
.close = vdisk_raw_close,
.read = vdisk_raw_read,
.write = vdisk_raw_write,
+36
View File
@@ -0,0 +1,36 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
vkbd - virtual keyboard
Copyright (C) 2025 Ivan Baravy <dunkaist@gmail.com>
*/
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <pthread.h>
#include <signal.h>
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "umka.h"
#include "umkart.h"
#include "trace.h"
#include "vkbd.h"
struct vkbd *
vkbd_init(void) {
struct vkbd *vkbd = (struct vkbd*)malloc(sizeof(struct vkbd));
if (!vkbd) {
fprintf(stderr, "[vkbd] device initialization failed\n");
return NULL;
}
vkbd->pew = 0;
return vkbd;
}
+23
View File
@@ -0,0 +1,23 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
vkbd - virtual keyboard
Copyright (C) 2025 Ivan Baravy <dunkaist@gmail.com>
*/
#ifndef VKBD_H_INCLUDED
#define VKBD_H_INCLUDED
#include <stdatomic.h>
#include "umka.h"
struct vkbd {
int pew;
};
struct vkbd *
vkbd_init(void);
#endif // VKBD_H_INCLUDED