diff --git a/index.html b/index.html index c1c9735..007b0ba 100644 --- a/index.html +++ b/index.html @@ -102,6 +102,7 @@

  • Build and Run the Tenok
  • Run Tenok with Gazebo Simulator
  • Interact with Tenok Shell
  • +
  • Supported Platforms
  • Resources

    @@ -111,31 +112,9 @@

  • Presentation at COSCUP 2023
  • -Supported Platforms

    -

    -ARM Cortex-M4F

    - -

    License

    Tenok is released under the BSD 2-Clause License, for detailed information please read LICENSE.

    -

    +

    Related Projects

    1. rtenv / rtenv+
    2. diff --git a/interrupt_8h_source.html b/interrupt_8h_source.html index 6114a8f..87ae627 100644 --- a/interrupt_8h_source.html +++ b/interrupt_8h_source.html @@ -88,8 +88,8 @@
      43  void *dev);
      44 
      45 #endif
      -
      int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev)
      Register the interrupt handler function to a specified IRQ.
      Definition: stm32f4_irq.c:163
      -
      void irq_init(void)
      Initialize the interrupt vector table of the processor.
      Definition: stm32f4_irq.c:148
      +
      int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev)
      Register the interrupt handler function to a specified IRQ.
      Definition: stm32f4_irq.c:169
      +
      void irq_init(void)
      Initialize the interrupt vector table of the processor.
      Definition: stm32f4_irq.c:154
      void preempt_enable(void)
      Eisable all interrupts. The function is only valid if it is called by kernel space code or in kernel ...
      Definition: v7m_port.c:26
      void preempt_disable(void)
      Disable interrupts with priority lower than KERNEL_INT_PRI. The function is only valid if it is calle...
      Definition: v7m_port.c:18
      diff --git a/kernel_8h.html b/kernel_8h.html index a539575..aede915 100644 --- a/kernel_8h.html +++ b/kernel_8h.html @@ -171,6 +171,10 @@
      }   +enum  { KERNEL_THREAD = 0 +, USER_THREAD = 1 + } +  @@ -198,6 +202,9 @@ + +

      Functions

      enum { ... }  THREAD_STATUS
       
      +enum { ... }  THREAD_TYPE
       
      diff --git a/kernel_8h_source.html b/kernel_8h_source.html index 270a2c6..1090a63 100644 --- a/kernel_8h_source.html +++ b/kernel_8h_source.html @@ -112,118 +112,122 @@
      41  THREAD_TERMINATED
      42 } THREAD_STATUS;
      43 
      -
      44 /* stack layout for threads without using fpu */
      -
      45 struct stack {
      -
      46  /* registers pushed into the stack by the os */
      -
      47  uint32_t r4_to_r11[8]; /* r4, ..., r11 */
      -
      48  uint32_t _lr;
      -
      49  uint32_t _r7; /* r7 (syscall number) */
      -
      50 
      -
      51  /* registers pushed into the stack by exception entry */
      -
      52  uint32_t r0, r1, r2, r3;
      -
      53  uint32_t r12_lr_pc_xpsr[4]; /* r12, lr, pc, xpsr */
      -
      54 
      -
      55  /* rest of the stack */
      -
      56  uint32_t stack[TASK_STACK_SIZE - 17];
      -
      57 };
      -
      58 
      -
      59 /* stack layout for threads that using fpu */
      -
      60 struct stack_fpu {
      -
      61  /* registeres pushed into the stack by the os */
      -
      62  uint32_t r4_to_r11[8]; /* r4, ..., r11 */
      -
      63  uint32_t _lr;
      -
      64  uint32_t _r7; /* r7 (syscall number) */
      -
      65  uint32_t s16_to_s31[16]; /* s16, ..., s31 */
      -
      66 
      -
      67  /* registers pushed into the stack by exception entry */
      -
      68  uint32_t r0, r1, r2, r3;
      -
      69  uint32_t r12_lr_pc_xpsr[4]; /* r12, lr, pc, xpsr */
      -
      70  uint32_t s0_to_s15_fpscr[17]; /* s0, ..., s15, fpscr */
      +
      44 enum {
      +
      45  KERNEL_THREAD = 0,
      +
      46  USER_THREAD = 1
      +
      47 } THREAD_TYPE;
      +
      48 
      +
      49 /* stack layout for threads without using fpu */
      +
      50 struct stack {
      +
      51  /* registers pushed into the stack by the os */
      +
      52  uint32_t r4_to_r11[8]; /* r4, ..., r11 */
      +
      53  uint32_t _lr;
      +
      54  uint32_t _r7; /* r7 (syscall number) */
      +
      55 
      +
      56  /* registers pushed into the stack by exception entry */
      +
      57  uint32_t r0, r1, r2, r3;
      +
      58  uint32_t r12_lr_pc_xpsr[4]; /* r12, lr, pc, xpsr */
      +
      59 
      +
      60  /* rest of the stack */
      +
      61  uint32_t stack[TASK_STACK_SIZE - 17];
      +
      62 };
      +
      63 
      +
      64 /* stack layout for threads that using fpu */
      +
      65 struct stack_fpu {
      +
      66  /* registeres pushed into the stack by the os */
      +
      67  uint32_t r4_to_r11[8]; /* r4, ..., r11 */
      +
      68  uint32_t _lr;
      +
      69  uint32_t _r7; /* r7 (syscall number) */
      +
      70  uint32_t s16_to_s31[16]; /* s16, ..., s31 */
      71 
      -
      72  /* rest of the stack */
      -
      73  uint32_t stack[TASK_STACK_SIZE - 50];
      -
      74 };
      -
      75 
      -
      76 struct task_struct {
      -
      77  int pid;
      -
      78 
      -
      79  /* file descriptors table */
      -
      80  struct fdtable fdtable[FILE_DESC_CNT_MAX];
      -
      81  int fd_cnt;
      -
      82 
      -
      83  struct list threads_list; /* all threads held by the task */
      -
      84  struct list list;
      -
      85 };
      -
      86 
      -
      87 struct thread_info {
      -
      88  struct stack *stack_top; /* stack pointer */
      -
      89  uint32_t stack[TASK_STACK_SIZE]; /* stack memory */
      -
      90  uint32_t stack_size;
      +
      72  /* registers pushed into the stack by exception entry */
      +
      73  uint32_t r0, r1, r2, r3;
      +
      74  uint32_t r12_lr_pc_xpsr[4]; /* r12, lr, pc, xpsr */
      +
      75  uint32_t s0_to_s15_fpscr[17]; /* s0, ..., s15, fpscr */
      +
      76 
      +
      77  /* rest of the stack */
      +
      78  uint32_t stack[TASK_STACK_SIZE - 50];
      +
      79 };
      +
      80 
      +
      81 struct task_struct {
      +
      82  int pid;
      +
      83 
      +
      84  /* file descriptors table */
      +
      85  struct fdtable fdtable[FILE_DESC_CNT_MAX];
      +
      86  int fd_cnt;
      +
      87 
      +
      88  struct list threads_list; /* all threads held by the task */
      +
      89  struct list list;
      +
      90 };
      91 
      -
      92  struct task_struct *task; /* the task of this thread */
      -
      93 
      -
      94  struct {
      -
      95  uint32_t *r0, *r1, *r2, *r3;
      -
      96  } reg;
      -
      97 
      -
      98  uint8_t status;
      -
      99  uint32_t pid;
      -
      100  uint32_t tid;
      -
      101  int priority;
      -
      102  char name[TASK_NAME_LEN_MAX];
      -
      103  bool privileged; /* kernel thread if set true */
      -
      104  bool syscall_pending;
      -
      105  uint32_t sleep_ticks; /* remained ticks to sleep before wake up */
      -
      106 
      -
      107  struct {
      -
      108  size_t size;
      -
      109  } file_request;
      +
      92 struct thread_info {
      +
      93  struct stack *stack_top; /* stack pointer */
      +
      94  uint32_t stack[TASK_STACK_SIZE]; /* stack memory */
      +
      95  uint32_t stack_size;
      +
      96 
      +
      97  struct task_struct *task; /* the task of this thread */
      +
      98 
      +
      99  struct {
      +
      100  uint32_t *r0, *r1, *r2, *r3;
      +
      101  } reg;
      +
      102 
      +
      103  uint8_t status;
      +
      104  uint32_t tid;
      +
      105  int priority;
      +
      106  char name[TASK_NAME_LEN_MAX];
      +
      107  uint32_t privilege;
      +
      108  bool syscall_pending;
      +
      109  uint32_t sleep_ticks; /* remained ticks to sleep before wake up */
      110 
      -
      111  /* signal table */
      -
      112  int *ret_sig;
      -
      113  bool wait_for_signal;
      -
      114  sigset_t sig_wait_set; /* the signal set of the thread to wait */
      -
      115  uint32_t stack_top_preserved;
      -
      116  struct sigaction *sig_table[SIGNAL_CNT];
      -
      117 
      -
      118  /* timers */
      -
      119  int timer_cnt;
      -
      120  struct list timers_list;
      +
      111  struct {
      +
      112  size_t size;
      +
      113  } file_request;
      +
      114 
      +
      115  /* signal table */
      +
      116  int *ret_sig;
      +
      117  bool wait_for_signal;
      +
      118  sigset_t sig_wait_set; /* the signal set of the thread to wait */
      +
      119  uint32_t stack_top_preserved;
      +
      120  struct sigaction *sig_table[SIGNAL_CNT];
      121 
      -
      122  /* poll */
      -
      123  bool poll_failed;
      -
      124  wait_queue_head_t poll_wq;
      -
      125  struct timespec poll_timeout;
      -
      126  struct list poll_files_list;
      -
      127 
      -
      128  struct list task_list; /* list head for the task to track */
      -
      129  struct list thread_list; /* global list of threads */
      -
      130  struct list poll_list; /* list head for the poll handler to track */
      -
      131  struct list join_list; /* list head of other threads to wait for join of the thread */
      -
      132  struct list list; /* list head for thread scheduling */
      -
      133 };
      -
      134 
      -
      135 int kthread_create(task_func_t task_func, uint8_t priority, int stack_size);
      -
      136 
      -
      137 void set_syscall_pending(struct thread_info *task);
      -
      138 void reset_syscall_pending(struct thread_info *task);
      -
      139 
      -
      140 struct task_struct *current_task_info(void);
      -
      141 struct thread_info *current_thread_info(void);
      -
      142 
      -
      143 void sched_start(void);
      -
      144 
      -
      145 #endif
      +
      122  /* timers */
      +
      123  int timer_cnt;
      +
      124  struct list timers_list;
      +
      125 
      +
      126  /* poll */
      +
      127  bool poll_failed;
      +
      128  wait_queue_head_t poll_wq;
      +
      129  struct timespec poll_timeout;
      +
      130  struct list poll_files_list;
      +
      131 
      +
      132  struct list task_list; /* list head for the task to track */
      +
      133  struct list thread_list; /* global list of threads */
      +
      134  struct list poll_list; /* list head for the poll handler to track */
      +
      135  struct list join_list; /* list head of other threads to wait for join of the thread */
      +
      136  struct list list; /* list head for thread scheduling */
      +
      137 };
      +
      138 
      +
      139 int kthread_create(task_func_t task_func, uint8_t priority, int stack_size);
      +
      140 
      +
      141 void set_syscall_pending(struct thread_info *task);
      +
      142 void reset_syscall_pending(struct thread_info *task);
      +
      143 
      +
      144 struct task_struct *current_task_info(void);
      +
      145 struct thread_info *current_thread_info(void);
      +
      146 
      +
      147 void sched_start(void);
      +
      148 
      +
      149 #endif
      Definition: fs.h:99
      Definition: list.h:23
      Definition: signal.h:35
      -
      Definition: kernel.h:60
      -
      Definition: kernel.h:45
      +
      Definition: kernel.h:65
      +
      Definition: kernel.h:50
      Definition: kernel.h:31
      -
      Definition: kernel.h:76
      -
      Definition: kernel.h:87
      +
      Definition: kernel.h:81
      +
      Definition: kernel.h:92
      Definition: time.h:14
      diff --git a/md_docs_5_platforms.html b/md_docs_5_platforms.html new file mode 100644 index 0000000..125f2f9 --- /dev/null +++ b/md_docs_5_platforms.html @@ -0,0 +1,97 @@ + + + + + + + +Tenok: Supported Platforms + + + + + + + + + +
      +
      + + + + + + + +
      +
      Tenok +
      +
      A real-time operating system for ARM Cortex-M microcontrollers
      +
      +
      + + + + + + + + +
      +
      + + +
      + +
      + +
      +
      +
      +
      Supported Platforms
      +
      +
      +

      +ARM Cortex-M4F

      +
        +
      • STM32F4DISCOVERY (STM32F407VG)
          +
        • Select by enabling include platform/stm32f4disc.mk in the Makefile
        • +
        • UART1 (console): PA9 (TX), PB7 (RX)
        • +
        • UART3 (debug-link): PC10 (TX), PC11 (RX)
        • +
        +
      • +
      • 32F429IDISCOVERY (STM32F429ZI)
          +
        • Select by enabling include platform/stm32f429disc.mk in the Makefile
        • +
        • UART1 (console): PA9 (TX), PB7 (RX)
        • +
        • UART3 (debug-link): PC10 (TX), PC11 (RX)
        • +
        +
      • +
      • QEMU Emulation of netduinoplus2 (STM32F405RGT6)
          +
        • Select by enabling include platform/qemu.mk in the Makefile
        • +
        +
      • +
      +
      +
      + + + + diff --git a/pages.html b/pages.html index 746f832..abb9c50 100644 --- a/pages.html +++ b/pages.html @@ -73,6 +73,7 @@  Build and Run  Run Tenok with Gazebo  Shell + Supported Platforms diff --git a/port_8h.html b/port_8h.html index 499faa7..8ed5bc5 100644 --- a/port_8h.html +++ b/port_8h.html @@ -128,7 +128,6 @@

      asm volatile ("push {r7} \n" \
      "mov r7, %0 \n" \
      "svc 0 \n" \
      -
      "nop \n" \
      "pop {r7} \n" \
      "bx lr \n" \
      :: "i"(num))
      diff --git a/port_8h_source.html b/port_8h_source.html index e0c4593..86ec78f 100644 --- a/port_8h_source.html +++ b/port_8h_source.html @@ -84,22 +84,21 @@
      13  asm volatile ("push {r7} \n" \
      14  "mov r7, %0 \n" \
      15  "svc 0 \n" \
      -
      16  "nop \n" \
      -
      17  "pop {r7} \n" \
      -
      18  "bx lr \n" \
      -
      19  :: "i"(num))
      -
      20 
      -
      25 uint32_t get_proc_mode(void);
      -
      26 
      -
      31 void os_env_init(uint32_t stack);
      -
      32 
      -
      40 uint32_t *jump_to_thread(uint32_t stack, bool privileged);
      -
      41 
      -
      42 #endif
      +
      16  "pop {r7} \n" \
      +
      17  "bx lr \n" \
      +
      18  :: "i"(num))
      +
      19 
      +
      24 uint32_t get_proc_mode(void);
      +
      25 
      +
      30 void os_env_init(uint32_t stack);
      +
      31 
      +
      39 uint32_t *jump_to_thread(uint32_t stack, bool privileged);
      +
      40 
      +
      41 #endif
      uint32_t get_proc_mode(void)
      Get the current ARM processor mode.
      Definition: v7m_port.c:5
      uint32_t * jump_to_thread(uint32_t stack, bool privileged)
      Jump to the thread given by the stack (context switch)
      void os_env_init(uint32_t stack)
      Initialze the operating system to split kernel space and user space.
      -
      Definition: kernel.h:45
      +
      Definition: kernel.h:50