Przeglądaj źródła

Change K210 sext specification

luojia65 4 lat temu
rodzic
commit
f10abf4395
2 zmienionych plików z 9 dodań i 5 usunięć
  1. 3 3
      platform/k210/README.md
  2. 6 2
      platform/k210/src/main.rs

+ 3 - 3
platform/k210/README.md

@@ -23,12 +23,12 @@ interrupt handlers.
 
 If there are mistakes or missing features in current support module, we welcome further contributions!
 
-## Private SBI functions
+## Implementation specific SBI functions
 
 To solve the issue 3 in previous section, RustSBI's current implementation includes a RustSBI specific
 SBI call as a function. 
 
-The K210 supervisor-level external interrupt handler register function is declared as either of:
+The K210 supervisor-level external interrupt handler register function is declared as:
 
 ```rust
 fn sbi_rustsbi_k210_sext(phys_addr: usize) -> SbiRet;
@@ -40,7 +40,7 @@ On any machine-level external interrupt, the RustSBI's K210 environment would ca
 The function's physical address shall be stored in register `a0` before calling this function.
 RustSBI will regard `a0` as a function without any parameters and any return values, or a `phys_addr: fn()`.
 
-This function will always return `SbiRet` value of `SBI_SUCCESS`.
+This function will always return `SbiRet` value of zero and error code of `SBI_SUCCESS`.
 
 ### Function Listing
 

+ 6 - 2
platform/k210/src/main.rs

@@ -362,11 +362,15 @@ extern "C" fn start_trap_rust(trap_frame: &mut TrapFrame) {
     let cause = mcause::read().cause();
     match cause {
         Trap::Exception(Exception::SupervisorEnvCall) => {
-            if trap_frame.a7 == 0x09 { 
-                // We use legacy 0x09 for now to register S-level interrupt handler
+            if trap_frame.a7 == 0x0A000004 && trap_frame.a6 == 0x210 { 
+                // We use implementation specific sbi_rustsbi_k210_sext function (extension 
+                // id: 0x0A000004, function id: 0x210) to register S-level interrupt handler
                 // for K210 chip only. This chip uses 1.9.1 version of privileged spec,
                 // which did not declare any S-level external interrupts. 
                 unsafe { DEVINTRENTRY = trap_frame.a0; }
+                // return values
+                trap_frame.a0 = 0; // SbiRet::error = SBI_SUCCESS
+                trap_frame.a1 = 0; // SbiRet::value = 0
             } else {
                 // Due to legacy 1.9.1 version of privileged spec, if we are in S-level
                 // timer handler (delegated from M mode), and we call SBI's `set_timer`,