1
- From 791ffe535a74e6df0809459c5283ac80c46d0d6c Mon Sep 17 00:00:00 2001
1
+ From ef88dca94b8e13b78bdd0dc71df8b6062009c6f0 Mon Sep 17 00:00:00 2001
2
2
3
3
Date: Sun, 6 Jun 2021 16:37:54 +1000
4
4
Subject: [PATCH] targets: add aero target port
5
5
6
6
Signed-off-by: Andy-Python-Programmer <
[email protected] >
7
7
---
8
- .gitignore | 6 +
8
+ .gitignore | 7 +
9
9
abis/aero/auxv.h | 13 +
10
10
meson.build | 4 +
11
11
options/ansi/generic/stdlib-stubs.cpp | 3 +
46
46
sysdeps/aero/include/abi-bits/uid_t.h | 1 +
47
47
sysdeps/aero/include/abi-bits/vm-flags.h | 1 +
48
48
sysdeps/aero/include/abi-bits/wait.h | 1 +
49
- sysdeps/aero/include/aero/syscall.h | 192 ++++++++++++++
49
+ sysdeps/aero/include/aero/syscall.h | 194 ++++++++++++++
50
50
sysdeps/aero/include/mlibc/thread-entry.hpp | 10 +
51
51
sysdeps/aero/meson.build | 67 +++++
52
52
sysdeps/dripos/generic/generic.cpp | 3 +
53
53
sysdeps/lemon/generic/signals.S | 7 +
54
- 46 files changed, 1022 insertions(+), 11 deletions(-)
54
+ 46 files changed, 1025 insertions(+), 11 deletions(-)
55
55
create mode 100644 abis/aero/auxv.h
56
56
create mode 100644 sysdeps/aero/crt-x86_64/crt0.S
57
57
create mode 100644 sysdeps/aero/generic/aero.cc
93
93
create mode 100644 sysdeps/lemon/generic/signals.S
94
94
95
95
diff --git a/.gitignore b/.gitignore
96
- index 1701c90..6e0116b 100644
96
+ index 1701c90..dbb35e8 100644
97
97
--- a/.gitignore
98
98
+++ b/.gitignore
99
- @@ -1,3 +1,9 @@
99
+ @@ -1,3 +1,10 @@
100
100
build
101
101
+
102
102
+ # the menson vsocde extension auto generates another build directory
@@ -106,7 +106,7 @@ index 1701c90..6e0116b 100644
106
106
subprojects/cxxshim
107
107
subprojects/frigg
108
108
+ .vscode
109
- \ No newline at end of file
109
+ + .clang-format
110
110
diff --git a/abis/aero/auxv.h b/abis/aero/auxv.h
111
111
new file mode 100644
112
112
index 0000000..59d4d4d
@@ -1170,10 +1170,10 @@ index 0000000..6d911c7
1170
1170
\ No newline at end of file
1171
1171
diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h
1172
1172
new file mode 100644
1173
- index 0000000..d3fe862
1173
+ index 0000000..ef9f036
1174
1174
--- /dev/null
1175
1175
+++ b/sysdeps/aero/include/aero/syscall.h
1176
- @@ -0,0 +1,192 @@
1176
+ @@ -0,0 +1,194 @@
1177
1177
+ #ifndef SYSCALL_H
1178
1178
+ #define SYSCALL_H
1179
1179
+
@@ -1229,141 +1229,143 @@ index 0000000..d3fe862
1229
1229
+ // Invalid syscall used to trigger a log error in the kernel (as a hint)
1230
1230
+ // so, that we can implement the syscall in the kernel.
1231
1231
+ #define UNIMPLEMENTED(FUNCTION_NAME) \
1232
- + { \
1233
- + syscall(314, FUNCTION_NAME, strlen( FUNCTION_NAME)); \
1234
- + __ensure(!"UNIMPLEMENTED function was called"); \
1235
- + __builtin_unreachable(); \
1236
- + }
1232
+ + { \
1233
+ + sys_libc_log("Unimplemented syscall: " FUNCTION_NAME); \
1234
+ + sys_exit(1); \
1235
+ + __builtin_unreachable(); \
1236
+ + }
1237
1237
+
1238
1238
+ extern "C" {
1239
1239
+ using sc_word_t = long;
1240
1240
+
1241
1241
+ static sc_word_t syscall0(int sc) {
1242
- + sc_word_t ret;
1243
- + asm volatile("syscall" : "=a"(ret) : "a"(sc) : "rcx", "r11", "memory");
1244
- + return ret;
1242
+ + sc_word_t ret;
1243
+ + asm volatile("syscall" : "=a"(ret) : "a"(sc) : "rcx", "r11", "memory");
1244
+ + return ret;
1245
1245
+ }
1246
1246
+
1247
1247
+ static sc_word_t syscall1(int sc, sc_word_t arg1) {
1248
- + sc_word_t ret;
1249
- + asm volatile("syscall"
1250
- + : "=a"(ret)
1251
- + : "a"(sc), "D"(arg1)
1252
- + : "rcx", "r11", "memory");
1253
- + return ret;
1248
+ + sc_word_t ret;
1249
+ + asm volatile("syscall"
1250
+ + : "=a"(ret)
1251
+ + : "a"(sc), "D"(arg1)
1252
+ + : "rcx", "r11", "memory");
1253
+ + return ret;
1254
1254
+ }
1255
1255
+
1256
1256
+ static sc_word_t syscall2(int sc, sc_word_t arg1, sc_word_t arg2) {
1257
- + sc_word_t ret;
1258
- + asm volatile("syscall"
1259
- + : "=a"(ret)
1260
- + : "a"(sc), "D"(arg1), "S"(arg2)
1261
- + : "rcx", "r11", "memory");
1262
- + return ret;
1257
+ + sc_word_t ret;
1258
+ + asm volatile("syscall"
1259
+ + : "=a"(ret)
1260
+ + : "a"(sc), "D"(arg1), "S"(arg2)
1261
+ + : "rcx", "r11", "memory");
1262
+ + return ret;
1263
1263
+ }
1264
1264
+
1265
1265
+ static sc_word_t syscall3(int sc, sc_word_t arg1, sc_word_t arg2,
1266
- + sc_word_t arg3) {
1267
- + sc_word_t ret;
1268
- + asm volatile("syscall"
1269
- + : "=a"(ret)
1270
- + : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3)
1271
- + : "rcx", "r11", "memory");
1272
- + return ret;
1266
+ + sc_word_t arg3) {
1267
+ + sc_word_t ret;
1268
+ + asm volatile("syscall"
1269
+ + : "=a"(ret)
1270
+ + : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3)
1271
+ + : "rcx", "r11", "memory");
1272
+ + return ret;
1273
1273
+ }
1274
1274
+
1275
1275
+ static sc_word_t syscall4(int sc, sc_word_t arg1, sc_word_t arg2,
1276
- + sc_word_t arg3, sc_word_t arg4) {
1277
- + sc_word_t ret;
1276
+ + sc_word_t arg3, sc_word_t arg4) {
1277
+ + sc_word_t ret;
1278
1278
+
1279
- + register sc_word_t arg4_reg asm("r10") = arg4;
1279
+ + register sc_word_t arg4_reg asm("r10") = arg4;
1280
1280
+
1281
- + asm volatile("syscall"
1282
- + : "=a"(ret)
1283
- + : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg)
1284
- + : "rcx", "r11", "memory");
1285
- + return ret;
1281
+ + asm volatile("syscall"
1282
+ + : "=a"(ret)
1283
+ + : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg)
1284
+ + : "rcx", "r11", "memory");
1285
+ + return ret;
1286
1286
+ }
1287
1287
+
1288
1288
+ static sc_word_t syscall5(int sc, sc_word_t arg1, sc_word_t arg2,
1289
- + sc_word_t arg3, sc_word_t arg4, sc_word_t arg5) {
1290
- + sc_word_t ret;
1289
+ + sc_word_t arg3, sc_word_t arg4, sc_word_t arg5) {
1290
+ + sc_word_t ret;
1291
1291
+
1292
- + register sc_word_t arg4_reg asm("r10") = arg4;
1293
- + register sc_word_t arg5_reg asm("r8") = arg5;
1292
+ + register sc_word_t arg4_reg asm("r10") = arg4;
1293
+ + register sc_word_t arg5_reg asm("r8") = arg5;
1294
1294
+
1295
- + asm volatile("syscall"
1296
- + : "=a"(ret)
1297
- + : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg),
1298
- + "r"(arg5_reg)
1299
- + : "rcx", "r11", "memory");
1300
- + return ret;
1295
+ + asm volatile("syscall"
1296
+ + : "=a"(ret)
1297
+ + : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg),
1298
+ + "r"(arg5_reg)
1299
+ + : "rcx", "r11", "memory");
1300
+ + return ret;
1301
1301
+ }
1302
1302
+
1303
1303
+ static sc_word_t syscall6(int sc, sc_word_t arg1, sc_word_t arg2,
1304
- + sc_word_t arg3, sc_word_t arg4, sc_word_t arg5,
1305
- + sc_word_t arg6) {
1306
- + sc_word_t ret;
1304
+ + sc_word_t arg3, sc_word_t arg4, sc_word_t arg5,
1305
+ + sc_word_t arg6) {
1306
+ + sc_word_t ret;
1307
1307
+
1308
- + register sc_word_t arg4_reg asm("r10") = arg4;
1309
- + register sc_word_t arg5_reg asm("r8") = arg5;
1310
- + register sc_word_t arg6_reg asm("r9") = arg6;
1308
+ + register sc_word_t arg4_reg asm("r10") = arg4;
1309
+ + register sc_word_t arg5_reg asm("r8") = arg5;
1310
+ + register sc_word_t arg6_reg asm("r9") = arg6;
1311
1311
+
1312
- + asm volatile("syscall"
1313
- + : "=a"(ret)
1314
- + : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg),
1315
- + "r"(arg5_reg), "r"(arg6_reg)
1316
- + : "rcx", "r11", "memory");
1317
- + return ret;
1312
+ + asm volatile("syscall"
1313
+ + : "=a"(ret)
1314
+ + : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg),
1315
+ + "r"(arg5_reg), "r"(arg6_reg)
1316
+ + : "rcx", "r11", "memory");
1317
+ + return ret;
1318
1318
+ }
1319
1319
+ } // extern "C"
1320
1320
+
1321
1321
+ // Cast to the argument type of the extern "C" functions.
1322
1322
+ __attribute__((always_inline)) inline sc_word_t sc_cast(long x) { return x; }
1323
- + __attribute__((always_inline)) inline sc_word_t sc_cast(const void *x) { return reinterpret_cast<sc_word_t>(x); }
1323
+ + __attribute__((always_inline)) inline sc_word_t sc_cast(const void *x) {
1324
+ + return reinterpret_cast<sc_word_t>(x);
1325
+ + }
1324
1326
+
1325
1327
+ // C++ wrappers for the extern "C" functions.
1326
1328
+ __attribute__((always_inline)) static inline long _syscall(int call) {
1327
- + return syscall0(call);
1329
+ + return syscall0(call);
1328
1330
+ }
1329
1331
+
1330
- + __attribute__((always_inline))
1331
- + static inline long _syscall(int call, sc_word_t arg0) {
1332
- + return syscall1(call, arg0);
1332
+ + __attribute__((always_inline)) static inline long _syscall(int call,
1333
+ + sc_word_t arg0) {
1334
+ + return syscall1(call, arg0);
1333
1335
+ }
1334
1336
+
1335
1337
+ __attribute__((always_inline)) static inline long
1336
1338
+ _syscall(int call, sc_word_t arg0, sc_word_t arg1) {
1337
- + return syscall2(call, arg0, arg1);
1339
+ + return syscall2(call, arg0, arg1);
1338
1340
+ }
1339
1341
+
1340
1342
+ __attribute__((always_inline)) static inline long
1341
1343
+ _syscall(int call, sc_word_t arg0, sc_word_t arg1, sc_word_t arg2) {
1342
- + return syscall3(call, arg0, arg1, arg2);
1344
+ + return syscall3(call, arg0, arg1, arg2);
1343
1345
+ }
1344
1346
+
1345
1347
+ __attribute__((always_inline)) static inline long
1346
1348
+ _syscall(int call, sc_word_t arg0, sc_word_t arg1, sc_word_t arg2,
1347
- + sc_word_t arg3) {
1348
- + return syscall4(call, arg0, arg1, arg2, arg3);
1349
+ + sc_word_t arg3) {
1350
+ + return syscall4(call, arg0, arg1, arg2, arg3);
1349
1351
+ }
1350
1352
+
1351
1353
+ __attribute__((always_inline)) static inline long
1352
1354
+ _syscall(int call, sc_word_t arg0, sc_word_t arg1, sc_word_t arg2,
1353
- + sc_word_t arg3, sc_word_t arg4) {
1354
- + return syscall5(call, arg0, arg1, arg2, arg3, arg4);
1355
+ + sc_word_t arg3, sc_word_t arg4) {
1356
+ + return syscall5(call, arg0, arg1, arg2, arg3, arg4);
1355
1357
+ }
1356
1358
+
1357
1359
+ __attribute__((always_inline)) static inline long
1358
1360
+ _syscall(int call, sc_word_t arg0, sc_word_t arg1, sc_word_t arg2,
1359
- + sc_word_t arg3, sc_word_t arg4, sc_word_t arg5) {
1360
- + return syscall6(call, arg0, arg1, arg2, arg3, arg4, arg5);
1361
+ + sc_word_t arg3, sc_word_t arg4, sc_word_t arg5) {
1362
+ + return syscall6(call, arg0, arg1, arg2, arg3, arg4, arg5);
1361
1363
+ }
1362
1364
+
1363
1365
+ template <typename... T>
1364
1366
+ __attribute__((always_inline)) static inline long syscall(sc_word_t call,
1365
- + T... args) {
1366
- + return _syscall(call, sc_cast(args)...);
1367
+ + T... args) {
1368
+ + return _syscall(call, sc_cast(args)...);
1367
1369
+ }
1368
1370
+ #endif // SYSCALL_H
1369
1371
diff --git a/sysdeps/aero/include/mlibc/thread-entry.hpp b/sysdeps/aero/include/mlibc/thread-entry.hpp
0 commit comments