|
@@ -1,21 +1,58 @@
|
|
|
#ifndef ZIVUOS_PROCESS_H_INCLUDED
|
|
#ifndef ZIVUOS_PROCESS_H_INCLUDED
|
|
|
#define ZIVUOS_PROCESS_H_INCLUDED
|
|
#define ZIVUOS_PROCESS_H_INCLUDED
|
|
|
|
|
|
|
|
-#include <stdint.h>
|
|
|
|
|
-#include <stdbool.h>
|
|
|
|
|
-
|
|
|
|
|
-typedef uint8_t zivu_priority_t;
|
|
|
|
|
-typedef size_t zivu_pid_t;
|
|
|
|
|
-
|
|
|
|
|
-typedef struct zivu_pipe_s {
|
|
|
|
|
- void *data;
|
|
|
|
|
- bool avairable;
|
|
|
|
|
-} zivu_pipe_t;
|
|
|
|
|
-
|
|
|
|
|
-typedef struct zivu_process_s {
|
|
|
|
|
- void (*worker)(void*, void*);
|
|
|
|
|
- zivu_pipe_t pipe[1];
|
|
|
|
|
- zivu_priority_t priority;
|
|
|
|
|
-} zivu_process_t;
|
|
|
|
|
|
|
+#include "porttypes.h"
|
|
|
|
|
+#include "worker.h"
|
|
|
|
|
+#include "pipe.h"
|
|
|
|
|
+
|
|
|
|
|
+typedef enum zv_process_state_e {
|
|
|
|
|
+ /* Process waiting for free processor time */
|
|
|
|
|
+ WAITING,
|
|
|
|
|
+
|
|
|
|
|
+ /* Process current executing by processor */
|
|
|
|
|
+ RUNNING,
|
|
|
|
|
+
|
|
|
|
|
+ /* Process waiting for IRQ (param) */
|
|
|
|
|
+ IRQ_WAITING,
|
|
|
|
|
+
|
|
|
|
|
+ /* Process waiting for new data in PIPE */
|
|
|
|
|
+ PIPE_WAITING,
|
|
|
|
|
+
|
|
|
|
|
+ /* Process waiting for ticks (param) */
|
|
|
|
|
+ TIME_WAITING
|
|
|
|
|
+} zv_process_state_t;
|
|
|
|
|
+
|
|
|
|
|
+typedef union zv_process_param_u {
|
|
|
|
|
+ /* Required for TIME_WAITING */
|
|
|
|
|
+ zv_ticks_t time;
|
|
|
|
|
+
|
|
|
|
|
+ /* Required for IRQ_WAITING */
|
|
|
|
|
+ zv_irq_t irq;
|
|
|
|
|
+} zv_process_param_t;
|
|
|
|
|
+
|
|
|
|
|
+typedef struct zv_process_s {
|
|
|
|
|
+ /* Current state of process */
|
|
|
|
|
+ zv_process_state_t state;
|
|
|
|
|
+
|
|
|
|
|
+ /* Pipe for processes communication */
|
|
|
|
|
+ zv_pipe_t pipe;
|
|
|
|
|
+
|
|
|
|
|
+ /* Priority of process (lower number -> higher priority) */
|
|
|
|
|
+ zv_uint_t priority;
|
|
|
|
|
+
|
|
|
|
|
+ /* Param for the process */
|
|
|
|
|
+ zv_process_param_t param;
|
|
|
|
|
+
|
|
|
|
|
+ /* Worker of the process */
|
|
|
|
|
+ zv_worker_t worker;
|
|
|
|
|
+} zv_process_t;
|
|
|
|
|
+
|
|
|
|
|
+#ifdef USING_NAMESPACE_ZV
|
|
|
|
|
+
|
|
|
|
|
+typedef zv_process_t process_t;
|
|
|
|
|
+typedef zv_process_param_t process_param_t;
|
|
|
|
|
+typedef zv_process_state_t process_state_t;
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
#endif
|
|
#endif
|