Move shell from umka_shell to separate module.

This commit is contained in:
Ivan Baravy 2020-05-10 07:21:49 +03:00
parent 7f355dfed2
commit 10f97725c4
7 changed files with 1880 additions and 1768 deletions

View File

@ -11,18 +11,21 @@ all: umka_shell umka_fuse umka_os umka.sym umka.prp umka.lst tags tools/mkdirran
covpreproc: covpreproc.c
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
umka_shell: umka_shell.o umka.o trace.o trace_lbr.o vdisk.o vnet.o lodepng.o pci.o thread.o
umka_shell: umka_shell.o umka.o shell.o trace.o trace_lbr.o vdisk.o vnet.o lodepng.o pci.o thread.o
$(CC) $(LDFLAGS_32) $^ -o $@ -static
umka_fuse: umka_fuse.o umka.o trace.o trace_lbr.o vdisk.o pci.o thread.o
$(CC) $(LDFLAGS_32) $^ -o $@ `pkg-config fuse3 --libs`
umka_os: umka_os.o umka.o trace.o trace_lbr.o vdisk.o pci.o thread.o
umka_os: umka_os.o umka.o shell.o lodepng.o vdisk.o vnet.o trace.o trace_lbr.o vdisk.o pci.o thread.o
$(CC) $(LDFLAGS_32) $^ -o $@ -static
umka.o umka.fas: umka.asm
INCLUDE="$(KOLIBRI)/kernel/trunk;$(KOLIBRI)/programs/develop/libraries/libcrash/trunk" $(FASM) $< umka.o -s umka.fas -m 1234567
shell.o: shell.c
$(CC) $(CFLAGS_32) -c $<
thread.o: linux/thread.c
$(CC) $(CFLAGS_32) -c $<

1796
shell.c Normal file

File diff suppressed because it is too large Load Diff

8
shell.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef SHELL_H_INCLUDED
#define SHELL_H_INCLUDED
#include <stdio.h>
void *run_test(FILE *in, FILE *out, int block);
#endif // SHELL_H_INCLUDED

View File

@ -26,7 +26,8 @@ public monitor_thread
public CURRENT_TASK as 'kos_current_task'
public current_slot as 'kos_current_slot'
public TASK_COUNT as 'kos_task_count'
public task_base_addr as 'kos_task_base'
public TASK_BASE as 'kos_task_base'
;public task_base_addr as 'kos_task_base'
public task_data_addr as 'kos_task_data'
public slot_base_addr as 'kos_slot_base'
@ -282,7 +283,7 @@ proc kos_init c uses ebx esi edi ebp
ret
endp
public idle as 'umka_idle'
public skin_udata
proc idle uses ebx esi edi
.loop:
mov ecx, 10000000
@ -542,7 +543,6 @@ macro lea r, v {
macro add r, v {
if v eq CURRENT_TASK - (SLOT_BASE shr 3)
; int3
push r
mov r, SLOT_BASE
shr r, 3

17
umka.h
View File

@ -454,10 +454,25 @@ typedef struct {
uint8_t pad[256-80];
} appdata_t;
typedef struct {
uint32_t event_mask;
uint32_t pid;
uint16_t pad1;
uint8_t state;
uint8_t pad2;
uint16_t pad3;
uint8_t wnd_number;
uint8_t pad4;
uint32_t mem_start;
uint32_t counter_sum;
uint32_t counter_add;
uint32_t cpu_usage;
} taskdata_t;
extern uint32_t kos_current_task;
extern appdata_t *kos_current_slot;
extern size_t kos_task_count;
extern void *kos_task_base;
extern taskdata_t *kos_task_base;
extern void *kos_task_data;
extern appdata_t *kos_slot_base;
extern void (*monitor_thread)(void);

View File

@ -2,9 +2,15 @@
#define __USE_GNU
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include "umka.h"
#include "thread.h"
#include "shell.h"
struct itimerval timeout = {.it_value = {.tv_sec = 0, .tv_usec = 10000}};
@ -23,19 +29,35 @@ void scheduler(int signo, siginfo_t *info, void *context) {
kos_current_task = 1;
}
} else {
printf("########## cli ############\n");
// printf("########## cli ############\n");
}
kos_current_slot = kos_slot_base + kos_current_task;
kos_task_base = ((taskdata_t*)&kos_current_task) + kos_current_task;
printf("##### kos_current_task: %u\n", kos_current_task);
setitimer(ITIMER_PROF, &timeout, NULL);
siglongjmp(*kos_slot_base[kos_current_task].fpu_state, 1);
}
}
//void intwrite(int fd,
void monitor() {
fprintf(stderr, "Start monitor thread\n");
// mkfifo("/tmp/umka.fifo.2u", 0644);
// mkfifo("/tmp/umka.fifo.4u", 0644);
FILE *fin = fopen("/tmp/umka.fifo.2u", "r");
FILE *fout = fopen("/tmp/umka.fifo.4u", "w");
// while (1) {
fprintf(stderr, "### from monitor: %d\n", fileno(fout));
// }
if (!fin || !fout) {
fprintf(stderr, "Can't open monitor files!\n");
return;
}
run_test(fin, fout, 0);
while (1) {
for (int i = 0; i < 10000000; i++) {}
printf("6 usera\n");
printf("6 monitor\n");
}
}

File diff suppressed because it is too large Load Diff