Exposing SystemSpawn in libc and adding skeleton for basic shell.

This commit is contained in:
Ali Mashtizadeh 2014-11-25 22:24:54 -08:00
parent 8d9580b273
commit 8826ed6396
7 changed files with 49 additions and 0 deletions

View File

@ -161,6 +161,7 @@ CopyTree('build/include/machine', 'sys/' + env['ARCH'] + '/include', env)
# Build Targets # Build Targets
SConscript('sys/SConscript', variant_dir='build/sys') SConscript('sys/SConscript', variant_dir='build/sys')
SConscript('lib/libc/SConscript', variant_dir='build/lib/libc') SConscript('lib/libc/SConscript', variant_dir='build/lib/libc')
SConscript('bin/shell/SConscript', variant_dir='build/bin/shell')
SConscript('sbin/init/SConscript', variant_dir='build/sbin/init') SConscript('sbin/init/SConscript', variant_dir='build/sbin/init')
# Build Tools # Build Tools
@ -180,6 +181,7 @@ if env["BOOTDISK"] == "1":
env.Append(BUILDERS = {'BuildImage' : newfs}) env.Append(BUILDERS = {'BuildImage' : newfs})
bootdisk = env.BuildImage('#build/bootdisk.img', '#release/bootdisk.manifest') bootdisk = env.BuildImage('#build/bootdisk.img', '#release/bootdisk.manifest')
Depends(bootdisk, "#build/tools/newfs_o2fs/newfs_o2fs") Depends(bootdisk, "#build/tools/newfs_o2fs/newfs_o2fs")
Depends(bootdisk, "#build/bin/shell/shell")
Depends(bootdisk, "#build/sbin/init/init") Depends(bootdisk, "#build/sbin/init/init")
Depends(bootdisk, "#build/sys/castor") Depends(bootdisk, "#build/sys/castor")
env.Alias('bootdisk', '#build/bootdisk.img') env.Alias('bootdisk', '#build/bootdisk.img')

21
bin/shell/SConscript Normal file
View File

@ -0,0 +1,21 @@
import sys
Import('env')
init_env = env.Clone()
src = [ ]
src_common = [
"shell.c"
]
src.append(src_common)
init_env.Append(LINKFLAGS = ['-nostdlib'])
init_env.Append(CPPFLAGS = ['-nostdinc'])
init_env.Append(CPPPATH = ['#build/include'])
init_env.Append(LIBPATH = ['#build/lib/libc'], LIBS = ['c'])
init_env.Program("shell", src)

15
bin/shell/shell.c Normal file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
int
main(int argc, const char *argv[])
{
char buf[256];
fputs("Shell\n", stdout);
while (1) {
fputs("> ", stdout);
fgets(buf, sizeof(buf), stdin);
}
}

View File

@ -6,6 +6,7 @@
#define EBADF 2 #define EBADF 2
#define EINVAL 3 #define EINVAL 3
#define EFAULT 4 #define EFAULT 4
#define ENOMEM 5
#endif /* __ERRNO_H__ */ #endif /* __ERRNO_H__ */

View File

@ -5,6 +5,7 @@
uint64_t SystemTime(); uint64_t SystemTime();
void SystemExit(int status); void SystemExit(int status);
uint64_t SystemGetPID(); uint64_t SystemGetPID();
uint64_t SystemSpawn(const char *path);
// Memory // Memory
void *SystemMemMap(void *addr, uint64_t len, int flags); void *SystemMemMap(void *addr, uint64_t len, int flags);

View File

@ -25,6 +25,12 @@ SystemGetPID()
return syscall(SYSCALL_GETPID); return syscall(SYSCALL_GETPID);
} }
uint64_t
SystemSpawn(const char *path)
{
return syscall(SYSCALL_SPAWN, path);
}
void * void *
SystemMemMap(void *addr, uint64_t len, int flags) SystemMemMap(void *addr, uint64_t len, int flags)
{ {

View File

@ -4,6 +4,9 @@ DIR /
END END
DIR dev DIR dev
END END
DIR bin
FILE shell build/bin/shell/shell
END
DIR sbin DIR sbin
FILE init build/sbin/init/init FILE init build/sbin/init/init
END END