-#!/bin/sh
+#!/bin/bash
#
# Execute the specified root application using the ARCH=native build
#
_=$PWD; cd $(dirname $0); DIR=$PWD; cd $_
DISTROOT=$(dirname $DIR)/Usermode/Output/native/
VTERM=/Devices/pts/vt0
+echo $DISTROOT
+
+KERNEL_PID=$$
+function cleanup {
+ trap '' SIGINT
+ echo Cleaning up $KERNEL_PID
+ kill $KERNEL_PID
+}
+
+trap cleanup SIGINT
# 1. Start up AcessKernel
# - Set DISTROOT to the output directory of ARCH=native
# - Don't start a root application
-${DIR}/AcessKernel --distroot $DISTROOT > ${DIR}/log/native_AcessKernel.log &
+${DIR}/AcessKernel --distroot $DISTROOT > ${DIR}/log/native_AcessKernel.log 2>&1 &
+KERNEL_PID=$!
+echo Kernel is $KERNEL_PID
sleep 1
LD_LIBRARY_PATH=${DIR}:${DISTROOT}Libs AN_PREOPEN=$VTERM:$VTERM:$VTERM ${DBG} ${DISTROOT}Apps/AxWin/4.0/AxWinServer
+
+cleanup
+
KERNEL_OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/io.o vfs/dir.o\r
KERNEL_OBJ += vfs/nodecache.o vfs/mount.o vfs/memfile.o vfs/select.o\r
KERNEL_OBJ += vfs/fs/root.o vfs/fs/devfs.o\r
-KERNEL_OBJ += drv/fifo.o drv/proc.o drv/dgram_pipe.o # drv/shm.o\r
+KERNEL_OBJ += drv/fifo.o drv/proc.o drv/dgram_pipe.o\r
KERNEL_OBJ += drv/vterm.o drv/vterm_font.o drv/vterm_output.o drv/vterm_input.o drv/vterm_termbuf.o\r
KERNEL_OBJ += drv/vterm_vt100.o drv/vterm_2d.o\r
KERNEL_OBJ += drv/pty.o\r
# - Local objects (use the kernel includes)\r
OBJ := helpers.o threads.o threads_glue.o server.o syscalls.o time.o\r
OBJ += video.o keyboard.o mouse.o nativefs.o vfs_handle.o ui_sdl.o\r
+#OBJ += shm.o\r
OBJ += net.o syscall_getpath.o\r
\r
BUILDINFO_OBJ := obj-$(PLATFORM)/buildinfo.o\r
{
if( strncmp(Path, "$$$$", 4) == 0 )
{
- return native_open(Path, Flags) | NATIVE_FILE_MASK;
+ return native_open(Path+4, Flags) | NATIVE_FILE_MASK;
+ }
+ if( strncmp(Path, "/Devices/shm/", 13) == 0 )
+ {
+ const char* tag = Path + 13;
+ Warning("TODO: Handle open SHM \"%s\"", tag);
+ return native_shm(tag, Flags) | NATIVE_FILE_MASK;
}
SYSTRACE("open(\"%s\", 0x%x)", Path, Flags);
return _Syscall(SYS_OPEN, ">s >i", Path, Flags);
}
// --- Logging
+static void int_dbgheader(void )
+{
+ printf("[_SysDebug %i] ", giSyscall_ClientID);
+}
void acess__SysDebug(const char *Format, ...)
{
va_list args;
va_start(args, Format);
-
- printf("[_SysDebug %i] ", giSyscall_ClientID);
+ int_dbgheader();
vprintf(Format, args);
printf("\n");
va_end(args);
}
+void acess__SysDebugHex(const char *tag, const void *data, size_t size)
+{
+ int_dbgheader();
+ printf("%s (Hexdump of %p+%zi)\r\n", tag, data, size);
+
+ #define CH(n) ((' '<=cdat[(n)]&&cdat[(n)]<0x7F) ? cdat[(n)] : '.')
+
+ const uint8_t *cdat = data;
+ unsigned int pos = 0;
+
+ while(size >= 16)
+ {
+ int_dbgheader();
+ printf("%04x:"
+ " %02x %02x %02x %02x %02x %02x %02x %02x "
+ " %02x %02x %02x %02x %02x %02x %02x %02x "
+ " %c%c%c%c%c%c%c%c %c%c%c%c%c%c%c%c\r\n",
+ pos,
+ cdat[ 0], cdat[ 1], cdat[ 2], cdat[ 3], cdat[ 4], cdat[ 5], cdat[ 6], cdat[ 7],
+ cdat[ 8], cdat[ 9], cdat[10], cdat[11], cdat[12], cdat[13], cdat[14], cdat[15],
+ CH(0), CH(1), CH(2), CH(3), CH(4), CH(5), CH(6), CH(7),
+ CH(8), CH(9), CH(10), CH(11), CH(12), CH(13), CH(14), CH(15)
+ );
+ size -= 16;
+ cdat += 16;
+ pos += 16;
+ }
+
+ {
+ int_dbgheader();
+ printf("%04x: ", pos);
+ for(int i = 0; i < size; i ++)
+ printf("%02x ", cdat[i]);
+ for(int i = size; i < 16; i ++)
+ printf(" ");
+ printf(" ");
+ for(int i = 0; i < size; i ++)
+ {
+ if( i == 8 )
+ printf(" ");
+ printf("%c", CH(i));
+ }
+
+ printf("\n");
+ }
+}
+
void acess__exit(int Status)
{
DEBUG("_exit(%i)", Status);
DEFSYM(_SysSetMemFlags),
DEFSYM(_SysDebug),
{"_ZN4_sys5debugEPKcz", &acess__SysDebug},
+ DEFSYM(_SysDebugHex),
+ {"_ZN4_sys7hexdumpEPKcPKvj", &acess__SysDebugHex},
DEFSYM(_SysSetFaultHandler),
DEFSYM(_SysWaitEvent),
return retValue;
}
+int native_int_getfd(void)
+{
+ for(int ret = 0; ret < MAX_FPS; ret ++ )
+ if( gaSyscall_LocalFPs[ret] == NULL )
+ return ret;
+ return -1;
+}
int native_open(const char *Path, int Flags)
{
- int ret;
- for(ret = 0; ret < MAX_FPS && gaSyscall_LocalFPs[ret]; ret ++ ) ;
- if(ret == MAX_FPS) return -1;
+ int ret = native_int_getfd();
+ if(ret == -1) return -1;
// TODO: Handle directories
- gaSyscall_LocalFPs[ret] = fopen(&Path[4], "r+");
+ gaSyscall_LocalFPs[ret] = fopen(Path, "r+");
if(!gaSyscall_LocalFPs[ret]) return -1;
return ret;
}
+int native_shm(const char *Tag, int Flags)
+{
+ // int ret = native_int_getfd();
+ //if(ret == -1) return -1;
+ //if( strcmp(Tag, "anon") == 0 )
+ // path = "/AcessNative/anon/RAND";
+ // FD = shm_open(path, O_RDWD);
+ //shm_unlink(path);
+ //else
+ // path = "/Acessnative/named/<TAG>";
+ // int FD = shm_open(path, O_RDWD);
+ //shm_unlink(path);
+ //gaSyscall_LocalFPs[ret] =
+ return -1;
+}
+
void native_close(int FD)
{
fclose( gaSyscall_LocalFPs[FD] );