mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 06:58:22 +00:00
syscalls: getcpu
This commit is contained in:
@@ -94,6 +94,7 @@ extern syscall_killthread
|
|||||||
extern syscall_shutdown
|
extern syscall_shutdown
|
||||||
extern syscall_nice
|
extern syscall_nice
|
||||||
extern syscall_flock
|
extern syscall_flock
|
||||||
|
extern syscall_getcpu
|
||||||
syscalltab:
|
syscalltab:
|
||||||
dq syscall_print
|
dq syscall_print
|
||||||
dq syscall_mmap
|
dq syscall_mmap
|
||||||
@@ -190,7 +191,8 @@ dq syscall_killthread
|
|||||||
dq syscall_shutdown
|
dq syscall_shutdown
|
||||||
dq syscall_nice
|
dq syscall_nice
|
||||||
dq syscall_flock
|
dq syscall_flock
|
||||||
syscallcount equ 95
|
dq syscall_getcpu
|
||||||
|
syscallcount equ 96
|
||||||
section .text
|
section .text
|
||||||
global arch_syscall_entry
|
global arch_syscall_entry
|
||||||
; on entry:
|
; on entry:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#ifdef SYSCALL_LOGGING
|
#ifdef SYSCALL_LOGGING
|
||||||
|
|
||||||
#define SYSCALL_COUNT 95
|
#define SYSCALL_COUNT 96
|
||||||
#define LOGSTR(x) arch_e9_puts(x)
|
#define LOGSTR(x) arch_e9_puts(x)
|
||||||
|
|
||||||
static char *name[] = {
|
static char *name[] = {
|
||||||
@@ -103,7 +103,8 @@ static char *name[] = {
|
|||||||
"killthread",
|
"killthread",
|
||||||
"shutdown",
|
"shutdown",
|
||||||
"nice",
|
"nice",
|
||||||
"flock"
|
"flock",
|
||||||
|
"getcpu"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *args[] = {
|
static char *args[] = {
|
||||||
@@ -201,7 +202,8 @@ static char *args[] = {
|
|||||||
"pid %d tid %d signal %d", // killthread
|
"pid %d tid %d signal %d", // killthread
|
||||||
"how %d", // shutdown
|
"how %d", // shutdown
|
||||||
"off %d", // nice
|
"off %d", // nice
|
||||||
"fd %d op %d" // flock
|
"fd %d op %d", // flock
|
||||||
|
"N/A" // getcpu
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include <kernel/syscalls.h>
|
||||||
|
#include <arch/cpu.h>
|
||||||
|
|
||||||
|
syscallret_t syscall_getcpu(context_t *) {
|
||||||
|
syscallret_t ret = {
|
||||||
|
.errno = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t cpu_id = current_cpu_internal_id();
|
||||||
|
|
||||||
|
ret.ret = cpu_id;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -84,26 +84,21 @@ index d5ba7b2..a86353f 100644
|
|||||||
long error = syscall(SYSCALL_ARCHCTL, &ret, func, (uint64_t)arg);
|
long error = syscall(SYSCALL_ARCHCTL, &ret, func, (uint64_t)arg);
|
||||||
if(error)
|
if(error)
|
||||||
diff --git mlibc-clean/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
diff --git mlibc-clean/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
index bb85dba..5e9e21a 100644
|
index bb85dba..5f12e17 100644
|
||||||
--- mlibc-clean/sysdeps/astral/generic/generic.cpp
|
--- mlibc-clean/sysdeps/astral/generic/generic.cpp
|
||||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
@@ -31,6 +31,12 @@ namespace mlibc {
|
@@ -40,6 +40,31 @@ namespace mlibc {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ int sys_getcpu(int *cpu) {
|
+ int sys_getcpu(int *cpu) {
|
||||||
+ *cpu = 0;
|
+ long ret;
|
||||||
+ // TODO unstub
|
+ // can never fail
|
||||||
|
+ syscall(SYSCALL_GETCPU, &ret);
|
||||||
|
+ *cpu = ret;
|
||||||
+ return 0;
|
+ return 0;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
int sys_getsockopt(int fd, int layer, int number,
|
|
||||||
void *__restrict buffer, socklen_t *__restrict size) {
|
|
||||||
(void)size;
|
|
||||||
@@ -40,6 +46,23 @@ namespace mlibc {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ int sys_flock(int fd, int options) {
|
+ int sys_flock(int fd, int options) {
|
||||||
+ long r;
|
+ long r;
|
||||||
+ return syscall(SYSCALL_FLOCK, &r, fd, options);
|
+ return syscall(SYSCALL_FLOCK, &r, fd, options);
|
||||||
@@ -124,7 +119,7 @@ index bb85dba..5e9e21a 100644
|
|||||||
int sys_tgkill(int pid, int tid, int sig) {
|
int sys_tgkill(int pid, int tid, int sig) {
|
||||||
long ret;
|
long ret;
|
||||||
return syscall(SYSCALL_KILLTHREAD, &ret, pid, tid, sig);
|
return syscall(SYSCALL_KILLTHREAD, &ret, pid, tid, sig);
|
||||||
@@ -161,7 +184,18 @@ namespace mlibc {
|
@@ -161,7 +186,18 @@ namespace mlibc {
|
||||||
*bytes_written = writec;
|
*bytes_written = writec;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -144,7 +139,7 @@ index bb85dba..5e9e21a 100644
|
|||||||
#ifndef MLIBC_BUILDING_RTLD
|
#ifndef MLIBC_BUILDING_RTLD
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -376,6 +410,12 @@ namespace mlibc {
|
@@ -376,6 +412,12 @@ namespace mlibc {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +152,7 @@ index bb85dba..5e9e21a 100644
|
|||||||
#ifndef MLIBC_BUILDING_RTLD
|
#ifndef MLIBC_BUILDING_RTLD
|
||||||
|
|
||||||
[[noreturn]] void sys_thread_exit() {
|
[[noreturn]] void sys_thread_exit() {
|
||||||
@@ -771,7 +811,7 @@ namespace mlibc {
|
@@ -771,7 +813,7 @@ namespace mlibc {
|
||||||
|
|
||||||
int sys_tcb_set(void *pointer) {
|
int sys_tcb_set(void *pointer) {
|
||||||
long r;
|
long r;
|
||||||
@@ -184,16 +179,17 @@ index d738e02..7e4f2a1 100644
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
diff --git mlibc-clean/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
diff --git mlibc-clean/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
index 5f42d62..6fbb253 100644
|
index 5f42d62..8414286 100644
|
||||||
--- mlibc-clean/sysdeps/astral/include/astral/syscall.h
|
--- mlibc-clean/sysdeps/astral/include/astral/syscall.h
|
||||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
@@ -96,6 +96,9 @@
|
@@ -96,6 +96,10 @@
|
||||||
#define SYSCALL_SIGTIMEDWAIT 89
|
#define SYSCALL_SIGTIMEDWAIT 89
|
||||||
#define SYSCALL_SIGPENDING 90
|
#define SYSCALL_SIGPENDING 90
|
||||||
#define SYSCALL_KILLTHREAD 91
|
#define SYSCALL_KILLTHREAD 91
|
||||||
+#define SYSCALL_SHUTDOWN 92
|
+#define SYSCALL_SHUTDOWN 92
|
||||||
+#define SYSCALL_NICE 93
|
+#define SYSCALL_NICE 93
|
||||||
+#define SYSCALL_FLOCK 94
|
+#define SYSCALL_FLOCK 94
|
||||||
|
+#define SYSCALL_GETCPU 95
|
||||||
|
|
||||||
#ifndef __MLIBC_ABI_ONLY
|
#ifndef __MLIBC_ABI_ONLY
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user