Wrap sf9: process info.

This commit is contained in:
Ivan Baravy 2020-02-08 06:13:04 +03:00
parent 4cf0d46fe6
commit 18edc67a10
6 changed files with 106 additions and 6 deletions

9
README
View File

@ -36,4 +36,13 @@ Kernel services are replaced with stubs or libc calls. Block devices are
emulated with wrappers around regular files. Shell and FUSE FS are written in C.
Troubleshooting
---------------
gm convert -size 400x300 -depth 8 umka.rgba umka.png
Links
-----
[1] https://github.com/libfuse/libfuse

41
kofu.c
View File

@ -237,6 +237,44 @@ void kofu_write_text(int argc, const char **argv) {
umka_sys_write_text(x, y, color, asciiz, fill_background, font_and_encoding, draw_to_buffer, scale_factor, string, length, background_color_or_buffer);
}
void kofu_dump_win_stack(int argc, const char **argv) {
int depth = 5;
if (argc > 1) {
depth = strtol(argv[1], NULL, 0);
}
for (int i = 0; i < depth; i++) {
printf("%3i: %3u\n", i, kos_win_stack[i]);
}
}
void kofu_dump_win_pos(int argc, const char **argv) {
int depth = 5;
if (argc > 1) {
depth = strtol(argv[1], NULL, 0);
}
for (int i = 0; i < depth; i++) {
printf("%3i: %3u\n", i, kos_win_pos[i]);
}
}
void kofu_process_info(int argc, const char **argv) {
(void)argc;
process_information_t info;
int32_t pid = strtol(argv[1], NULL, 0);
umka_sys_process_info(pid, &info);
printf("cpu_usage: %u\n", info.cpu_usage);
printf("window_stack_position: %u\n", info.window_stack_position);
printf("window_stack_value: %u\n", info.window_stack_value);
printf("process_name: %s\n", info.process_name);
printf("memory_start: 0x%.8" PRIx32 "\n", info.memory_start);
printf("used_memory: %u (0x%x)\n", info.used_memory, info.used_memory);
printf("pid: %u\n", info.pid);
printf("box: %u %u %u %u\n", info.box.left, info.box.top, info.box.width, info.box.height);
printf("slot_state: %u\n", info.slot_state);
printf("client_box: %u %u %u %u\n", info.client_box.left, info.client_box.top, info.client_box.width, info.client_box.height);
printf("wnd_state: 0x%.2" PRIx8 "\n", info.wnd_state);
}
void kofu_display_number(int argc, const char **argv) {
(void)argc;
int is_pointer = strtoul(argv[1], NULL, 0);
@ -668,6 +706,7 @@ func_table_t funcs[] = {
{ "write_text", kofu_write_text },
{ "put_image", kofu_put_image },
{ "button", kofu_button },
{ "process_info", kofu_process_info },
{ "window_redraw", kofu_window_redraw },
{ "draw_rect", kofu_draw_rect },
{ "draw_line", kofu_draw_line },
@ -679,6 +718,8 @@ func_table_t funcs[] = {
{ "set_window_caption", kofu_set_window_caption },
{ "blit_bitmap", kofu_blit_bitmap },
{ "scrot", kofu_scrot },
{ "dump_win_stack", kofu_dump_win_stack },
{ "dump_win_pos", kofu_dump_win_pos },
{ NULL, NULL },
};

View File

@ -49,6 +49,8 @@ TASK_BASE = os_base + 0x00003010
CURRENT_TASK = os_base + 0x00003000
TASK_COUNT = os_base + 0x00003004
TASK_BASE = os_base + 0x00003010
WIN_STACK = os_base + 0x0000C000
WIN_POS = os_base + 0x0000C400
include 'system.inc'
include 'fdo.inc'
@ -70,6 +72,7 @@ include 'gui/button.inc'
load_file equ __load_file
include 'gui/skincode.inc'
restore load_file
include 'sysother.inc'
include 'gui/draw.inc'
include 'gui/font.inc'
include 'gui/event.inc'
@ -193,12 +196,14 @@ proc kos_init c uses ebx esi edi ebp
mov dword[sysdir_path], 'HD0/'
mov word[sysdir_path+4], '1'
mov eax, SLOT_BASE + 2*256
mov [current_slot], eax
mov ebx, SLOT_BASE + 2*256
mov [current_slot], ebx
stdcall kernel_alloc, 0x2000
mov [ebx+APPDATA.process], eax
mov word[cur_dir.path], '/'
mov [eax+APPDATA.cur_dir], cur_dir
mov [eax+APPDATA.wnd_clientbox.left], 0
mov [eax+APPDATA.wnd_clientbox.top], 0
mov [ebx+APPDATA.cur_dir], cur_dir
mov [ebx+APPDATA.wnd_clientbox.left], 0
mov [ebx+APPDATA.wnd_clientbox.top], 0
mov dword[CURRENT_TASK], 2
mov dword[TASK_COUNT], 2
mov dword[TASK_BASE], CURRENT_TASK + 2*sizeof.TASKDATA
@ -531,7 +536,6 @@ sys_getkey:
sys_clock:
delay_hs_unprotected:
undefined_syscall:
sys_cpuusage:
sys_redrawstat:
syscall_getscreensize:
sys_background:
@ -640,6 +644,10 @@ ide_channel6_mutex MUTEX
ide_channel7_mutex MUTEX
ide_channel8_mutex MUTEX
os_base rb 0x400000
public win_stack_addr as 'kos_win_stack'
win_stack_addr dd WIN_STACK
public win_pos_addr as 'kos_win_pos'
win_pos_addr dd WIN_POS
public lfb_base_addr as 'kos_lfb_base'
lfb_base_addr dd lfb_base
lfb_base rd MAX_SCREEN_WIDTH*MAX_SCREEN_HEIGHT

View File

@ -7,6 +7,31 @@
#define BDFE_LEN_CP866 304
#define BDFE_LEN_UNICODE 560
typedef struct {
uint32_t left, top, right, bottom;
} rect_t;
typedef struct {
uint32_t left, top, width, height;
} box_t;
typedef struct {
uint32_t cpu_usage; // +0
uint16_t window_stack_position; // +4
uint16_t window_stack_value; // +6
uint16_t pad; // +8
char process_name[12]; // +10
uint32_t memory_start; // +22
uint32_t used_memory; // +26
uint32_t pid; // +30
box_t box; // +34
uint16_t slot_state; // +50
uint16_t pad2; // +52
box_t client_box; // +54
uint8_t wnd_state; // +70
uint8_t pad3[1024-71];
} __attribute__((packed)) process_information_t;
enum {
DEFAULT,
CP866,
@ -142,4 +167,6 @@ void coverage_begin(void);
void coverage_end(void);
extern uint32_t *kos_lfb_base;
extern uint16_t *kos_win_stack;
extern uint16_t *kos_win_pos;
#endif

View File

@ -87,6 +87,16 @@ static inline void umka_sys_button(size_t x, size_t xsize,
: "memory");
}
static inline void umka_sys_process_info(int32_t pid, void *param) {
__asm__ __inline__ __volatile__ (
"call i40"
:
: "a"(9),
"b"(param),
"c"(pid)
: "memory");
}
static inline void umka_sys_window_redraw(int begin_end) {
__asm__ __inline__ __volatile__ (
"call i40"

View File

@ -28,4 +28,9 @@ window_redraw 2
set_window_caption hi_2there 0
dump_win_stack 5
dump_win_pos 5
process_info -1
scrot umka.rgba