diff options
author | Alex Auvolat <alex@adnab.me> | 2017-04-19 11:37:40 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2017-04-19 11:37:40 +0200 |
commit | 8e88e765ee17296a85c5ae372471ed248ce321db (patch) | |
tree | 94c375f5ec15d215dac16c6f9e386f24283c07df | |
parent | 96da27494f89d75f8aec0c8894440c3f7482f54b (diff) | |
download | kogata-8e88e765ee17296a85c5ae372471ed248ce321db.tar.gz kogata-8e88e765ee17296a85c5ae372471ed248ce321db.zip |
Mini reorganization
-rw-r--r-- | bam.lua | 3 | ||||
-rwxr-xr-x | make_cdrom.sh | 16 | ||||
-rw-r--r-- | src/bin/bam.lua | 24 | ||||
-rw-r--r-- | src/common/include/assert.h (renamed from src/lib/include/assert.h) | 0 | ||||
l--------- | src/lib/include/lua/lprefix.h | 1 | ||||
-rw-r--r-- | src/lib/libc/debug.c | 1 | ||||
-rw-r--r-- | src/lib/libc/stdio.c | 7 | ||||
-rw-r--r-- | src/sysbin/bam.lua | 3 | ||||
-rw-r--r-- | src/sysbin/login/main.c | 2 | ||||
-rw-r--r-- | src/sysbin/lua/lua.c (renamed from src/bin/lua/lua.c) | 8 | ||||
-rw-r--r-- | src/sysbin/luac/luac.c (renamed from src/bin/luac/luac.c) | 0 | ||||
-rw-r--r-- | src/sysbin/shell/main.c | 3 |
12 files changed, 25 insertions, 43 deletions
@@ -96,7 +96,6 @@ local function cdrom(name, settings) local kernel = require('src/kernel/bam')(settings, common) local lib = require('src/lib/bam')(settings, common) local sysbin = require('src/sysbin/bam')(settings, lib) - local bin = require('src/bin/bam')(settings, lib) if name == "dev" then dev_kernel = kernel @@ -104,7 +103,7 @@ local function cdrom(name, settings) local cdrom = "cdrom." .. name .. ".iso" AddJob(cdrom, "building ISO", "./make_cdrom.sh " .. name) - AddDependency(cdrom, kernel.bin, sysbin, bin, fonts, keymaps) + AddDependency(cdrom, kernel.bin, sysbin, fonts, keymaps) AddDependency(cdrom, Collect('src/syslua/*.lua')) -- diff --git a/make_cdrom.sh b/make_cdrom.sh index 961ae7b..e6ef212 100755 --- a/make_cdrom.sh +++ b/make_cdrom.sh @@ -27,15 +27,13 @@ cp build/$TY/kernel.bin cdrom/boot; $STRIP cdrom/boot/kernel.bin cp build/$TY/sysbin/init.bin cdrom/boot; $STRIP cdrom/boot/init.bin mkdir -p cdrom/sys/bin -for BIN in giosrv.bin login.bin terminal.bin shell.bin; do - cp build/$TY/sysbin/$BIN cdrom/sys/bin - $STRIP cdrom/sys/bin/$BIN -done - -mkdir -p cdrom/bin -for BIN in lua.bin luac.bin; do - cp build/$TY/bin/$BIN cdrom/bin - $STRIP cdrom/bin/$BIN +for BIN in giosrv.bin login.bin terminal.bin shell.bin lua.bin luac.bin; do + if [ -e build/$TY/sysbin/$BIN ]; then + cp build/$TY/sysbin/$BIN cdrom/sys/bin + $STRIP cdrom/sys/bin/$BIN + else + print "Skipping binary $BIN: not found!" + fi done mkdir -p cdrom/sys/fonts diff --git a/src/bin/bam.lua b/src/bin/bam.lua deleted file mode 100644 index d529ece..0000000 --- a/src/bin/bam.lua +++ /dev/null @@ -1,24 +0,0 @@ -return function(s, lib) - local function bin_settings(name) - local s = TableDeepCopy(s.user_settings) - s.link.flags:Add("-T src/lib/linker.ld") - if name == 'lua' or name == 'luac' then - s.cc.includes:Add("src/lib/lua") - end - return s - end - - local function bin_exe(name, deps) - local s = bin_settings(name) - - local src = Collect('src/bin/' .. name .. '/*.c') - local obj = Compile(s, src) - - return Link(s, 'bin/' .. name .. ".bin", {obj, deps}) - end - - return { - bin_exe('lua', {lib.liblua}), - -- bin_exe('luac', {liblua}), - } -end diff --git a/src/lib/include/assert.h b/src/common/include/assert.h index 655d6f6..655d6f6 100644 --- a/src/lib/include/assert.h +++ b/src/common/include/assert.h diff --git a/src/lib/include/lua/lprefix.h b/src/lib/include/lua/lprefix.h new file mode 120000 index 0000000..3c5a9cb --- /dev/null +++ b/src/lib/include/lua/lprefix.h @@ -0,0 +1 @@ +../../lua/lprefix.h
\ No newline at end of file diff --git a/src/lib/libc/debug.c b/src/lib/libc/debug.c index f862fe6..d88b204 100644 --- a/src/lib/libc/debug.c +++ b/src/lib/libc/debug.c @@ -4,6 +4,7 @@ #include <kogata/syscall.h> #include <kogata/debug.h> #include <kogata/printf.h> +#include <kogata/mutex.h> void sys_panic(const char* msg, const char* file, int line) { dbg_printf("PANIC in user process\n %s\n at %s:%d\n", msg, file, line); diff --git a/src/lib/libc/stdio.c b/src/lib/libc/stdio.c index dcbcf83..864fb34 100644 --- a/src/lib/libc/stdio.c +++ b/src/lib/libc/stdio.c @@ -322,15 +322,18 @@ int fflush(FILE* stream) { dbg_printf("FFLUSH %p\n", stream); if (!(stream->file_mode & FM_WRITE)) return 0; - if (stream == NULL || stream->fd == 0) return EOF; + if (stream == NULL || stream->fd == 0) { + return EOF; + } if (stream->buf_mode != 0 && stream->out_buf_used > 0) { size_t ret = sc_write(stream->fd, stream->pos, stream->out_buf_used, stream->out_buf); - stream->out_buf_used = 0; if (ret != stream->out_buf_used) { return EOF; } + + stream->out_buf_used = 0; if (!(stream->st.type & (FT_CHARDEV | FT_CHANNEL | FT_DIR))) { stream->pos += ret; } diff --git a/src/sysbin/bam.lua b/src/sysbin/bam.lua index 9e13a8a..c05d8e6 100644 --- a/src/sysbin/bam.lua +++ b/src/sysbin/bam.lua @@ -20,5 +20,8 @@ return function(s, lib) sysbin_exe('login', {lib.libkogata}), sysbin_exe('terminal', {lib.libkogata}), sysbin_exe('shell', {lib.libkogata}), + + sysbin_exe('lua', {lib.liblua}), + -- sysbin_exe('luac', {liblua}), } end diff --git a/src/sysbin/login/main.c b/src/sysbin/login/main.c index d86eb39..2f75dbe 100644 --- a/src/sysbin/login/main.c +++ b/src/sysbin/login/main.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) { if (!ok) PANIC("[login] Could not bind to shell process."); // ok = sc_proc_exec(shell_pid, "sys:/bin/shell.bin"); - ok = sc_proc_exec(shell_pid, "root:/bin/lua.bin"); + ok = sc_proc_exec(shell_pid, "sys:/bin/lua.bin"); if (!ok) PANIC("[login] Could not run shell.bin"); proc_status_t s; diff --git a/src/bin/lua/lua.c b/src/sysbin/lua/lua.c index 8f64451..c67d771 100644 --- a/src/bin/lua/lua.c +++ b/src/sysbin/lua/lua.c @@ -11,7 +11,7 @@ #define lua_c -#include "lprefix.h" +#include <lua/lprefix.h> #include <signal.h> @@ -19,10 +19,10 @@ #include <stdlib.h> #include <string.h> -#include "lua.h" +#include <lua/lua.h> -#include "lauxlib.h" -#include "lualib.h" +#include <lua/lauxlib.h> +#include <lua/lualib.h> #if !defined(LUA_PROMPT) diff --git a/src/bin/luac/luac.c b/src/sysbin/luac/luac.c index c0c91d0..c0c91d0 100644 --- a/src/bin/luac/luac.c +++ b/src/sysbin/luac/luac.c diff --git a/src/sysbin/shell/main.c b/src/sysbin/shell/main.c index e27b4e9..3f45332 100644 --- a/src/sysbin/shell/main.c +++ b/src/sysbin/shell/main.c @@ -34,9 +34,10 @@ void cat(char* file) { while (true) { size_t r = sc_read(f, p, 128, buf); p += r; - fwrite(buf, r, 1, stdout); + fwrite(buf, 1, r, stdout); if (r < 128) break; } + printf("\n -> %d bytes\n", p); sc_close(f); } else { printf("Could not open file '%s'\n", file); |