changeset 286:34fae66beb7e

merge
author menikon <e165723@ie.u-ryukyu.ac.jp>
date Wed, 22 Jan 2020 20:29:31 +0900
parents 6e28bd30e8a7 (current diff) 429f0c3cc097 (diff)
children b73c5bd61c37
files
diffstat 8 files changed, 213 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/CMakeLists.txt	Wed Jan 22 20:28:26 2020 +0900
+++ b/src/CMakeLists.txt	Wed Jan 22 20:29:31 2020 +0900
@@ -126,8 +126,7 @@
   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  impl/file_impl_pipe.cbc
-         entry.S 
+  SingleLinkedStack.cbc entry.S impl/vm_impl.cbc
 )
 
 # sys_read_impl.cbc
--- a/src/gearsTools/lib/Gears/Context/Template/XV6.pm	Wed Jan 22 20:28:26 2020 +0900
+++ b/src/gearsTools/lib/Gears/Context/Template/XV6.pm	Wed Jan 22 20:29:31 2020 +0900
@@ -161,6 +161,8 @@
 #ifndef USE_CUDAWorker
 typedef unsigned long long CUdeviceptr;
 #endif
+typedef uint32  pte_t;
+typedef uint32  pde_t;
 EOFEOF
     print $out $str;
 }
--- a/src/gearsTools/trans_impl.pl	Wed Jan 22 20:28:26 2020 +0900
+++ b/src/gearsTools/trans_impl.pl	Wed Jan 22 20:29:31 2020 +0900
@@ -99,31 +99,31 @@
         }
   }
 
-  for my $datum (@inter_data) {
-        # remove macro, comment block
-        $datum =~ s|//[\s\w]+||;
-        if ($datum =~ /^\s+#/) {
-          next;
-        }
+  #for my $datum (@inter_data) {
+  #      # remove macro, comment block
+  #      $datum =~ s|//[\s\w]+||;
+  #      if ($datum =~ /^\s+#/) {
+  #        next;
+  #      }
 
-        if ($datum =~ /\w+\s\w+\*\s(\w+)/) {
-            print $out "    ${instance_inter}->$1 = NULL;\n";
-            next;
-        }
-        if ($datum =~ /\w+\s\w+\s(\w+)/) {
-            print $out "    ${instance_inter}->$1 = 0;\n";
-            next;
-        }
-        if ($datum =~ /\w+(\*)?\s(\w+)/) {
-            my $is_pointer = $1;
-            my $var_name = $2;
-            if ($1) {
-                print $out "    ${instance_inter}->$var_name = NULL;\n";
-            } else {
-                print $out "    ${instance_inter}->$var_name  = 0;\n";
-            }
-        }
-  }
+  #      if ($datum =~ /\w+\s\w+\*\s(\w+)/) {
+  #          print $out "    ${instance_inter}->$1 = NULL;\n";
+  #          next;
+  #      }
+  #      if ($datum =~ /\w+\s\w+\s(\w+)/) {
+  #          print $out "    ${instance_inter}->$1 = 0;\n";
+  #          next;
+  #      }
+  #      if ($datum =~ /\w+(\*)?\s(\w+)/) {
+  #          my $is_pointer = $1;
+  #          my $var_name = $2;
+  #          if ($1) {
+  #              print $out "    ${instance_inter}->$var_name = NULL;\n";
+  #          } else {
+  #              print $out "    ${instance_inter}->$var_name  = 0;\n";
+  #          }
+  #      }
+  #}
 
 
   for my $code (@{$impl_ir->{codes}}) {
--- a/src/impl/file_impl_pipe.cbc	Wed Jan 22 20:28:26 2020 +0900
+++ b/src/impl/file_impl_pipe.cbc	Wed Jan 22 20:29:31 2020 +0900
@@ -34,10 +34,13 @@
 // ----
 
 file* createpipe(struct Context* cbc_context) {
+    //initialize
     struct file* file  = new file();
     struct pipe* pipe = new pipe();
     file->file = (union Data*)pipe;
     pipe->file = (union Data*)file;
+
+    //assign
     pipe->lock = 0;
     pipe->spinlock  = 0;
     pipe->data  = 0;
@@ -52,10 +55,16 @@
     pipe->int  = 0;
     pipe->n  = 0;
     pipe->addr = NULL;
+
+    /*
+    API
     file->st = NULL;
     file->addr = NULL;
     file->n  = 0;
     file->fd  = 0;
+    */
+
+    // CodeGear Init
     pipe->piperead1 = C_piperead1pipe;
     pipe->piperead2 = C_piperead2pipe;
     pipe->cbc_pipeclose = C_cbc_pipeclosepipe;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/vm_impl.cbc	Wed Jan 22 20:29:31 2020 +0900
@@ -0,0 +1,125 @@
+#include "../../context.h"
+#interface "vm.h"
+
+// ----
+// typedef struct vm_impl<Impl, Isa> impl vm{
+//     unsigned int i;
+//     pte_t *pte;
+//     unsigned int sz;
+//  
+//     __code loaduvm_ptesize_check(Impl* vm_impl, __code next(...));
+//     __code loaduvm_loop(Impl* vm_impl, unsigned int i, pte_t *pte, unsigned int sz, __code next(...));
+//  
+// 
+// } vm_impl;
+// ----
+
+vm* createvm_impl(struct Context* cbc_context) {
+    struct vm* vm  = new vm();
+    struct vm_impl* vm_impl = new vm_impl();
+    vm->vm = (union Data*)vm_impl;
+    vm_impl->i = 0;
+    vm_impl->sz = 0;
+    vm->low = 0;
+    vm->hi = 0;
+    vm->p = NULL;
+    vm->pgdir = NULL;
+    vm->init = NULL;
+    vm->sz = 0;
+    vm->addr = NULL;
+    vm->ip = NULL;
+    vm->offset = 0;
+    vm->oldsz = 0;
+    vm->newsz = 0;
+    vm->uva = NULL;
+    vm->va = 0;
+    vm->p = NULL;
+    vm->len = 0;
+    vm->phy_low = 0;
+    vm->phy_hi = 0;
+    vm_impl->loaduvm_ptesize_check = C_loaduvm_ptesize_checkvm_impl;
+    vm_impl->loaduvm_loop = C_loaduvm_loopvm_impl;
+    vm->init_vmm = C_init_vmmvm_impl;
+    vm->kpt_freerange = C_kpt_freerangevm_impl;
+    vm->kpt_alloc = C_kpt_allocvm_impl;
+    vm->switchuvm = C_switchuvmvm_impl;
+    vm->init_inituvm = C_init_inituvmvm_impl;
+    vm->loaduvm = C_loaduvmvm_impl;
+    vm->allocuvm = C_allocuvmvm_impl;
+    vm->clearpteu = C_clearpteuvm_impl;
+    vm->copyuvm = C_copyuvmvm_impl;
+    vm->uva2ka = C_uva2kavm_impl;
+    vm->copyout = C_copyoutvm_impl;
+    vm->pagind_int = C_pagind_intvm_impl;
+    return vm;
+}
+__code loaduvm_ptesize_checkvm_impl(struct vm_impl* vm, __code next(...)) {
+
+    goto next(...);
+}
+
+__code loaduvm_loopvm_impl(struct vm_impl* vm, unsigned int i, pte_t *pte, unsigned int sz, __code next(...)) {
+
+    goto next(...);
+}
+
+__code init_vmmvm_impl(struct vm_impl* vm, __code next(...)) {
+
+    goto next(...);
+}
+
+__code kpt_freerangevm_impl(struct vm_impl* vm, unsigned int low, unsigned int hi, __code next(...)) {
+
+    goto next(...);
+}
+
+__code kpt_allocvm_impl(struct vm_impl* vm ,__code next(...)) {
+
+    goto next(...);
+}
+
+__code switchuvmvm_impl(struct vm_impl* vm ,struct proc* p, __code next(...)) {//:skip
+
+    goto next(...);
+}
+
+__code init_inituvmvm_impl(struct vm_impl* vm, pde_t* pgdir, char* init, unsigned int sz, __code next(...)) {//:skip
+
+    goto next(...);
+}
+
+__code loaduvmvm_impl(struct vm_impl* vm,pde_t* pgdir, char* addr, struct inode* ip, unsigned int offset, unsigned int sz,  __code next(...)) {
+
+    goto next(...);
+}
+
+__code allocuvmvm_impl(struct vm_impl* vm, pde_t* pgdir, unsigned int oldsz, unsigned int newsz, __code next(...)) {
+
+    goto next(...);
+}
+
+__code clearpteuvm_impl(struct vm_impl* vm, pde_t* pgdir, char* uva,  __code next(...)) {
+
+    goto next(...);
+}
+
+__code copyuvmvm_impl(struct vm_impl* vm, pde_t* pgdir, unsigned int sz, __code next(...)) {
+
+    goto next(...);
+}
+
+__code uva2kavm_impl(struct vm_impl* vm, pde_t* pgdir, char* uva, __code next(...)) {
+
+    goto next(...);
+}
+
+__code copyoutvm_impl(struct vm_impl* vm, pde_t* pgdir, unsigned int va, void* p, unsigned int len, __code next(...)) {
+
+    goto next(...);
+}
+
+__code pagind_intvm_impl(struct vm_impl* vm, unsigned int phy_low, unsigned int phy_hi, __code next(...)) {
+
+    goto next(...);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/vm_impl.h	Wed Jan 22 20:29:31 2020 +0900
@@ -0,0 +1,12 @@
+typedef struct vm_impl<Impl, Isa> impl vm{
+    unsigned int i;
+    pte_t *pte;
+    unsigned int sz;
+ 
+    __code loaduvm_ptesize_check(Type* vm_impl, __code next(...));
+    __code loaduvm_loop(Type* vm_impl, unsigned int i, pte_t *pte, unsigned int sz, __code next(...));
+ 
+
+} vm_impl;
+
+
--- a/src/interface/file.dg	Wed Jan 22 20:28:26 2020 +0900
+++ b/src/interface/file.dg	Wed Jan 22 20:29:31 2020 +0900
@@ -1,5 +1,12 @@
 typedef struct file <Impl> {
     union Data* file;
+    enum { FD_NONE, FD_PIPE, FD_INODE } type;
+    int ref;   // reference count
+    char readable;
+    char writable;
+    struct pipe  *pipe;
+    struct inode *ip;
+    unsigned int off;
     struct stat* st;
     char* addr;
     int n;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/interface/vm.h	Wed Jan 22 20:29:31 2020 +0900
@@ -0,0 +1,33 @@
+typedef struct vm<Type,Impl> {
+    union Data* vm;
+    unsigned int low;
+    unsigned int hi;
+    struct proc* p;
+    pde_t* pgdir;
+    char* init;
+    unsigned int sz;
+    char* addr;
+    struct inode* ip;
+    unsigned int offset;
+    unsigned int oldsz;
+    unsigned int newsz;
+    char* uva;
+    unsigned int va;
+    void* pp;
+    unsigned int len;
+    unsigned int phy_low;
+    unsigned int phy_hi;
+    __code init_vmm(Impl* vm, __code next(...));
+    __code kpt_freerange(Impl* vm, unsigned int low, unsigned int hi, __code next(...));
+    __code kpt_alloc(Impl* vm ,__code next(...));
+    __code switchuvm(Impl* vm ,struct proc* p, __code next(...));
+    __code init_inituvm(Impl* vm, pde_t* pgdir, char* init, unsigned int sz, __code next(...));
+    __code loaduvm(Impl* vm,pde_t* pgdir, char* addr, struct inode* ip, unsigned int offset, unsigned int sz,  __code next(...));
+    __code allocuvm(Impl* vm, pde_t* pgdir, unsigned int oldsz, unsigned int newsz, __code next(...));
+    __code clearpteu(Impl* vm, pde_t* pgdir, char* uva,  __code next(...));
+    __code copyuvm(Impl* vm, pde_t* pgdir, unsigned int sz, __code next(...));
+    __code uva2ka(Impl* vm, pde_t* pgdir, char* uva, __code next(...));
+    __code copyout(Impl* vm, pde_t* pgdir, unsigned int va, void* pp, unsigned int len, __code next(...));
+    __code pagind_int(Impl* vm, unsigned int phy_low, unsigned int phy_hi, __code next(...));
+    __code next(...);
+} vm;