spec_v2.md 2.9 KB
Newer Older
1 2 3
# Enclave Runtime PAL API Specification v2
Enclave Runtime PAL API defines a common interface to interact between `rune` and enclave runtime.

4
## 1.pal_get_version()
5 6 7 8 9 10

### Description
Indicate PAL API version number implemented by runelet and enclave runtime; runelet is compatible with any enclave runtimes equal to or less than the indicated value. If this symbol is undefined in enclave runtime, version 1 is assuemd by runelet.

### Prototype
```c
11
int pal_get_version();
12 13 14 15 16 17 18 19 20
```

### Parameters
```
N/A
```

### Return value
```
21
@int: the PAL API version of the current enclave runtime.
22
```
23 24

## 2.pal_init()
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108

### Description
Do libos initialization according to the incoming attr parameters.

### Prototype
```c
struct pal_attr_t {
	const char *args;
	const char *log_level;
};

int pal_init(struct pal_attr_t *attr);
```

### Parameters
```
@args: Pass the required parameters of libos (can be instance path etc.).
@log_level: Log level.
```
### Return value
```
0: Success
-EINVAL: Invalid argument
-ENOSYS: The function is not supported
```

## 3.pal_create_process()

### Description
Create a new process, but do not run it; the real run is triggered by pal_exec().

### Prototype
```c
struct pal_stdio_fds {
	int stdin, stdout, stderr;
};

struct pal_create_process_args {
	char *path;
	char *argv[];
	char *env[];
	struct pal_stdio_fds *stdio;
	int *pid;
}__attribute__((packed));

int pal_create_process(struct pal_create_process_args *args);
```

### Parameters
```
@path: The path of the binary file to be run (relative path in the libos file system).
@argv: Binary parameters, ending with a null element.
@env: Binary environment variables, ending with a null element.
@stdio: The fd of stdio.
@pid: If the function return value is 0, pid stores the pid of the new process in libos.
```

### Return value
```
0: Success
-EINVAL: Invalid argument
-ENOSYS: The function is not supported
```

## 4.pal_exec()

### Description
Execute the program corresponding to pid.

### Prototype
```c
struct pal_exec_args {
	int pid;
	int *exit_value;
}__attribute__((packed));

int pal_exec(struct pal_exec_args *attr);
```

### Parameters
```
@pid: The pid of the generation process.
@exit_value: The exit value of the process.
```
109

110 111 112 113 114 115 116
### Return value
```
0: Success
-EINVAL: Invalid argument
-ENOSYS: The function is not supported
```

117
## 5.pal_kill()
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138

### Description
Send signals to processes running in enclave runtime.

### Prototype
```c
int pal_kill(int pid, int sig);
```

### Parameters
```
@pid: Send to all processes if equal to -1, or send to current process if equal to 0, or send to the process that owns the pid if others.  
@sig: Signal number to be sent.
```

### Return value
```
0: Success
-EINVAL: Invalid argument
-ENOSYS: The function is not supported
```
139 140

## 6.pal_destroy()
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

### Description
Destroy libos instance.

### Prototype
```c
int pal_destroy();
```

### Parameters
```
N/A
```

### Return value
```
0: Success
-ENOSYS: The function is not supported
```