changeset 156:18a432ac4f9f

add Syscall close
author tobaru
date Fri, 20 Dec 2019 16:05:31 +0900
parents 94ee7046d190
children 57386e27708b
files src/CMakeLists.txt src/impl/SysCloseImpl.cbc src/impl/SysCloseImpl.h src/inode.h src/interface/SysClose.h src/sys_close_impl.cbc src/usr/CMakeLists.txt
diffstat 6 files changed, 53 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/CMakeLists.txt	Mon Dec 02 18:07:42 2019 +0900
+++ b/src/CMakeLists.txt	Fri Dec 20 16:05:31 2019 +0900
@@ -124,7 +124,7 @@
       kernel
   SOURCES
 	string.c arm.c asm.S bio.c buddy.c console.cbc exec.c file.cbc fs.c log.c main.c memide.c pipe.cbc proc.cbc spinlock.cbc 
-	start.c swtch.S syscall.cbc sysfile.cbc sysproc.c trap_asm.S trap.c vm.c device/picirq.c device/timer.c device/uart.c
-  SingleLinkedStack.cbc
+	start.c swtch.S syscall.cbc sysfile.cbc sysproc.c trap_asm.S trap.c vm.c device/picirq.c device/timer.c device/uart.c 
+  SingleLinkedStack.cbc sys_close_impl.cbc
          entry.S 
 )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/SysCloseImpl.h	Fri Dec 20 16:05:31 2019 +0900
@@ -0,0 +1,3 @@
+typedef struct SysCloseImpl<Type, Isa> impl SysClose {
+
+} SysCloseImpl;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/inode.h	Fri Dec 20 16:05:31 2019 +0900
@@ -0,0 +1,13 @@
+typedef struct inode <Impl> {
+    uint    dev;        // Device number
+    uint    inum;       // Inode number
+    int     ref;        // Reference count
+    int     flags;      // I_BUSY, I_VALID
+
+    short   type;       // copy of disk inode
+    short   major;
+    short   minor;
+    short   nlink;
+    uint    size;
+    uint    addrs[NDIRECT+1];
+} inode;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/interface/SysClose.h	Fri Dec 20 16:05:31 2019 +0900
@@ -0,0 +1,7 @@
+typedef struct SysClose<Type, Impl>{
+    int fd;
+    struct file *f;
+
+    __code close(int fd, struct file *f, __code next(...));
+
+} SysClose;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sys_close_impl.cbc	Fri Dec 20 16:05:31 2019 +0900
@@ -0,0 +1,25 @@
+#include "../context.h";
+#interface "SysClose.h";
+
+// ----
+// typedef struct SysCloseImpl<Type, Isa> impl SysClose {
+// 
+// } SysCloseImpl;
+// ----
+
+SysClose* createSysCloseImpl(struct Context* cbc_context) {
+    struct SysClose*     int fd;
+  = new SysClose();
+    struct SysCloseImpl* sys_close_impl = new SysCloseImpl();
+        int fd;
+->    int fd;
+ = (union Data*)sys_close_impl;
+        int fd;
+->close = C_closeSysCloseImpl;
+    return     int fd;
+;
+}
+__code closeSysCloseImpl(int fd, struct file *f, __code next(...)) {
+
+  goto next(...);
+}
--- a/src/usr/CMakeLists.txt	Mon Dec 02 18:07:42 2019 +0900
+++ b/src/usr/CMakeLists.txt	Fri Dec 20 16:05:31 2019 +0900
@@ -57,17 +57,16 @@
             list(APPEND _Gears_CBC_SOURCES ${j})
         else()
             set(j ${i})
-            file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION "${CMAKE_BINARY_DIR}/usr/${_Gears_TARGET}.dir")
             list(APPEND _Gears_CSOURCES ${j})
         endif()
     endforeach(i)
 
     add_custom_command (
-          OUTPUT    ${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c
+          OUTPUT    CMakeFiles/${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c
           DEPENDS   ${_Gears_CBC_SOURCES}
-          COMMAND  "cd" "${_Gears_TARGET}.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} "-w" ${CMAKE_SOURCE_DIR}/usr/${_Gears_CSOURCES}
+          COMMAND  "cd" "CMakeFiles/${_Gears_TARGET}.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} "-w" ${CMAKE_SOURCE_DIR}/usr/${_Gears_CSOURCES}
     )
-    add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c )
+    add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} CMakeFiles/${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c )
     target_link_libraries(${_Gears_TARGET} ulib)
 endmacro()