9 Commits
main ... acpi

206 changed files with 177326 additions and 54571 deletions

1
.gitignore vendored
View File

@@ -51,4 +51,3 @@ apps/loader
apps/asciivju apps/asciivju
apps/justawindow apps/justawindow
runtests runtests
cov_t*.*

9
README
View File

@@ -103,11 +103,6 @@ Testing
Troubleshooting Troubleshooting
--------------- ---------------
# Build
Install toolchain for the 32-bit target, e.g. gcc-multilib, lib32-glibc,
32-bit and develop packages of libfuse and libsdl2, fasm.
# umka_os # umka_os
To create tap devices. To create tap devices.
@@ -122,10 +117,6 @@ Allow reading process_vm_readv syscall.
# sysctl -w kernel.yama.ptrace_scope=0 # sysctl -w kernel.yama.ptrace_scope=0
Insert msr linux kernel module to collect coverage.
# modprobe msr
Links & Acknowledgements Links & Acknowledgements
------------------------ ------------------------

13
TODO
View File

@@ -1,10 +1,9 @@
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 lsstat to decrease tests size
separate dirs for each image separate dirs for each image and test
include umka_os to tests
tests with writing to block devices (read-only base image + discardable image for writing)
library loader library loader
validate against the reference XFS implementation custom test runner
stressing via ref impl (how?) make mkfs.xfs use config file via -c option
writing tests
compare with reference XFS implementation
stressing via ref impl
multithreaded: kofu one.t two.t multithreaded: kofu one.t two.t

View File

@@ -30,13 +30,7 @@ gpt_large.qcow2 () {
local img=$FUNCNAME local img=$FUNCNAME
qemu-img create -f qcow2 -o $QCOW2_OPTS,cluster_size=2097152 $img 2E > /dev/null qemu-img create -f qcow2 -o $QCOW2_OPTS,cluster_size=2097152 $img 2E > /dev/null
sudo qemu-nbd -c $NBD_DEV $img sudo qemu-nbd -c $NBD_DEV $img
sleep 1
# This is weird but the sleep above prevents the following error of the
# sgdisk below. A better understanding and fix is needed.
# Problem reading disk in BasicMBRData::ReadMBRData()!
# Warning! Read error 22; strange behavior now likely!
# Caution! Secondary header was placed beyond the disk's limits! Moving the
# header, but other problems may occur!
$SGDISK --clear --new=0:0:+1023MiB --new=0:0:+1023GiB --new=0:0:+1023TiB \ $SGDISK --clear --new=0:0:+1023MiB --new=0:0:+1023GiB --new=0:0:+1023TiB \
--new=0:0:+1023PiB $NBD_DEV > /dev/null --new=0:0:+1023PiB $NBD_DEV > /dev/null
@@ -433,7 +427,6 @@ xfs_v4_xattr.qcow2 () {
} }
xfs_v4_btrees_l2.qcow2 () { xfs_v4_btrees_l2.qcow2 () {
echo "[*] This can take about ten minutes"
local img=$FUNCNAME local img=$FUNCNAME
local img_raw=$(basename $img .qcow2).raw local img_raw=$(basename $img .qcow2).raw
@@ -726,7 +719,7 @@ fat32_test0.raw () {
sudo mount -o codepage=866,iocharset=utf8,umask=111,dmask=000 $p1 $TEMP_DIR sudo mount -o codepage=866,iocharset=utf8,umask=111,dmask=000 $p1 $TEMP_DIR
$RANDDIR $TEMP_DIR 1000 8 255 65536 $RANDDIR $TEMP_DIR 1000 8 255 65536
$DIRTOTEST $TEMP_DIR $img hd0 > "../test/t045/run.us" $DIRTOTEST $TEMP_DIR $img hd0 > "../test/045/run.us"
# tree $TEMP_DIR # tree $TEMP_DIR
# du -sh $TEMP_DIR # du -sh $TEMP_DIR
@@ -848,7 +841,6 @@ exfat_s05k_c8k_b8k.qcow2 () {
} }
xfs_samehash_s05k.raw () { xfs_samehash_s05k.raw () {
echo "[*] This can take about one hour"
local img=$FUNCNAME local img=$FUNCNAME
# local img_raw=$(basename $img .qcow2).raw # local img_raw=$(basename $img .qcow2).raw
local img_raw=$img local img_raw=$img
@@ -896,7 +888,7 @@ ext2_s05k.qcow2 () {
local p1="$LOOP_DEV"p1 local p1="$LOOP_DEV"p1
$MKFS_EXT2 $EXT_MKFS_OPTS -N 1200000 $p1 $MKFS_EXT2 $EXT_MKFS_OPTS -N 1200000 $p1
debugfs -w -R "set_super_value hash_seed $EXT_HASH_SEED" $p1 debugfs -w -R "set_super_value hash_seed $EXT_HASH_SEED" $p1 > /dev/null
sudo mount $p1 $TEMP_DIR sudo mount $p1 $TEMP_DIR
sudo chown $USER $TEMP_DIR -R sudo chown $USER $TEMP_DIR -R
# #
@@ -926,7 +918,6 @@ ext2_s05k.qcow2 () {
} }
ext4_s05k.qcow2 () { ext4_s05k.qcow2 () {
echo "[*] This can take about ten minutes"
local img=$FUNCNAME local img=$FUNCNAME
local img_raw=$(basename $img .qcow2).raw local img_raw=$(basename $img .qcow2).raw
@@ -936,7 +927,7 @@ ext4_s05k.qcow2 () {
local p1="$LOOP_DEV"p1 local p1="$LOOP_DEV"p1
$MKFS_EXT4 $EXT_MKFS_OPTS -N 1200000 $p1 $MKFS_EXT4 $EXT_MKFS_OPTS -N 1200000 $p1
debugfs -w -R "set_super_value hash_seed $EXT_HASH_SEED" $p1 debugfs -w -R "set_super_value hash_seed $EXT_HASH_SEED" $p1 > /dev/null
sudo mount $p1 $TEMP_DIR sudo mount $p1 $TEMP_DIR
sudo chown $USER $TEMP_DIR -R sudo chown $USER $TEMP_DIR -R
# #
@@ -1039,53 +1030,6 @@ fat16_s05k.qcow2 () {
rm $img_raw rm $img_raw
} }
iso9660_s2k_dir_all.qcow2 () {
echo "[*] This can take about thirty minutes"
local img=$FUNCNAME
local img_raw=$(basename $img .qcow2).raw
sudo chown $USER $TEMP_DIR -R
mkdir $TEMP_DIR/dir_ls_a
mkdir $TEMP_DIR/dir_ls_b
$MKDIRRANGE $TEMP_DIR/dir_ls_b 0 3 0 2
mkdir $TEMP_DIR/dir_ls_c
$MKDIRRANGE $TEMP_DIR/dir_ls_c 0 5 201 43
mkdir $TEMP_DIR/dir_ls_d
$MKDIRRANGE $TEMP_DIR/dir_ls_d 0 50 201 43
mkdir $TEMP_DIR/dir_ls_e
$MKDIRRANGE $TEMP_DIR/dir_ls_e 0 1000 201 43
mkdir $TEMP_DIR/dir_ls_f
$MKDIRRANGE $TEMP_DIR/dir_ls_f 0 5000 231 13
mkdir $TEMP_DIR/dir_ls_g
$MKDIRRANGE $TEMP_DIR/dir_ls_g 0 46656 231 13
mkdir $TEMP_DIR/dir_stat_a
mkdir $TEMP_DIR/dir_stat_b
$MKDOUBLEDIRS $TEMP_DIR/dir_stat_b d 3
mkdir $TEMP_DIR/dir_stat_c
$MKDOUBLEDIRS $TEMP_DIR/dir_stat_c d 100
mkdir $TEMP_DIR/dir_stat_d
$MKDOUBLEDIRS $TEMP_DIR/dir_stat_d d 5000
mkdir $TEMP_DIR/dir_stat_e
$MKDOUBLEDIRS $TEMP_DIR/dir_stat_e d 3861
mkisofs -J -R -T -V 'KolibriOS' -input-charset 'UTF-8' -quiet $TEMP_DIR > $img_raw
rm $TEMP_DIR/* -rf
qemu-img convert -m 2 -O qcow2 -o $QCOW2_OPTS $img_raw $img
rm $img_raw
}
images=(gpt_large.qcow2 gpt_partitions_s05k.qcow2 gpt_partitions_s4k.qcow2 images=(gpt_large.qcow2 gpt_partitions_s05k.qcow2 gpt_partitions_s4k.qcow2
kolibri.raw jfs.qcow2 xfs_lookup_v4.qcow2 xfs_lookup_v5.qcow2 kolibri.raw jfs.qcow2 xfs_lookup_v4.qcow2 xfs_lookup_v5.qcow2
xfs_nrext64.qcow2 xfs_bigtime.qcow2 xfs_borg_bit.qcow2 xfs_nrext64.qcow2 xfs_bigtime.qcow2 xfs_borg_bit.qcow2
@@ -1097,7 +1041,7 @@ images=(gpt_large.qcow2 gpt_partitions_s05k.qcow2 gpt_partitions_s4k.qcow2
xfs_v5_files_s05k_b4k_n8k.qcow2 fat32_test0.raw xfs_v5_files_s05k_b4k_n8k.qcow2 fat32_test0.raw
exfat_s05k_c16k_b16k.qcow2 exfat_s05k_c8k_b8k.qcow2 exfat_s05k_c16k_b16k.qcow2 exfat_s05k_c8k_b8k.qcow2
xfs_samehash_s05k.raw ext2_s05k.qcow2 ext4_s05k.qcow2 fat12_s05k.qcow2 xfs_samehash_s05k.raw ext2_s05k.qcow2 ext4_s05k.qcow2 fat12_s05k.qcow2
fat16_s05k.qcow2 iso9660_s2k_dir_all.qcow2) fat16_s05k.qcow2)
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
LOOP_DEV=$(losetup --find) LOOP_DEV=$(losetup --find)

View File

@@ -3,7 +3,7 @@ ifndef KOLIBRIOS
endif endif
FASM_EXE ?= fasm FASM_EXE ?= fasm
FASM_FLAGS=-dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 -dHOST=$(HOST) -m 2000000 -dlang=en_US FASM_FLAGS=-dUEFI=1 -dextended_primary_loader=1 -dUMKA=1 -dHOST=$(HOST) -m 2000000
HOST ?= linux HOST ?= linux
CC ?= gcc CC ?= gcc
@@ -28,8 +28,7 @@ else
endif endif
CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c11 -g -O0 -DNDEBUG -masm=intel \ CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c11 -g -O0 -DNDEBUG -masm=intel \
-D_POSIX_C_SOURCE=200809L -I$(HOST) -Ideps -I. -fno-pie -D_POSIX \ -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 CFLAGS_32=$(CFLAGS) -m32 -D_FILE_OFFSET_BITS=64 -D__USE_TIME_BITS64
LDFLAGS=-no-pie LDFLAGS=-no-pie
LDFLAGS_32=$(LDFLAGS) -m32 LDFLAGS_32=$(LDFLAGS) -m32
@@ -84,7 +83,7 @@ umka_os: umka_os.o umka.o shell.o deps/lodepng/lodepng.o vdisk.o vdisk/raw.o \
vnet/file.o vnet/null.o trace.o trace_lbr.o $(HOST)/pci.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 \ $(HOST)/thread.o umkaio.o umkart.o deps/isocline/src/isocline.o \
deps/optparse/optparse.o deps/optparse/optparse.o
$(CC) $(LDFLAGS_32) $^ `sdl2-config --libs` -o $@ -T umka.ld $(CC) $(LDFLAGS_32) `sdl2-config --libs` $^ -o $@ -T umka.ld
umka_gen_devices_dat: umka_gen_devices_dat.o umka.o $(HOST)/pci.o \ umka_gen_devices_dat: umka_gen_devices_dat.o umka.o $(HOST)/pci.o \
$(HOST)/thread.o umkart.o $(HOST)/thread.o umkart.o

View File

@@ -37,7 +37,6 @@ _Thread_local char reffname[PATH_MAX];
_Thread_local char outfname[PATH_MAX]; _Thread_local char outfname[PATH_MAX];
int coverage = 0; int coverage = 0;
int no_timeout = 0;
int silent_success = 1; int silent_success = 1;
static int static int
@@ -126,7 +125,7 @@ struct test_wait_arg {
pthread_cond_t *cond; pthread_cond_t *cond;
}; };
static time_t static unsigned
get_test_timeout(const char *testname) { get_test_timeout(const char *testname) {
sprintf(timeoutfname, "%s/%s", testname, TIMEOUT_FILENAME); sprintf(timeoutfname, "%s/%s", testname, TIMEOUT_FILENAME);
FILE *f = fopen(timeoutfname, "rb"); FILE *f = fopen(timeoutfname, "rb");
@@ -179,33 +178,21 @@ run_test(const void *arg) {
int child; int child;
if (!(child = fork())) { if (!(child = fork())) {
chdir(test_name); chdir(test_name);
if (coverage) {
char covfile[64];
sprintf(covfile, "../cov_%s", test_name);
execl("/usr/bin/taskset", "taskset", "1", "sudo",
"../../umka_shell", "-ri", "run.us", "-o", "out.log", "-c",
covfile, NULL);
} else {
execl("../../umka_shell", "../../umka_shell", "-ri", "run.us", "-o", execl("../../umka_shell", "../../umka_shell", "-ri", "run.us", "-o",
"out.log", NULL); "out.log", NULL);
}
fprintf(stderr, "Can't run test command: %s\n", strerror(errno)); fprintf(stderr, "Can't run test command: %s\n", strerror(errno));
return (void *)-1; return (void *)-1;
} }
pthread_t t; pthread_t t;
struct test_wait_arg wa = {.pid = child, .cond = &cond}; struct test_wait_arg wa = {.pid = child, .cond = &cond};
pthread_create(&t, NULL, thread_wait, &wa); pthread_create(&t, NULL, thread_wait, &wa);
time_t tout = get_test_timeout(test_name); unsigned tout = get_test_timeout(test_name);
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts); clock_gettime(CLOCK_REALTIME, &ts);
if (no_timeout) {
ts.tv_sec += 60*60*24*7; // a week
} else {
ts.tv_sec += tout; ts.tv_sec += tout;
}
int status; int status;
if ((status = pthread_cond_timedwait(&cond, &mutex, &ts))) { if ((status = pthread_cond_timedwait(&cond, &mutex, &ts))) {
fprintf(stderr, "[!] %s: timeout (%llim%llis)\n", test_name, fprintf(stderr, "[!] %s: timeout (%um%us)\n", test_name,
tout/60, tout % 60); tout/60, tout % 60);
kill(child, SIGKILL); kill(child, SIGKILL);
result = (void *)(intptr_t)status; result = (void *)(intptr_t)status;
@@ -283,24 +270,19 @@ main(int argc, char *argv[]) {
(void)argc; (void)argc;
// int action = ACTION_RUN; // int action = ACTION_RUN;
size_t nthreads = 1; size_t nthreads = 1;
struct optparse opts; struct optparse opts;
optparse_init(&opts, argv); optparse_init(&opts, argv);
int opt; int opt;
while ((opt = optparse(&opts, "cj:st")) != -1) { while ((opt = optparse(&opts, "j:s")) != -1) {
switch (opt) { switch (opt) {
case 'c':
coverage = 1;
break;
case 'j': case 'j':
nthreads = strtoul(opts.optarg, NULL, 0); nthreads = strtoul(opts.optarg, NULL, 0);
break; break;
case 's': case 's':
silent_success = 0; silent_success = 0;
break; break;
case 't':
no_timeout = 1;
break;
default: default:
fprintf(stderr, "[!] Unknown option: '%c'\n", opt); fprintf(stderr, "[!] Unknown option: '%c'\n", opt);
exit(1); exit(1);

183
shell.c
View File

@@ -51,12 +51,124 @@
#define SHELL_CMD_BUF_LEN 0x10 #define SHELL_CMD_BUF_LEN 0x10
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,
};
enum { enum {
SHELL_CMD_STATUS_EMPTY, SHELL_CMD_STATUS_EMPTY,
SHELL_CMD_STATUS_READY, SHELL_CMD_STATUS_READY,
SHELL_CMD_STATUS_DONE, SHELL_CMD_STATUS_DONE,
}; };
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 umka_cmd {
atomic_int status;
uint32_t type;
union {
// internal funcs
struct cmd_set_mouse_data set_mouse_data;
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 umka_cmd_buf[SHELL_CMD_BUF_LEN]; struct umka_cmd umka_cmd_buf[SHELL_CMD_BUF_LEN];
char prompt_line[PATH_MAX]; char prompt_line[PATH_MAX];
@@ -69,6 +181,21 @@ typedef struct {
void (*func) (struct shell_ctx *, int, char **); void (*func) (struct shell_ctx *, int, char **);
} func_table_t; } func_table_t;
void
shell_run_cmd_sync(struct shell_ctx *ctx);
static 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);
}
}
static uint32_t static uint32_t
shell_run_cmd_wait_test(void /* struct appdata * with wait_param is in ebx */) { shell_run_cmd_wait_test(void /* struct appdata * with wait_param is in ebx */) {
appdata_t *app; appdata_t *app;
@@ -77,9 +204,6 @@ shell_run_cmd_wait_test(void /* struct appdata * with wait_param is in ebx */) {
return (uint32_t)(atomic_load_explicit(&cmd->status, memory_order_acquire) == SHELL_CMD_STATUS_READY); 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 static void
thread_cmd_runner(void *arg) { thread_cmd_runner(void *arg) {
umka_sti(); umka_sti();
@@ -420,16 +544,11 @@ cmd_send_scancode(struct shell_ctx *ctx, int argc, char **argv) {
argc -= 1; argc -= 1;
argv += 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;
while (argc) { while (argc) {
char *endptr; char *endptr;
size_t code = strtoul(argv[0], &endptr, 0); size_t code = strtoul(argv[0], &endptr, 0);
if (*endptr == '\0') { if (*endptr == '\0') {
c->scancode = code; umka_set_keyboard_data(code);
shell_run_cmd(ctx);
shell_clear_cmd(cmd);
argc--; argc--;
argv++; argv++;
} else { } else {
@@ -712,8 +831,6 @@ disk_list_partitions(struct shell_ctx *ctx, disk_t *d) {
fsname = "exfat"; fsname = "exfat";
} else if (p->fs_user_functions == ntfs_user_functions) { } else if (p->fs_user_functions == ntfs_user_functions) {
fsname = "ntfs"; fsname = "ntfs";
} else if (p->fs_user_functions == iso9660_user_functions) {
fsname = "iso9660";
} else { } else {
fsname = "???"; fsname = "???";
} }
@@ -1268,16 +1385,17 @@ cmd_mouse_move(struct shell_ctx *ctx, int argc, char **argv) {
} }
uint32_t btn_state = lbheld + (rbheld << 1) + (mbheld << 2) + (yabs << 30) uint32_t btn_state = lbheld + (rbheld << 1) + (mbheld << 2) + (yabs << 30)
+ (xabs << 31); + (xabs << 31);
struct umka_cmd *cmd = shell_get_cmd(ctx); struct umka_cmd *cmd = umka_cmd_buf;
cmd->type = UMKA_CMD_SET_MOUSE_DATA;
struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg; struct cmd_set_mouse_data_arg *c = &cmd->set_mouse_data.arg;
cmd->type = UMKA_CMD_SET_MOUSE_DATA;
c->btn_state = btn_state; c->btn_state = btn_state;
c->xmoving = xmoving; c->xmoving = xmoving;
c->ymoving = ymoving; c->ymoving = ymoving;
c->vscroll = vscroll; c->vscroll = vscroll;
c->hscroll = hscroll; c->hscroll = hscroll;
shell_run_cmd(ctx); shell_run_cmd(ctx);
shell_clear_cmd(cmd); atomic_store_explicit(&cmd->status, SHELL_CMD_STATUS_EMPTY,
memory_order_release);
} }
static void static void
@@ -4210,7 +4328,7 @@ func_table_t cmd_cmds[] = {
{ NULL, NULL }, { NULL, NULL },
}; };
static void void
shell_run_cmd_sync(struct shell_ctx *ctx) { shell_run_cmd_sync(struct shell_ctx *ctx) {
struct umka_cmd *cmd = umka_cmd_buf; struct umka_cmd *cmd = umka_cmd_buf;
switch (cmd->type) { switch (cmd->type) {
@@ -4248,18 +4366,9 @@ shell_run_cmd_sync(struct shell_ctx *ctx) {
COVERAGE_OFF(); COVERAGE_OFF();
break; 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: { case UMKA_CMD_SYS_LFN: {
struct cmd_sys_lfn_arg *c = &cmd->sys_lfn.arg; struct cmd_sys_lfn_arg *c = &cmd->sys_lfn.arg;
COVERAGE_ON();
umka_sys_lfn(c->bufptr, c->r, c->f70or80); umka_sys_lfn(c->bufptr, c->r, c->f70or80);
COVERAGE_OFF();
break; break;
} }
default: default:
@@ -4271,30 +4380,6 @@ shell_run_cmd_sync(struct shell_ctx *ctx) {
pthread_cond_signal(&ctx->cmd_done); 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 static void
cmd_help(struct shell_ctx *ctx, int argc, char **argv) { cmd_help(struct shell_ctx *ctx, int argc, char **argv) {
const char *usage = \ const char *usage = \
@@ -4343,7 +4428,7 @@ run_test(struct shell_ctx *ctx) {
pthread_mutex_lock(&ctx->cmd_mutex); pthread_mutex_lock(&ctx->cmd_mutex);
int is_tty = isatty(fileno(stdin)); int is_tty = isatty(fileno(stdin));
char **argv = (char**)calloc(MAX_COMMAND_ARGS + 1, sizeof(char*)); char **argv = (char**)calloc(sizeof(char*), (MAX_COMMAND_ARGS + 1));
ic_set_default_completer(completer, NULL); ic_set_default_completer(completer, NULL);
ic_set_default_highlighter(highlighter, NULL); ic_set_default_highlighter(highlighter, NULL);
ic_enable_auto_tab(1); ic_enable_auto_tab(1);

135
shell.h
View File

@@ -59,140 +59,7 @@ shell_close(struct shell_ctx *shell);
void * void *
run_test(struct shell_ctx *ctx); 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 void
shell_run_cmd(struct shell_ctx *ctx); umka_run_cmd_sync(struct shell_ctx *ctx);
void
shell_clear_cmd(struct umka_cmd *cmd);
#endif // SHELL_H_INCLUDED #endif // SHELL_H_INCLUDED

15
test/d037/run.us Normal file
View File

@@ -0,0 +1,15 @@
acpi_set_usage 1
acpi_preload_table /data/work/mirror/acpica/tests/aslts/tmp/aml/20201217/nopt/64/arithmetic.aml
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt
acpi_call \MAIN
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

1
test/d037/tags.txt Normal file
View File

@@ -0,0 +1 @@
acpi: aml

1
test/d037/timeout.txt Normal file
View File

@@ -0,0 +1 @@
10s

17
test/d039/run.us Normal file
View File

@@ -0,0 +1,17 @@
acpi_set_usage 1
acpi_preload_table machines/008/acpi/dsdt.dat
acpi_preload_table machines/008/acpi/ssdt1.dat
acpi_preload_table machines/008/acpi/ssdt2.dat
acpi_preload_table machines/008/acpi/ssdt3.dat
acpi_preload_table machines/008/acpi/ssdt4.dat
acpi_preload_table machines/008/acpi/ssdt5.dat
acpi_preload_table machines/008/acpi/ssdt6.dat
acpi_preload_table machines/008/acpi/ssdt7.dat
acpi_preload_table machines/008/acpi/ssdt8.dat
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

1
test/d039/tags.txt Normal file
View File

@@ -0,0 +1 @@
acpi: aml

1
test/d039/timeout.txt Normal file
View File

@@ -0,0 +1 @@
10s

422
test/d041/ref.log Normal file
View File

@@ -0,0 +1,422 @@
/> acpi_set_usage 1
/> acpi_preload_table machines/unit/acpi/alloc_free.aml
table #0
/> acpi_enable
acpi.aml.process_table begin
table length 0x0000012C
Table signature: 'DSDT'
Table length (with header): 0x0000012C
Revision: 0x01
OEM ID: 'UMKA '
OEM Table ID: 'UMKADSDT'
OEM Table Revision: 0x00000001
table/position: [0x00000024]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.name begin
aml._.name_string begin
aml._.name_string begin again
offset: 0x00000025
aml._.name_path begin
aml._.name_path end
name_string: INT5
aml._.name_string end
aml._.get_node_by_name begin
name: ''
aml._.get_node_by_name end
aml._.data_ref_object begin
aml._.data_object begin
aml._.computational_data begin
aml._.byte_const begin
aml._.byte_const end
aml._.computational_data end
aml._.data_object end
aml._.data_ref_object end
aml._.name end
aml._.namespace_modifier_obj end
aml._.object end
aml._.term_obj end
table/position: [0x0000002B]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.name begin
aml._.name_string begin
aml._.name_string begin again
offset: 0x0000002C
aml._.name_path begin
aml._.name_path end
name_string: REF5
aml._.name_string end
aml._.get_node_by_name begin
name: ''
aml._.get_node_by_name end
aml._.data_ref_object begin
aml._.data_object begin
aml._.computational_data begin
aml._.byte_const begin
aml._.byte_const end
aml._.computational_data end
aml._.data_object end
aml._.data_ref_object end
aml._.name end
aml._.namespace_modifier_obj end
aml._.object end
aml._.term_obj end
table/position: [0x00000032]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.method begin
pkg_length: 0x000000EA
aml._.name_string begin
aml._.name_string begin again
offset: 0x00000035
aml._.name_path begin
aml._.name_path end
name_string: AREF
aml._.name_string end
aml._.attach_node begin
aml._.get_node_by_name begin
name: ''
aml._.get_node_by_name end
aml._.attach_node end
aml._.method end
aml._.named_obj end
aml._.object end
aml._.term_obj end
table/position: [0x0000011D]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.method begin
pkg_length: 0x0000000E
aml._.name_string begin
aml._.name_string begin again
offset: 0x0000011F
aml._.name_path begin
aml._.name_path end
name_string: MAIN
aml._.name_string end
aml._.attach_node begin
aml._.get_node_by_name begin
name: ''
aml._.get_node_by_name end
aml._.attach_node end
aml._.method end
aml._.named_obj end
aml._.object end
aml._.term_obj end
==========ACPI_TREE==========
\MAIN Method length:0x00000008 Args:0 serialize:0 sync_level:0
\AREF Method length:0x000000E3 Args:1 serialize:0 sync_level:0
\REF5 Integer = 0x0000000000000002
\INT5 Integer = 0x0000000000000005
\_TZ_ Scope
\_SI_ Scope
\_SB_ Scope
\_PR_ Scope
\_GPE Scope
-----------------------------
acpi.aml.process_table end
==========ACPI_TREE==========
\MAIN Method length:0x00000008 Args:0 serialize:0 sync_level:0
\AREF Method length:0x000000E3 Args:1 serialize:0 sync_level:0
\REF5 Integer = 0x0000000000000002
\INT5 Integer = 0x0000000000000005
\_TZ_ Scope
\_SI_ Scope
\_SB_ Scope
\_PR_ Scope
\_GPE Scope
-----------------------------
/> acpi_get_node_alloc_cnt
nodes allocated: 11
/> acpi_get_node_free_cnt
nodes freed: 0
/> acpi_get_node_cnt
nodes in namespace: 11
/> acpi_call \MAIN
acpi.call_name begin
aml._.get_node_by_name begin
name: '\MAIN'
aml._.get_node_by_name end
acpi.call_node begin
# func name MAIN
# bytes 0x46455241
# bytes 0x35544E49
# bytes 0x0001DE69
table/position: [0x00000124]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.named_obj end
aml._.object end
aml._.type1opcode begin
aml._.type1opcode end
aml._.name_string begin
aml._.name_string begin again
offset: 0x00000124
aml._.name_path begin
aml._.name_path end
name_string: AREF
aml._.name_string end
aml._.get_node_by_name begin
name: 'AREF'
aml._.get_node_by_name end
aml._.method_invocation begin
arg_count: 1
aml._.term_arg begin
aml._.name_string begin
aml._.name_string begin again
offset: 0x00000128
aml._.name_path begin
aml._.name_path end
name_string: INT5
aml._.name_string end
aml._.get_node_by_name begin
name: 'INT5'
aml._.get_node_by_name end
aml._.data_object begin
aml._.computational_data begin
aml._.computational_data end
aml._.data_object end
aml._.name_string begin
aml._.name_string begin again
offset: 0x00000128
aml._.name_path begin
aml._.name_path end
name_string: INT5
aml._.name_string end
aml._.get_node_by_name begin
name: 'INT5'
aml._.get_node_by_name end
aml._.term_arg end
table/position: [0x0000003A]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.named_obj end
aml._.object end
aml._.type1opcode begin
aml._.type1opcode end
aml._.store begin
aml._.term_arg begin
aml._.name_string begin
aml._.name_string begin again
offset: 0x0000003B
aml._.name_path begin
aml._.name_path end
name_string: INT5
aml._.name_string end
aml._.get_node_by_name begin
name: 'INT5'
aml._.get_node_by_name end
aml._.data_object begin
aml._.computational_data begin
aml._.computational_data end
aml._.data_object end
aml._.name_string begin
aml._.name_string begin again
offset: 0x0000003B
aml._.name_path begin
aml._.name_path end
name_string: INT5
aml._.name_string end
aml._.get_node_by_name begin
name: 'INT5'
aml._.get_node_by_name end
aml._.term_arg end
aml._.super_name begin
aml._.simple_name begin
aml._.name_string begin
aml._.name_string end
aml._.simple_name end
aml._.debug_obj begin
aml._.debug_obj end
aml._.super_name end
aml._.store_table begin
types 2 to 19
aml._.store_table.integer_to_debug_object begin
AML_DBG: 0x0000000000000005
aml._.store_table.integer_to_debug_object end
aml._.store_table end
aml._.store end
aml._.term_obj end
table/position: [0x00000041]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.named_obj end
aml._.object end
aml._.type1opcode begin
aml._.type1opcode end
aml._.store begin
aml._.term_arg begin
aml._.name_string begin
aml._.name_string end
aml._.data_object begin
aml._.computational_data begin
aml._.computational_data end
aml._.data_object end
aml._.arg_obj begin
aml._.arg_obj end
aml._.term_arg end
aml._.super_name begin
aml._.simple_name begin
aml._.name_string begin
aml._.name_string end
aml._.simple_name end
aml._.debug_obj begin
aml._.debug_obj end
aml._.super_name end
aml._.store_table begin
types 2 to 19
aml._.store_table.integer_to_debug_object begin
AML_DBG: 0x0000000000000005
aml._.store_table.integer_to_debug_object end
aml._.store_table end
aml._.store end
aml._.term_obj end
table/position: [0x00000045]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.named_obj end
aml._.object end
aml._.type1opcode begin
aml._.type1opcode end
aml._.store begin
aml._.term_arg begin
aml._.name_string begin
aml._.name_string begin again
offset: 0x00000046
aml._.name_path begin
aml._.name_path end
name_string: REF5
aml._.name_string end
aml._.get_node_by_name begin
name: 'REF5'
aml._.get_node_by_name end
aml._.data_object begin
aml._.computational_data begin
aml._.computational_data end
aml._.data_object end
aml._.name_string begin
aml._.name_string begin again
offset: 0x00000046
aml._.name_path begin
aml._.name_path end
name_string: REF5
aml._.name_string end
aml._.get_node_by_name begin
name: 'REF5'
aml._.get_node_by_name end
aml._.term_arg end
aml._.super_name begin
aml._.simple_name begin
aml._.name_string begin
aml._.name_string end
aml._.simple_name end
aml._.debug_obj begin
aml._.debug_obj end
aml._.super_name end
aml._.store_table begin
types 2 to 19
aml._.store_table.integer_to_debug_object begin
AML_DBG: 0x0000000000000002
aml._.store_table.integer_to_debug_object end
aml._.store_table end
aml._.store end
aml._.term_obj end
table/position: [0x0000004C]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.named_obj end
aml._.object end
aml._.type1opcode begin
aml._.type1opcode end
aml._.store begin
aml._.term_arg begin
aml._.name_string begin
aml._.name_string end
aml._.data_object begin
aml._.computational_data begin
aml._.string begin
aml._.string end
aml._.computational_data end
aml._.data_object end
aml._.term_arg end
aml._.super_name begin
aml._.simple_name begin
aml._.name_string begin
aml._.name_string end
aml._.simple_name end
aml._.debug_obj begin
aml._.debug_obj end
aml._.super_name end
aml._.store_table begin
types 3 to 19
aml._.store_table.string_to_debug_object begin
AML_DBG:
aml._.store_table.string_to_debug_object end
aml._.store_table end
aml._.store end
aml._.term_obj end
table/position: [0x00000052]
aml._.term_obj begin
aml._.object begin
aml._.namespace_modifier_obj begin
aml._.namespace_modifier_obj end
aml._.named_obj begin
aml._.named_obj end
aml._.object end
aml._.type1opcode begin
aml._.type1opcode end
aml._.store begin
aml._.term_arg begin
aml._.name_string begin
aml._.name_string end
aml._.data_object begin
aml._.computational_data begin
aml._.computational_data end
aml._.data_object end
aml._.name_string begin
aml._.name_string end
error: unknown term_arg: 0x71
aml._.term_arg end
aml._.super_name begin
aml._.simple_name begin
aml._.name_string begin
aml._.name_string end
aml._.simple_name end
aml._.name_string begin
aml._.name_string end
aml._.super_name end
aml._.store end
aml._.name_string begin
aml._.name_string end
aml._.term_obj end
error: unknown bytes: 0x7168

15
test/d041/run.us Normal file
View File

@@ -0,0 +1,15 @@
acpi_set_usage 1
acpi_preload_table machines/unit/acpi/alloc_free.aml
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt
acpi_call \MAIN
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

1
test/d041/tags.txt Normal file
View File

@@ -0,0 +1 @@
acpi: aml

1
test/d041/timeout.txt Normal file
View File

@@ -0,0 +1 @@
10s

161961
test/d048/ref.log Normal file

File diff suppressed because it is too large Load Diff

23
test/d048/run.us Normal file
View File

@@ -0,0 +1,23 @@
umka_init
pci_set_path machines/013/pci
acpi_set_usage 2
acpi_preload_table machines/013/acpi/dsdt.dat
acpi_preload_table machines/013/acpi/ssdt1.dat
acpi_preload_table machines/013/acpi/ssdt2.dat
acpi_preload_table machines/013/acpi/ssdt3.dat
acpi_preload_table machines/013/acpi/ssdt4.dat
acpi_preload_table machines/013/acpi/ssdt5.dat
acpi_preload_table machines/013/acpi/ssdt6.dat
acpi_preload_table machines/013/acpi/ssdt7.dat
acpi_preload_table machines/013/acpi/ssdt8.dat
acpi_preload_table machines/013/acpi/ssdt9.dat
acpi_preload_table machines/013/acpi/ssdt10.dat
acpi_preload_table machines/013/acpi/ssdt11.dat
acpi_preload_table machines/013/acpi/ssdt12.dat
acpi_enable
acpi_get_node_alloc_cnt
acpi_get_node_free_cnt
acpi_get_node_cnt

1
test/d048/tags.txt Normal file
View File

@@ -0,0 +1 @@
acpi: aml

1
test/d048/timeout.txt Normal file
View File

@@ -0,0 +1 @@
10s

View File

@@ -0,0 +1,2 @@
name:
owner: Doczom

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
name:
owner: Vitaly K

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More