diff --git a/meson.build b/meson.build index 31c81fde..4ff310b9 100644 --- a/meson.build +++ b/meson.build @@ -20,7 +20,6 @@ rtdl_deps = [ ] headers_only = get_option('headers_only') no_headers = get_option('mlibc_no_headers') -static = get_option('static') disable_ansi_option = false disable_posix_option = false disable_linux_option = false @@ -181,58 +180,30 @@ subdir('options/glibc') subdir('options/linux') if not headers_only - if not static - ldso_lib = shared_library('ld', rtdl_sources, - name_prefix: '', - cpp_args: ['-fvisibility=hidden', '-DMLIBC_BUILDING_RTDL', '-DFRIGG_HAVE_LIBC'], - include_directories: rtdl_include_dirs, - dependencies: rtdl_deps, - install: true) + ldso_lib = shared_library('ld', rtdl_sources, + name_prefix: '', + cpp_args: ['-fvisibility=hidden', '-DMLIBC_BUILDING_RTDL', '-DFRIGG_HAVE_LIBC'], + include_directories: rtdl_include_dirs, + dependencies: rtdl_deps, + install: true) - shared_library('c', - [ - libc_sources, - internal_sources, - ansi_sources, - lsb_sources, - ], - cpp_args: ['-DFRIGG_HAVE_LIBC'], - include_directories: libc_include_dirs, - dependencies: libc_deps, - link_with: [ldso_lib], - link_whole: libc_sublibs, - install: true) + shared_library('c', + [ + libc_sources, + internal_sources, + ansi_sources, + lsb_sources, + ], + cpp_args: ['-DFRIGG_HAVE_LIBC'], + include_directories: libc_include_dirs, + dependencies: libc_deps, + link_with: [ldso_lib], + link_whole: libc_sublibs, + install: true) - shared_library('dl', 'libdl/src/dummy.cpp', install: true) - shared_library('pthread', 'libpthread/src/dummy.cpp', install: true) - shared_library('rt', 'librt/src/dummy.cpp', install: true) - shared_library('util', 'libutil/src/dummy.cpp', install: true) - shared_library('m', 'libm/src/dummy.cpp', install: true) - else - ldso_lib = static_library('ld', rtdl_sources, - name_prefix: '', - cpp_args: ['-fvisibility=hidden', '-DMLIBC_BUILDING_RTDL', '-DFRIGG_HAVE_LIBC'], - include_directories: rtdl_include_dirs, - dependencies: rtdl_deps, - install: true) - - static_library('c', - [ - libc_sources, - internal_sources, - ansi_sources, - ], - cpp_args: ['-DFRIGG_HAVE_LIBC'], - include_directories: libc_include_dirs, - dependencies: libc_deps, - link_with: [ldso_lib], - link_whole: libc_sublibs, - install: true) - - static_library('dl', 'libdl/src/dummy.cpp', install: true) - static_library('pthread', 'libpthread/src/dummy.cpp', install: true) - static_library('rt', 'librt/src/dummy.cpp', install: true) - static_library('util', 'libutil/src/dummy.cpp', install: true) - static_library('m', 'libm/src/dummy.cpp', install: true) - endif + shared_library('dl', 'libdl/src/dummy.cpp', install: true) + shared_library('pthread', 'libpthread/src/dummy.cpp', install: true) + shared_library('rt', 'librt/src/dummy.cpp', install: true) + shared_library('util', 'libutil/src/dummy.cpp', install: true) + shared_library('m', 'libm/src/dummy.cpp', install: true) endif diff --git a/meson_options.txt b/meson_options.txt index fad4b26b..45b7a703 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,2 @@ option('headers_only', type : 'boolean', value : false) option('mlibc_no_headers', type : 'boolean', value : false) -option('static', type : 'boolean', value : false) diff --git a/sysdeps/lemon/generic/exit.c b/sysdeps/lemon/generic/exit.c deleted file mode 100755 index ee688380..00000000 --- a/sysdeps/lemon/generic/exit.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/lemon/generic/fb.c b/sysdeps/lemon/generic/fb.c deleted file mode 100644 index 11bfb67d..00000000 --- a/sysdeps/lemon/generic/fb.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -uint8_t* lemon_map_fb(struct FBInfo* fbInfo){ - uint8_t* ptr = 0; - syscall(SYS_MAP_FB,&ptr,fbInfo,0,0,0); - return ptr; -} - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/sysdeps/lemon/generic/filesystem.cpp b/sysdeps/lemon/generic/filesystem.cpp index 7ee7eb1c..f73bdcaf 100644 --- a/sysdeps/lemon/generic/filesystem.cpp +++ b/sysdeps/lemon/generic/filesystem.cpp @@ -49,13 +49,11 @@ namespace mlibc{ return 0; } - #warning finish filesystem sysdeps int sys_close(int fd){ lemon_close(fd); return 0; } - #warning Properly Implement access() int sys_access(const char* filename, int mode){ int ret = lemon_open(filename, 0); diff --git a/sysdeps/lemon/generic/ipc.c b/sysdeps/lemon/generic/ipc.c deleted file mode 100755 index 0584f34f..00000000 --- a/sysdeps/lemon/generic/ipc.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -uint64_t ReceiveMessage(ipc_message_t* msg){ - uint64_t queue_size; - syscall(SYS_RECEIVE_MESSAGE, msg /*Pointer to message*/, &queue_size /*Pointer to value with amount of messages in queue*/, 0, 0, 0); - return queue_size; -} - -void SendMessage(uint64_t pid, ipc_message_t msg){ - uint64_t m = msg.msg; - uint64_t data = msg.data; - uint64_t data2 = msg.data2; - - syscall(SYS_SEND_MESSAGE, pid /*Target PID*/, m /*Message ID*/, data/*Message Data*/, data2/*Second Message Data*/, 0); -} \ No newline at end of file diff --git a/sysdeps/lemon/generic/itoa.c b/sysdeps/lemon/generic/itoa.c deleted file mode 100644 index 2ae27103..00000000 --- a/sysdeps/lemon/generic/itoa.c +++ /dev/null @@ -1,48 +0,0 @@ -#include - -void reverse(char *str, int length) -{ - int c; - char *begin, *end, temp; - - begin = str; - end = str; - - for (c = 0; c < length - 1; c++) - end++; - - for (c = 0; c < length/2; c++) - { - temp = *end; - *end = *begin; - *begin = temp; - - begin++; - end--; - } -} - -char* itoa(long num, char* str, int base) -{ - int i = 0; - - if (num == 0) - { - str[i++] = '0'; - str[i] = '\0'; - return str; - } - - while (num != 0) - { - int rem = num % base; - str[i++] = (rem > 9) ? (rem - 10) + 'a' : rem + '0'; - num = num / base; - } - - str[i] = '\0'; - - reverse(str, i); - - return str; -} \ No newline at end of file diff --git a/sysdeps/lemon/generic/lemon.c b/sysdeps/lemon/generic/lemon.c deleted file mode 100755 index b6c636ea..00000000 --- a/sysdeps/lemon/generic/lemon.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -char* lemon_uname(char* string){ - syscall(SYS_UNAME, string, 0, 0, 0, 0); - return string; -} diff --git a/sysdeps/lemon/generic/lemon.cpp b/sysdeps/lemon/generic/lemon.cpp index 1037c8dc..019180cf 100644 --- a/sysdeps/lemon/generic/lemon.cpp +++ b/sysdeps/lemon/generic/lemon.cpp @@ -1,10 +1,12 @@ #include #include #include +#include namespace mlibc{ + void sys_exit(int status){ - syscall(SYS_EXIT, 0, 0, 0, 0, 0); + syscall(SYS_EXIT, status, 0, 0, 0, 0); } int sys_anon_allocate(size_t size, void **pointer) { @@ -25,6 +27,14 @@ namespace mlibc{ *((int*)0xffffDEADDEADDEAD) = 1; // Force Page Fault for(;;); } + + pid_t sys_getpid(){ + uint64_t _pid; + syscall(SYS_GETPID, (uintptr_t)&_pid, 0, 0, 0, 0); + + pid_t pid = _pid; + return pid; + } } extern "C" int __cxa_atexit(){ @@ -34,3 +44,7 @@ extern "C" int __cxa_atexit(){ void __mlibc_do_finalize(){ } + +extern "C" int lemon_spawn(const char* path){ + syscall(SYS_EXEC, (uintptr_t)path, 0, 0, 0, 0); +} diff --git a/sysdeps/lemon/generic/process.c b/sysdeps/lemon/generic/process.c deleted file mode 100755 index 7f0a66ce..00000000 --- a/sysdeps/lemon/generic/process.c +++ /dev/null @@ -1,13 +0,0 @@ -#include - -int lemon_spawn(char* path){ - syscall(SYS_EXEC, path, 0, 0, 0, 0); -} - -int lemon_spawnv(char* path, const char* argv[]){ - -} - -int lemon_kill(int pid){ - -} diff --git a/sysdeps/lemon/include/lemon/fb.h b/sysdeps/lemon/include/lemon/fb.h deleted file mode 100755 index ce5d7576..00000000 --- a/sysdeps/lemon/include/lemon/fb.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef FB_H -#define FB_H - -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -typedef struct FBInfo{ - uint32_t width; // Resolution width - uint32_t height; // Resolution height - uint16_t bpp; // Resolution depth/bits per pixel - - uint32_t pitch; // Video mode pitch -} __attribute__((packed)) fb_info_t; - -uint8_t* lemon_map_fb(struct FBInfo* fbInfo); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/sysdeps/lemon/include/lemon/ipc.h b/sysdeps/lemon/include/lemon/ipc.h deleted file mode 100755 index 103f2af3..00000000 --- a/sysdeps/lemon/include/lemon/ipc.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef IPC_H -#define IPC_H - -#define WINDOW_EVENT_KEY 1 -#define WINDOW_EVENT_MOUSEDOWN 2 -#define WINDOW_EVENT_MOUSEUP 3 -#define WINDOW_EVENT_KEYRELEASED 4 -#define WINDOW_EVENT_CLOSE 5 - -#define DESKTOP_EVENT 0xBEEF - #define DESKTOP_SUBEVENT_WINDOW_DESTROYED 1 - #define DESKTOP_SUBEVENT_WINDOW_CREATED 2 -#define DESKTOP_EVENT_KEY 0x1BEEF -#define DESKTOP_EVENT_KEY_RELEASED 0x2BEEF - -typedef struct { - uint64_t senderPID; // PID of Sender - uint64_t recieverPID; // PID of Reciever - uint64_t msg; // ID of message - uint64_t data; // Message Data - uint64_t data2; -} __attribute__((packed)) ipc_message_t; - -#ifdef __cplusplus -extern "C"{ -#endif - -void SendMessage(uint64_t pid, ipc_message_t msg); -uint64_t ReceiveMessage(ipc_message_t* msg); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/sysdeps/lemon/include/lemon/itoa.h b/sysdeps/lemon/include/lemon/itoa.h deleted file mode 100644 index 153c7d5c..00000000 --- a/sysdeps/lemon/include/lemon/itoa.h +++ /dev/null @@ -1,14 +0,0 @@ - #ifndef LEMON_H -#define LEMON_H - -#ifdef __cplusplus -extern "C"{ -#endif - -char* itoa(long num, char* str, int base); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/sysdeps/lemon/include/lemon/keyboard.h b/sysdeps/lemon/include/lemon/keyboard.h deleted file mode 100755 index b075f972..00000000 --- a/sysdeps/lemon/include/lemon/keyboard.h +++ /dev/null @@ -1,20 +0,0 @@ -#define KEY_TAB '\t' -#define KEY_BACKSPACE '\b' -#define KEY_ENTER '\n' -#define KEY_ESCAPE 27 - -#define KEY_F1 256 -#define KEY_F2 257 -#define KEY_F3 258 -#define KEY_F4 259 -#define KEY_F5 260 -#define KEY_F6 261 -#define KEY_F7 262 -#define KEY_F8 263 -#define KEY_F9 264 -#define KEY_F10 265 - -#define KEY_ARROW_UP 266 -#define KEY_ARROW_LEFT 267 -#define KEY_ARROW_RIGHT 268 -#define KEY_ARROW_DOWN 269 \ No newline at end of file diff --git a/sysdeps/lemon/include/lemon/lemon.h b/sysdeps/lemon/include/lemon/lemon.h deleted file mode 100755 index f4b38c4c..00000000 --- a/sysdeps/lemon/include/lemon/lemon.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef LEMON_H -#define LEMON_H - -#ifdef __cplusplus -extern "C"{ -#endif - -#include - -typedef struct { - - char cpuVendor[12]; - char null; - char versionString[64]; - - uint32_t memSize; - uint32_t usedMemory; -} lemon_sys_info_t; - -char* lemon_uname(char* string); -void lemon_sysinfo(lemon_sys_info_t* sys); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/sysdeps/lemon/include/lemon/spawn.h b/sysdeps/lemon/include/lemon/spawn.h new file mode 100644 index 00000000..529f9661 --- /dev/null +++ b/sysdeps/lemon/include/lemon/spawn.h @@ -0,0 +1,18 @@ +#ifndef FS_H +#define FS_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +void lemon_spawn(const char* path); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sysdeps/lemon/include/lemon/types.h b/sysdeps/lemon/include/lemon/types.h deleted file mode 100755 index e2c86f07..00000000 --- a/sysdeps/lemon/include/lemon/types.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef L_TYPES_H -#define L_TYPES_H - -#include - -typedef void* handle_t; - -#endif diff --git a/sysdeps/lemon/meson.build b/sysdeps/lemon/meson.build index f664997e..b911b947 100644 --- a/sysdeps/lemon/meson.build +++ b/sysdeps/lemon/meson.build @@ -5,14 +5,8 @@ rtdl_sources += files( libc_sources += files( 'generic/filesystem.c', 'generic/filesystem.cpp', - 'generic/ipc.c', 'generic/syscall.c', - 'generic/fb.c', - 'generic/process.c', - 'generic/lemon.c', 'generic/lemon.cpp', - 'generic/exit.c', - 'generic/itoa.c', ) if not no_headers @@ -24,14 +18,9 @@ if not no_headers subdir: 'abi-bits' ) install_headers( - 'include/lemon/ipc.h', 'include/lemon/filesystem.h', 'include/lemon/syscall.h', - 'include/lemon/types.h', - 'include/lemon/fb.h', - 'include/lemon/lemon.h', - 'include/lemon/keyboard.h', - 'include/lemon/itoa.h', + 'include/lemon/spawn.h', subdir: 'lemon' ) endif