Move out libmsl functionality into separate libs
All checks were successful
Build documentation / build-and-deploy (push) Successful in 26s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 26s
This commit is contained in:
2
Makefile
2
Makefile
@@ -5,4 +5,6 @@ include make/kernel.mk
|
|||||||
include make/dist.mk
|
include make/dist.mk
|
||||||
include make/docs.mk
|
include make/docs.mk
|
||||||
include make/libmsl.mk
|
include make/libmsl.mk
|
||||||
|
include make/liballoc.mk
|
||||||
include make/libterminal.mk
|
include make/libterminal.mk
|
||||||
|
include make/libprocess.mk
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
make -B all_libmsl
|
make -B all_libmsl
|
||||||
|
make -B all_liballoc
|
||||||
|
make -B all_libprocess
|
||||||
make -B all_libterminal
|
make -B all_libterminal
|
||||||
make -B all_apps
|
make -B all_apps
|
||||||
make -B all_dist
|
make -B all_dist
|
||||||
|
|||||||
@@ -4,4 +4,7 @@ set -x
|
|||||||
|
|
||||||
make -B format_kernel
|
make -B format_kernel
|
||||||
make -B format_libmsl
|
make -B format_libmsl
|
||||||
|
make -B format_libterminal
|
||||||
|
make -B format_libprocess
|
||||||
|
make -B format_liballoc
|
||||||
make -B format_apps
|
make -B format_apps
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
ldflags += -L ../libterminal/build -l:libterminal.a
|
include ../make/ufuncs.mk
|
||||||
cflags += -isystem ../libterminal
|
|
||||||
|
$(eval $(call add_lib,libterminal))
|
||||||
|
$(eval $(call add_lib,liballoc))
|
||||||
|
$(eval $(call add_lib,libprocess))
|
||||||
|
|
||||||
include ../make/user.mk
|
include ../make/user.mk
|
||||||
|
|||||||
13
init/init.c
13
init/init.c
@@ -1,6 +1,5 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <proc/local.h>
|
#include <process/process.h>
|
||||||
#include <proc/proc.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string/string.h>
|
#include <string/string.h>
|
||||||
@@ -8,10 +7,10 @@
|
|||||||
|
|
||||||
#define MUTEX 2000
|
#define MUTEX 2000
|
||||||
|
|
||||||
LOCAL volatile char letter = 'c';
|
__thread volatile char letter = 'c';
|
||||||
|
|
||||||
void app_proc (void) {
|
void app_proc (void) {
|
||||||
char arg_letter = (char)(uintptr_t)argument_ptr ();
|
char arg_letter = (char)(uintptr_t)process_argument ();
|
||||||
|
|
||||||
letter = arg_letter;
|
letter = arg_letter;
|
||||||
|
|
||||||
@@ -32,9 +31,9 @@ void app_main (void) {
|
|||||||
|
|
||||||
letter = 'a';
|
letter = 'a';
|
||||||
|
|
||||||
/* process_spawn (&app_proc, (void*)'b'); */
|
process_spawn (&app_proc, (void*)'b');
|
||||||
/* process_spawn (&app_proc, (void*)'c'); */
|
process_spawn (&app_proc, (void*)'c');
|
||||||
/* process_spawn (&app_proc, (void*)'d'); */
|
process_spawn (&app_proc, (void*)'d');
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
mutex_lock (MUTEX);
|
mutex_lock (MUTEX);
|
||||||
|
|||||||
28
liballoc/Makefile
Normal file
28
liballoc/Makefile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
cc := clang
|
||||||
|
o :=
|
||||||
|
c :=
|
||||||
|
cflags := -isystem . -isystem ../libmsl
|
||||||
|
buildtype ?= release
|
||||||
|
|
||||||
|
include src.mk
|
||||||
|
include ../generic/flags.mk
|
||||||
|
include ../$(platform)/flags.mk
|
||||||
|
|
||||||
|
all: build/liballoc.a
|
||||||
|
|
||||||
|
build/liballoc.a: $(o)
|
||||||
|
llvm-ar rcs $@ $^
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(cc) -c -o $@ $(cflags) $<
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(cc) -c -o $@ $(cflags) $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(o) build/liballoc.a
|
||||||
|
|
||||||
|
format:
|
||||||
|
clang-format -i $$(git ls-files '*.c' '*.h')
|
||||||
|
|
||||||
|
.PHONY: all clean format
|
||||||
1
liballoc/src.mk
Normal file
1
liballoc/src.mk
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include alloc/src.mk
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
cc := clang
|
cc := clang
|
||||||
o :=
|
o :=
|
||||||
c :=
|
c :=
|
||||||
cflags := -isystem .
|
cflags := -isystem . -isystem ../liballoc
|
||||||
buildtype ?= release
|
buildtype ?= release
|
||||||
|
|
||||||
include src.mk
|
include src.mk
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
#ifndef _LIBMSL_PROC_TLS_H
|
|
||||||
#define _LIBMSL_PROC_TLS_H
|
|
||||||
|
|
||||||
#define LOCAL __thread
|
|
||||||
|
|
||||||
#endif // _LIBMSL_PROC_TLS_H
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
c += proc/proc.c
|
|
||||||
|
|
||||||
o += proc/proc.o
|
|
||||||
@@ -2,5 +2,3 @@ include $(platform)/src.mk
|
|||||||
include init/src.mk
|
include init/src.mk
|
||||||
include m/src.mk
|
include m/src.mk
|
||||||
include string/src.mk
|
include string/src.mk
|
||||||
include alloc/src.mk
|
|
||||||
include proc/src.mk
|
|
||||||
|
|||||||
28
libprocess/Makefile
Normal file
28
libprocess/Makefile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
cc := clang
|
||||||
|
o :=
|
||||||
|
c :=
|
||||||
|
cflags := -isystem . -isystem ../libmsl -isystem ../liballoc
|
||||||
|
buildtype ?= release
|
||||||
|
|
||||||
|
include src.mk
|
||||||
|
include ../generic/flags.mk
|
||||||
|
include ../$(platform)/flags.mk
|
||||||
|
|
||||||
|
all: build/libprocess.a
|
||||||
|
|
||||||
|
build/libprocess.a: $(o)
|
||||||
|
llvm-ar rcs $@ $^
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(cc) -c -o $@ $(cflags) $<
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(cc) -c -o $@ $(cflags) $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(o) build/libprocess.a
|
||||||
|
|
||||||
|
format:
|
||||||
|
clang-format -i $$(git ls-files '*.c' '*.h')
|
||||||
|
|
||||||
|
.PHONY: all clean format
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
#include <alloc/liballoc.h>
|
#include <alloc/liballoc.h>
|
||||||
#include <m/status.h>
|
#include <m/status.h>
|
||||||
#include <m/system.h>
|
#include <m/system.h>
|
||||||
#include <proc/proc.h>
|
#include <process/process.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
int process_spawn (process_func_t func, void* argument_ptr) {
|
int process_spawn (process_func_t func, void* argument_ptr) {
|
||||||
void* stack = malloc (PROC_STACK_SIZE);
|
void* stack = malloc (STACK_SIZE);
|
||||||
if (stack == NULL)
|
if (stack == NULL)
|
||||||
return -ST_OOM_ERROR;
|
return -ST_OOM_ERROR;
|
||||||
|
|
||||||
uintptr_t top = (uintptr_t)stack + PROC_STACK_SIZE;
|
uintptr_t top = (uintptr_t)stack + STACK_SIZE;
|
||||||
return clone (top, func, argument_ptr);
|
return clone (top, func, argument_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef _LIBMSL_PROC_PROC_H
|
#ifndef _LIBPROCESS_PROCESS_PROCESS_H
|
||||||
#define _LIBMSL_PROC_PROC_H
|
#define _LIBPROCESS_PROCESS_PROCESS_H
|
||||||
|
|
||||||
#include <m/system.h>
|
#include <m/system.h>
|
||||||
|
|
||||||
#define PROC_STACK_SIZE 256 * PAGE_SIZE
|
#define STACK_SIZE (256 * PAGE_SIZE)
|
||||||
|
|
||||||
typedef void (*process_func_t) (void);
|
typedef void (*process_func_t) (void);
|
||||||
|
|
||||||
@@ -11,4 +11,4 @@ int process_spawn (process_func_t func, void* argument_ptr);
|
|||||||
int process_quit (void);
|
int process_quit (void);
|
||||||
void* process_argument (void);
|
void* process_argument (void);
|
||||||
|
|
||||||
#endif // _LIBMSL_PROC_PROC_H
|
#endif // _LIBPROCESS_PROCESS_PROCESS_H
|
||||||
3
libprocess/process/src.mk
Normal file
3
libprocess/process/src.mk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
c += process/process.c
|
||||||
|
|
||||||
|
o += process/process.o
|
||||||
1
libprocess/src.mk
Normal file
1
libprocess/src.mk
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include process/src.mk
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
#include <m/system.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <terminal/device.h>
|
#include <terminal/device.h>
|
||||||
#include <terminal/terminal.h>
|
#include <terminal/terminal.h>
|
||||||
#include <m/system.h>
|
|
||||||
|
|
||||||
void terminal_print (const char* string, size_t len) {
|
void terminal_print (const char* string, size_t len) {
|
||||||
device_do (TERMINAL_DEVICE, TERMINAL_PUTSTR, (void*)string, &len, NULL, NULL);
|
device_do (TERMINAL_DEVICE, TERMINAL_PUTSTR, (void*)string, &len, NULL, NULL);
|
||||||
|
|||||||
10
make/liballoc.mk
Normal file
10
make/liballoc.mk
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
all_liballoc:
|
||||||
|
make -C liballoc platform=$(platform) all
|
||||||
|
|
||||||
|
clean_liballoc:
|
||||||
|
make -C liballoc platform=$(platform) clean
|
||||||
|
|
||||||
|
format_liballoc:
|
||||||
|
make -C liballoc platform=$(platform) format
|
||||||
|
|
||||||
|
.PHONY: all_liballoc clean_liballoc format_liballoc
|
||||||
10
make/libprocess.mk
Normal file
10
make/libprocess.mk
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
all_libprocess:
|
||||||
|
make -C libprocess platform=$(platform) all
|
||||||
|
|
||||||
|
clean_libprocess:
|
||||||
|
make -C libprocess platform=$(platform) clean
|
||||||
|
|
||||||
|
format_libprocess:
|
||||||
|
make -C libprocess platform=$(platform) format
|
||||||
|
|
||||||
|
.PHONY: all_libprocess clean_libprocess format_libprocess
|
||||||
4
make/ufuncs.mk
Normal file
4
make/ufuncs.mk
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
define add_lib
|
||||||
|
ldflags += -L ../$(1)/build -l:$(1).a
|
||||||
|
cflags += -isystem ../$(1)
|
||||||
|
endef
|
||||||
Reference in New Issue
Block a user