void
console_view_down();
+void
+console_flush(void* arg);
+
void
console_start_flushing();
#endif /* __LUNAIX_LXCONSOLE_H */
__LXSYSCALL2(int, signal, int, signum, sighandler_t, handler);
+__LXSYSCALL1(int, sigpending, sigset_t, *set);
+__LXSYSCALL1(int, sigsuspend, const sigset_t, *mask);
+
__LXSYSCALL3(int,
sigprocmask,
int,
#define __SYSCALL_pause 14
#define __SYSCALL_kill 15
#define __SYSCALL_alarm 16
+#define __SYSCALL_sigpending 17
+#define __SYSCALL_sigsuspend 18
#define __SYSCALL_MAX 0x100
struct fifo_buffer buffer;
unsigned int erd_pos;
unsigned int lines;
- unsigned int chars;
};
#endif /* __LUNAIX_CONSOLE_H */
soft_iret:
movl %eax, %esp
+#ifdef __ASM_INTR_DIAGNOSIS
+ movl 56(%esp), %eax
+ movl %eax, (debug_resv + 4)
+#endif
+
popl %eax
popl %ebx
popl %ecx
#include <arch/x86/interrupts.h>
+#include <lunaix/lxconsole.h>
#include <lunaix/process.h>
#include <lunaix/spike.h>
#include <lunaix/syslog.h>
void
intr_routine_general_protection(const isr_param* param)
{
+ kprintf(KERROR "Pid: %d\n", __current->pid);
kprintf(KERROR "Addr: %p\n", (&debug_resv)[0]);
- kprintf(KERROR "Expected: %p\n", __current->intr_ctx.eip);
+ kprintf(KERROR "Expected: %p\n", (&debug_resv)[1]);
+ console_flush(0);
__print_panic_msg("General Protection", param);
spin();
}
.long __lxsys_pause
.long __lxsys_kill /* 15 */
.long __lxsys_alarm
+ .long __lxsys_sigpending
+ .long __lxsys_sigsuspend
2:
.rept __SYSCALL_MAX - (2b - 1b)/4
.long 0
kprintf(KWARN "I, pid %d, have received an alarm!\n", pid);
}
+// FIXME: Race condition with signal (though rare!)
+// For some reason, there is a chance that iret in soft_iret path
+// get unhappy when return from signal handler. Investigation is needed!
+
void __USER__
_signal_demo_main()
{
kprintf("done\n");
- spin();
+ _exit(0);
}
\ No newline at end of file
static struct console lx_console;
-volatile int can_flush = 0;
-
void
lxconsole_init()
{
}
void
-__flush_cb(void* arg)
+console_flush(void* arg)
{
if (mutex_on_hold(&lx_console.buffer.lock)) {
return;
for (size_t i = 0; i < size; i++) {
c = data[i];
buffer[(ptr + i) % console->buffer.size] = c;
- // chars += (31 < c && c < 127);
lines += (c == '\n');
}
console_start_flushing()
{
struct lx_timer* timer =
- timer_run_ms(20, __flush_cb, NULL, TIMER_MODE_PERIODIC);
+ timer_run_ms(20, console_flush, NULL, TIMER_MODE_PERIODIC);
lx_console.flush_timer = timer;
}
\ No newline at end of file
#include <hal/cpu.h>
#include <lunaix/clock.h>
-#include <lunaix/keyboard.h>
#include <lunaix/lunistd.h>
#include <lunaix/lxconsole.h>
#include <lunaix/mm/kalloc.h>
cpu_get_brand(buf);
kprintf("CPU: %s\n\n", buf);
- // no lxmalloc here! This can only be used within kernel, but here, we are
- // in a dedicated process! any access to kernel method must be done via
- // syscall
-
- struct kdb_keyinfo_pkt keyevent;
- while (1) {
- if (!kbd_recv_key(&keyevent)) {
- yield();
- continue;
- }
- if ((keyevent.state & KBD_KEY_FPRESSED)) {
- if ((keyevent.keycode & 0xff00) <= KEYPAD) {
- console_write_char((char)(keyevent.keycode & 0x00ff));
- } else if (keyevent.keycode == KEY_UP) {
- console_view_up();
- } else if (keyevent.keycode == KEY_DOWN) {
- console_view_down();
- }
- }
- }
- spin();
+ _exit(0);
}
\ No newline at end of file
void
__do_reserved_memory(int unlock);
-//#define DEMO_SIGNAL
+#define DEMO_SIGNAL
+
+extern void
+_pconsole_main();
+
+extern void
+_signal_demo_main();
+
+extern void
+_lxinit_main();
void __USER__
__proc0_usr()
{
+ pid_t p;
if (!fork()) {
+ _pconsole_main();
+ }
+
+ if (!(p = fork())) {
#ifdef DEMO_SIGNAL
- asm("jmp _signal_demo_main");
+ _signal_demo_main();
#else
- asm("jmp _lxinit_main");
+ _lxinit_main();
#endif
}
+ // waitpid(p, 0, 0);
+
while (1) {
yield();
}
done:
cpu_disable_interrupt();
status_flags |= PEXITSIG * (proc->sig_inprogress != 0);
- *status = proc->exit_code | status_flags;
+ if (status) {
+ *status = proc->exit_code | status_flags;
+ }
return destroy_process(proc->pid);
}
--- /dev/null
+#include <lunaix/keyboard.h>
+#include <lunaix/lxconsole.h>
+#include <lunaix/proc.h>
+
+void
+_pconsole_main()
+{
+ struct kdb_keyinfo_pkt keyevent;
+ while (1) {
+ if (!kbd_recv_key(&keyevent)) {
+ yield();
+ continue;
+ }
+ if ((keyevent.state & KBD_KEY_FPRESSED)) {
+ if ((keyevent.keycode & 0xff00) <= KEYPAD) {
+ console_write_char((char)(keyevent.keycode & 0x00ff));
+ } else if (keyevent.keycode == KEY_UP) {
+ console_view_up();
+ } else if (keyevent.keycode == KEY_DOWN) {
+ console_view_down();
+ }
+ }
+ }
+}
\ No newline at end of file
return 0;
}
-__DEFINE_LXSYSCALL(int, pause)
+void
+__do_pause()
{
__current->flags |= PROC_FINPAUSE;
}
})
__current->k_status = EINTR;
+}
+
+__DEFINE_LXSYSCALL(int, pause)
+{
+ __do_pause();
return -1;
}
__DEFINE_LXSYSCALL2(int, kill, pid_t, pid, int, signum)
{
return signal_send(pid, signum);
+}
+
+__DEFINE_LXSYSCALL1(int, sigpending, sigset_t, *sigset)
+{
+ *sigset = __current->sig_pending;
+ return 0;
+}
+
+__DEFINE_LXSYSCALL1(int, sigsuspend, sigset_t, *mask)
+{
+ sigset_t tmp = __current->sig_mask;
+ __current->sig_mask = (*mask) & ~_SIGNAL_UNMASKABLE;
+ __do_pause();
+ __current->sig_mask = tmp;
+ return -1;
}
\ No newline at end of file