Switch to the wall clock timer, communicate via shared memory

This commit is contained in:
Ivan Baravy 2023-01-21 07:49:13 +00:00
parent 65cbfbc743
commit 94ebe02739
5 changed files with 78 additions and 22 deletions

View File

@ -17,6 +17,8 @@ start:
btr dword[esp], BSF EFLAGS.ID btr dword[esp], BSF EFLAGS.ID
popfd popfd
mcall 68, 11
mcall 12, 1 mcall 12, 1
mcall 0, <100,200>, <100,100>, 0x34888888, , window_title mcall 0, <100,200>, <100,100>, 0x34888888, , window_title
mcall 12, 2 mcall 12, 2
@ -25,13 +27,33 @@ start:
mcall 70, fs70 mcall 70, fs70
DEBUGF 1, "files in dir: %d\n", ebx DEBUGF 1, "files in dir: %d\n", ebx
mcall 15, 1, 2, 2
mcall 15, 4, 1
mcall 15, 6
mov ecx, 0
mov edx, 0xff
mov [eax+0], cl
mov [eax+1], cl
mov [eax+2], cl
mov [eax+3], dl
mov [eax+4], dl
mov [eax+5], dl
mov [eax+6], dl
mov [eax+7], dl
mov [eax+8], dl
mov [eax+9], cl
mov [eax+10], cl
mov [eax+11], cl
mcall 15, 7, eax
mcall 15, 3
mcall 18, 19, 4, 0 mcall 18, 19, 4, 0
.next: .next:
mcall 37, 0 mcall 37, 0
add eax, 0x00020002 add eax, 0x00010001
mov edx, eax mov edx, eax
mcall 18, 19, 4 mcall 18, 19, 4
mcall 5, 1 mcall 5, 10
; mov ecx, 0x1000000 ; mov ecx, 0x1000000
; loopnz $ ; loopnz $
jmp .next jmp .next

View File

@ -41,8 +41,8 @@ else
endif endif
ifeq ($(HOST),linux) ifeq ($(HOST),linux)
all: umka_shell umka_fuse umka_os umka_gen_devices_dat umka.sym umka.prp \ all: umka_shell umka_fuse umka_os umka_monitor umka_gen_devices_dat umka.sym \
umka.lst tags default.skn skin.skn umka.prp umka.lst tags default.skn skin.skn
else ifeq ($(HOST),windows) else ifeq ($(HOST),windows)
all: umka_shell umka.sym umka.prp \ all: umka_shell umka.sym umka.prp \
umka.lst default.skn skin.skn umka.lst default.skn skin.skn
@ -58,7 +58,7 @@ test: umka_shell
umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o \ umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o \
vdisk/raw.o vdisk/qcow2.o vdisk/miniz/miniz.a vnet.o lodepng.o \ vdisk/raw.o vdisk/qcow2.o vdisk/miniz/miniz.a vnet.o lodepng.o \
$(HOST)/pci.o $(HOST)/thread.o io.o $(HOST)/io_async.o util.o \ $(HOST)/pci.o $(HOST)/thread.o io.o $(HOST)/io_async.o util.o \
optparse.o bestline.o optparse32.o bestline32.o
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld $(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o vdisk/raw.o \ umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o vdisk/raw.o \
@ -68,9 +68,12 @@ umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o vdisk/raw.o \
umka_os: umka_os.o umka.o shell.o lodepng.o vdisk.o vdisk/raw.o vdisk/qcow2.o \ umka_os: umka_os.o umka.o shell.o lodepng.o vdisk.o vdisk/raw.o vdisk/qcow2.o \
vdisk/miniz/miniz.a vnet.o trace.o trace_lbr.o $(HOST)/pci.o \ vdisk/miniz/miniz.a vnet.o trace.o trace_lbr.o $(HOST)/pci.o \
$(HOST)/thread.o io.o $(HOST)/io_async.o util.o bestline.o optparse.o $(HOST)/thread.o io.o $(HOST)/io_async.o util.o bestline32.o optparse32.o
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld $(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
umka_monitor: umka_monitor.o optparse.o bestline.o
$(CC) $(LDFLAGS) `sdl2-config --libs` $^ -o $@
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 util.o $(HOST)/thread.o util.o
$(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld $(CC) $(LDFLAGS_32) $^ -o $@ -T umka.ld
@ -96,11 +99,17 @@ $(HOST)/pci.o: $(HOST)/pci.c
lodepng.o: lodepng.c lodepng.h lodepng.o: lodepng.c lodepng.h
$(CC) $(CFLAGS_32) -c $< $(CC) $(CFLAGS_32) -c $<
bestline32.o: bestline.c bestline.h
$(CC) $(CFLAGS_32) -U_POSIX_C_SOURCE -Wno-logical-op -Wno-switch-enum -c $< -o $@
bestline.o: bestline.c bestline.h bestline.o: bestline.c bestline.h
$(CC) $(CFLAGS_32) -U_POSIX_C_SOURCE -Wno-logical-op -Wno-switch-enum -c $< $(CC) $(CFLAGS) -U_POSIX_C_SOURCE -Wno-logical-op -Wno-switch-enum -c $< -o $@
optparse32.o: optparse.c optparse.h
$(CC) $(CFLAGS_32) -c $< -o $@
optparse.o: optparse.c optparse.h optparse.o: optparse.c optparse.h
$(CC) $(CFLAGS_32) -c $< $(CC) $(CFLAGS) -c $< -o $@
util.o: util.c util.h umka.h util.o: util.c util.h umka.h
$(CC) $(CFLAGS_32) -c $< $(CC) $(CFLAGS_32) -c $<
@ -162,9 +171,12 @@ umka_shell.o: umka_shell.c umka.h trace.h
umka_fuse.o: umka_fuse.c umka.h umka_fuse.o: umka_fuse.c umka.h
$(CC) $(CFLAGS_32) `pkg-config fuse3 --cflags` -c $< $(CC) $(CFLAGS_32) `pkg-config fuse3 --cflags` -c $<
umka_os.o: umka_os.c umka.h umka_os.o: umka_os.c umka.h umka_os.h
$(CC) $(CFLAGS_32) -c $< $(CC) $(CFLAGS_32) -c $<
umka_monitor.o: umka_monitor.c umka_os.h
$(CC) $(CFLAGS) `sdl2-config --cflags` -c $< -D_GNU_SOURCE
umka_gen_devices_dat.o: umka_gen_devices_dat.c umka.h umka_gen_devices_dat.o: umka_gen_devices_dat.c umka.h
$(CC) $(CFLAGS_32) -c $< $(CC) $(CFLAGS_32) -c $<

View File

@ -3,7 +3,7 @@ SYS_READ = 3
SYS_WRITE = 4 SYS_WRITE = 4
SYS_OPEN = 5 SYS_OPEN = 5
SYS_CLOSE = 6 SYS_CLOSE = 6
;SYS_LSEEK = 19 SYS_PAUSE = 29
SYS_LLSEEK = 140 SYS_LLSEEK = 140
SEEK_SET = 0 SEEK_SET = 0

View File

@ -803,12 +803,11 @@ endp
pubsym skin_udata pubsym skin_udata
proc idle uses ebx esi edi proc idle uses ebx esi edi
sti sti
.loop:
mov ecx, 10000000
@@: @@:
loop @b
; DEBUGF 1, "1 idle\n" ; DEBUGF 1, "1 idle\n"
jmp .loop movi eax, SYS_PAUSE
int 0x80
jmp @b
ret ret
endp endp

View File

@ -2,7 +2,7 @@
SPDX-License-Identifier: GPL-2.0-or-later SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools UMKa - User-Mode KolibriOS developer tools
umka_os - kind of KolibriOS rump kernel umka_os - kind of KolibriOS anykernel
Copyright (C) 2018-2023 Ivan Baravy <dunkaist@gmail.com> Copyright (C) 2018-2023 Ivan Baravy <dunkaist@gmail.com>
*/ */
@ -25,6 +25,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include "umka.h" #include "umka.h"
#include "umka_os.h"
#include "optparse.h" #include "optparse.h"
#include "shell.h" #include "shell.h"
#include "trace.h" #include "trace.h"
@ -168,13 +169,15 @@ hw_int(int signo, siginfo_t *info, void *context) {
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
(void)argc; (void)argc;
const char *usage = "umka_os [-i <infile>] [-o <outfile>]\n"; const char *usage = "umka_os [-i <infile>] [-o <outfile>] [-s <shname>]\n";
if (coverage) { if (coverage) {
trace_begin(); trace_begin();
} }
umka_sti(); umka_sti();
const char *shname = "/umka";
int shfd = 0;
const char *infile = NULL, *outfile = NULL; const char *infile = NULL, *outfile = NULL;
build_history_filename(); build_history_filename();
@ -182,7 +185,7 @@ main(int argc, char *argv[]) {
int opt; int opt;
optparse_init(&options, argv); optparse_init(&options, argv);
while ((opt = optparse(&options, "i:o:")) != -1) { while ((opt = optparse(&options, "i:o:s:")) != -1) {
switch (opt) { switch (opt) {
case 'i': case 'i':
infile = options.optarg; infile = options.optarg;
@ -190,6 +193,9 @@ main(int argc, char *argv[]) {
case 'o': case 'o':
outfile = options.optarg; outfile = options.optarg;
break; break;
case 's':
shname = options.optarg;
break;
default: default:
fprintf(stderr, "bad option: %c\n", opt); fprintf(stderr, "bad option: %c\n", opt);
fputs(usage, stderr); fputs(usage, stderr);
@ -197,6 +203,13 @@ main(int argc, char *argv[]) {
} }
} }
if (shname) {
shfd = shm_open(shname, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (!shfd) {
perror("[!] can't open shared memory");
exit(1);
}
}
if (infile && !freopen(infile, "r", stdin)) { if (infile && !freopen(infile, "r", stdin)) {
fprintf(stderr, "[!] can't open file for reading: %s\n", infile); fprintf(stderr, "[!] can't open file for reading: %s\n", infile);
exit(1); exit(1);
@ -213,8 +226,8 @@ main(int argc, char *argv[]) {
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO; sa.sa_flags = SA_SIGINFO;
if (sigaction(SIGPROF, &sa, NULL) == -1) { if (sigaction(SIGALRM, &sa, NULL) == -1) {
fprintf(stderr, "Can't install SIGPROF handler!\n"); fprintf(stderr, "Can't install SIGALRM handler!\n");
return 1; return 1;
} }
@ -252,13 +265,23 @@ main(int argc, char *argv[]) {
exit(1); exit(1);
} }
printf("pid=%d, kos_lfb_base=%p\n", getpid(), (void*)kos_lfb_base);
kos_boot.bpp = UMKA_DEFAULT_DISPLAY_BPP; kos_boot.bpp = UMKA_DEFAULT_DISPLAY_BPP;
kos_boot.x_res = UMKA_DEFAULT_DISPLAY_WIDTH; kos_boot.x_res = UMKA_DEFAULT_DISPLAY_WIDTH;
kos_boot.y_res = UMKA_DEFAULT_DISPLAY_HEIGHT; kos_boot.y_res = UMKA_DEFAULT_DISPLAY_HEIGHT;
kos_boot.pitch = UMKA_DEFAULT_DISPLAY_WIDTH * UMKA_DEFAULT_DISPLAY_BPP / 8; kos_boot.pitch = UMKA_DEFAULT_DISPLAY_WIDTH * UMKA_DEFAULT_DISPLAY_BPP / 8;
struct shared_info sinfo = (struct shared_info) {
.pid = getpid(),
.lfb_base = (uintptr_t)kos_lfb_base,
.lfb_bpp = kos_boot.bpp,
.lfb_width = kos_boot.x_res,
.lfb_height = kos_boot.y_res,
.cmd_buf = (uintptr_t)cmd_buf,
};
ftruncate(shfd, sizeof(sinfo));
write(shfd, &sinfo, sizeof(sinfo));
// printf("pid=%d, kos_lfb_base=%p\n", getpid(), (void*)kos_lfb_base);
run_test(ctx->shell); run_test(ctx->shell);
// umka_stack_init(); // umka_stack_init();
@ -313,7 +336,7 @@ main(int argc, char *argv[]) {
dump_procs(); dump_procs();
setitimer(ITIMER_PROF, &timeout, NULL); setitimer(ITIMER_REAL, &timeout, NULL);
ctx->umka->running = 1; ctx->umka->running = 1;
umka_osloop(); // doesn't return umka_osloop(); // doesn't return