Moved Lemon sysdeps to LibLemon

This commit is contained in:
fido2020 2020-02-14 13:19:33 +11:00
parent 67284d6874
commit c4917449d2
18 changed files with 58 additions and 297 deletions

View file

@ -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

View file

@ -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)

View file

@ -1 +0,0 @@
#include <lemon/syscall.h>

View file

@ -1,15 +0,0 @@
#include <lemon/syscall.h>
#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

View file

@ -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);

View file

@ -1,16 +0,0 @@
#include <lemon/syscall.h>
#include <lemon/ipc.h>
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);
}

View file

@ -1,48 +0,0 @@
#include <stdint.h>
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;
}

View file

@ -1,7 +0,0 @@
#include <lemon/syscall.h>
#include <lemon/lemon.h>
char* lemon_uname(char* string){
syscall(SYS_UNAME, string, 0, 0, 0, 0);
return string;
}

View file

@ -1,10 +1,12 @@
#include <lemon/syscall.h>
#include <stddef.h>
#include <bits/ensure.h>
#include <bits/posix/pid_t.h>
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);
}

View file

@ -1,13 +0,0 @@
#include <lemon/syscall.h>
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){
}

View file

@ -1,24 +0,0 @@
#ifndef FB_H
#define FB_H
#include <stdint.h>
#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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,27 +0,0 @@
#ifndef LEMON_H
#define LEMON_H
#ifdef __cplusplus
extern "C"{
#endif
#include <stdint.h>
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

View file

@ -0,0 +1,18 @@
#ifndef FS_H
#define FS_H
#include <stddef.h>
#include <sys/types.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"{
#endif
void lemon_spawn(const char* path);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,8 +0,0 @@
#ifndef L_TYPES_H
#define L_TYPES_H
#include <stdint.h>
typedef void* handle_t;
#endif

View file

@ -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