summaryrefslogtreecommitdiff
path: root/src/init/main.c
diff options
context:
space:
mode:
authordzwdz2021-09-12 15:07:26 +0200
committerdzwdz2021-09-12 15:07:26 +0200
commite4e4007fbbeede6f9a59dab6327f0ef3a4675801 (patch)
tree13da6d7ed29aadc442124ca32a290aee1403ee68 /src/init/main.c
parent1bf901c803bff3393d0cc9dfe76fc9f025cecb1c (diff)
init: allocate bss at runtime
Diffstat (limited to 'src/init/main.c')
-rw-r--r--src/init/main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/init/main.c b/src/init/main.c
index dc5a975..78576aa 100644
--- a/src/init/main.c
+++ b/src/init/main.c
@@ -6,28 +6,28 @@
#define argify(str) str, sizeof(str) - 1
#define log(str) _syscall_write(tty_fd, argify(str))
-__attribute__((section("text")))
-int tty_fd;
+extern char _bss_start; // provided by the linker
+extern char _bss_end;
-int test;
+int tty_fd;
void fs_test(void);
int main(void) {
+ // allocate bss
+ _syscall_memflag(&_bss_start, &_bss_end - &_bss_start, MEMFLAG_PRESENT);
+
tty_fd = _syscall_open("/tty", sizeof("/tty") - 1);
if (tty_fd < 0)
_syscall_exit(argify("couldn't open tty"));
log(" opened /tty ");
- _syscall_memflag(&test, sizeof(int), MEMFLAG_PRESENT);
- test = 0; // would cause a pagefault without the memflag call
-
fs_test();
_syscall_exit(argify("my job here is done."));
}
void fs_test(void) {
- static char buf[64] __attribute__((section("text")));
+ static char buf[64];
int len = 64;
handle_t front, back, file;
front = _syscall_fs_create(&back);