[umka_os/linux] Simulate hw interrupts via signals
This commit is contained in:
parent
566de74194
commit
ac151ef588
21
umka.asm
21
umka.asm
@ -79,6 +79,8 @@ UMKA_OS = 3
|
||||
|
||||
UMKA_MEMORY_BYTES = 256 SHL 20
|
||||
|
||||
pubsym irq_serv.irq_10, 'kos_irq_serv_irq10'
|
||||
pubsym attach_int_handler, 'kos_attach_int_handler', 12
|
||||
pubsym fs_execute, 'kos_fs_execute'
|
||||
pubsym set_keyboard_data, 'kos_set_keyboard_data'
|
||||
pubsym KEY_COUNT as 'kos_key_count'
|
||||
@ -191,6 +193,7 @@ macro sti {
|
||||
}
|
||||
|
||||
iretd equ retd
|
||||
iret equ ret
|
||||
|
||||
lang fix en
|
||||
|
||||
@ -383,7 +386,15 @@ purge call
|
||||
;include 'core/exports.inc'
|
||||
include 'core/string.inc'
|
||||
;include 'core/v86.inc'
|
||||
macro mov dst, src {
|
||||
if dst eq ds
|
||||
else if dst eq es
|
||||
else
|
||||
mov dst, src
|
||||
end if
|
||||
}
|
||||
include 'core/irq.inc'
|
||||
purge mov
|
||||
include 'core/apic.inc'
|
||||
include 'core/hpet.inc'
|
||||
include 'core/timers.inc'
|
||||
@ -535,6 +546,10 @@ proc umka_init c uses ebx esi edi ebp
|
||||
; call mem_test
|
||||
; call init_mem
|
||||
; call init_page_map
|
||||
mov [irq_mode], IRQ_APIC
|
||||
mov [IOAPIC_base], ioapic_data
|
||||
mov [LAPIC_BASE], lapic_data
|
||||
mov [ioapic_cnt], 1
|
||||
|
||||
mov [xsave_area_size], 0x1000
|
||||
|
||||
@ -724,6 +739,9 @@ proc umka_init c uses ebx esi edi ebp
|
||||
mov ebx, SLOT_BASE + 2*sizeof.APPDATA
|
||||
mov word[cur_dir.path], '/'
|
||||
mov [ebx+APPDATA.cur_dir], cur_dir
|
||||
; end of set_variables
|
||||
|
||||
call init_irqs
|
||||
|
||||
ret
|
||||
endp
|
||||
@ -1034,6 +1052,9 @@ ide_channel6_mutex MUTEX
|
||||
ide_channel7_mutex MUTEX
|
||||
ide_channel8_mutex MUTEX
|
||||
|
||||
ioapic_data rb 0x400
|
||||
lapic_data rb 0x400
|
||||
|
||||
lfb_base rd MAX_SCREEN_WIDTH*MAX_SCREEN_HEIGHT
|
||||
|
||||
align 4096
|
||||
|
6
umka.h
6
umka.h
@ -541,6 +541,12 @@ umka_mouse_move(int lbheld, int mbheld, int rbheld, int xabs, int32_t xmoving,
|
||||
STDCALL net_buff_t *
|
||||
kos_net_buff_alloc(size_t size);
|
||||
|
||||
STDCALL void
|
||||
kos_attach_int_handler(int irq, int (*handler)(void*), void *user_data);
|
||||
|
||||
void
|
||||
kos_irq_serv_irq10(void);
|
||||
|
||||
static inline int32_t
|
||||
umka_fs_execute(const char *filename) {
|
||||
// edx Flags
|
||||
|
16
umka_os.c
16
umka_os.c
@ -111,6 +111,13 @@ void handle_i40(int signo, siginfo_t *info, void *context) {
|
||||
umka_i40((pushad_t*)(ctx->uc_mcontext.__gregs + REG_EDI));
|
||||
}
|
||||
|
||||
void handle_irq_net(int signo, siginfo_t *info, void *context) {
|
||||
(void)signo;
|
||||
(void)info;
|
||||
(void)context;
|
||||
kos_irq_serv_irq10();
|
||||
}
|
||||
|
||||
int
|
||||
main() {
|
||||
if (coverage)
|
||||
@ -138,6 +145,15 @@ main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sa.sa_sigaction = handle_irq_net;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
|
||||
if (sigaction(SIGUSR1, &sa, NULL) == -1) {
|
||||
printf("Can't install SIGUSR1 handler!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void *app_base = mmap((void*)0, 16*0x100000, PROT_READ | PROT_WRITE |
|
||||
PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS,
|
||||
-1, 0);
|
||||
|
8
vnet.c
8
vnet.c
@ -17,6 +17,12 @@ typedef struct {
|
||||
int fd;
|
||||
} vnet_userdata_t;
|
||||
|
||||
int vnet_input(void *udata) {
|
||||
vnet_userdata_t *u = udata;
|
||||
fprintf(stderr, "###### vnet_input\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
net_device_t *vnet_init(int fd) {
|
||||
// printf("vnet_init\n");
|
||||
vnet_userdata_t *u = (vnet_userdata_t*)malloc(sizeof(vnet_userdata_t));
|
||||
@ -44,6 +50,8 @@ net_device_t *vnet_init(int fd) {
|
||||
.userdata = u,
|
||||
};
|
||||
|
||||
kos_attach_int_handler(SIGUSR1, vnet_input, u);
|
||||
|
||||
return vnet;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user