mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Add a sys$exit and make init_stage2 call it when finished.
This commit is contained in:
parent
79ffdb7205
commit
3a3c57357c
Notes:
sideshowbarker
2024-07-19 18:45:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3a3c57357c9
5 changed files with 35 additions and 3 deletions
|
@ -77,6 +77,10 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3)
|
|||
return current->sys$kill((pid_t)arg1, (int)arg2);
|
||||
case Syscall::PosixGetuid:
|
||||
return current->sys$getuid();
|
||||
case Syscall::PosixExit:
|
||||
current->sys$exit((int)arg1);
|
||||
ASSERT_NOT_REACHED();
|
||||
return 0;
|
||||
default:
|
||||
kprintf("int0x80: Unknown function %x requested {%x, %x, %x}\n", function, arg1, arg2, arg3);
|
||||
break;
|
||||
|
|
|
@ -16,6 +16,7 @@ enum Function {
|
|||
PosixSeek = 0x1988,
|
||||
PosixKill = 0x1989,
|
||||
PosixGetuid = 0x1990,
|
||||
PosixExit = 0x1991,
|
||||
};
|
||||
|
||||
void initialize();
|
||||
|
@ -23,21 +24,21 @@ void initialize();
|
|||
inline DWORD invoke(DWORD function)
|
||||
{
|
||||
DWORD result;
|
||||
asm("int $0x80":"=a"(result):"a"(function));
|
||||
asm volatile("int $0x80":"=a"(result):"a"(function));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline DWORD invoke(DWORD function, DWORD arg1)
|
||||
{
|
||||
DWORD result;
|
||||
asm("int $0x80":"=a"(result):"a"(function),"d"(arg1));
|
||||
asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1));
|
||||
return result;
|
||||
}
|
||||
|
||||
inline DWORD invoke(DWORD function, DWORD arg1, DWORD arg2)
|
||||
{
|
||||
DWORD result;
|
||||
asm("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2));
|
||||
asm volatile("int $0x80":"=a"(result):"a"(function),"d"(arg1),"c"(arg2));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -235,6 +235,26 @@ void Task::dumpRegions()
|
|||
}
|
||||
}
|
||||
|
||||
void Task::sys$exit(int status)
|
||||
{
|
||||
cli();
|
||||
kprintf("sys$exit: %s(%u) exit with status %d\n", name().characters(), pid(), status);
|
||||
|
||||
setState(Exiting);
|
||||
dumpRegions();
|
||||
|
||||
s_tasks->remove(this);
|
||||
|
||||
if (!scheduleNewTask()) {
|
||||
kprintf("Task::taskDidCrash: Failed to schedule a new task :(\n");
|
||||
HANG;
|
||||
}
|
||||
|
||||
delete this;
|
||||
|
||||
switchNow();
|
||||
}
|
||||
|
||||
void Task::taskDidCrash(Task* crashedTask)
|
||||
{
|
||||
// NOTE: This is called from an excepton handler, so interrupts are disabled.
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
BlockedSleep = 5,
|
||||
Terminated = 6,
|
||||
Crashing = 7,
|
||||
Exiting = 8,
|
||||
};
|
||||
|
||||
enum RingLevel {
|
||||
|
@ -83,6 +84,7 @@ public:
|
|||
int sys$kill(pid_t pid, int sig);
|
||||
int sys$geterror() { return m_error; }
|
||||
void sys$sleep(DWORD ticks);
|
||||
void sys$exit(int status);
|
||||
|
||||
struct
|
||||
{
|
||||
|
|
|
@ -192,6 +192,11 @@ static void init_stage2()
|
|||
|
||||
kprintf("init stage2 is done!\n");
|
||||
|
||||
DO_SYSCALL_A1(Syscall::PosixExit, 413);
|
||||
|
||||
kprintf("uh, we're still going after calling sys$exit...\n");
|
||||
HANG;
|
||||
|
||||
for (;;) {
|
||||
asm("hlt");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue