All uncommitted work from ESP32 GDB stub development session. Includes: - GDB stub (uos_gdbstub.c/.h/_entry.S) - Startup vector table rewrite - ESP32 HAL integration files - Boot chain design docs - AGENTS.md absolute rules (commit before refactor, no unauthorized changes) - All prior deepseek session work This commit prevents further data loss. No claims of correctness.
88 lines
2.4 KiB
C
88 lines
2.4 KiB
C
/*
|
|
* UniversalisOS — Native UOS API Test (ESP32 / Xtensa)
|
|
*
|
|
* Uses ONLY the native UniversalisOS API. No FreeRTOS shim.
|
|
* Tests: task creation, preemptive scheduling, tick delays, stack canary.
|
|
*/
|
|
#include "uos_api.h"
|
|
#include "uos_hrt.h"
|
|
|
|
/* UART — works for both ARM (0x4000C000) and ESP32 (0x3FF40000) */
|
|
#ifdef __xtensa__
|
|
#define UART0_DR (*(volatile uint32_t*)0x3FF40000)
|
|
#else
|
|
#define UART0_DR (*(volatile uint32_t*)0x4000C000)
|
|
#endif
|
|
|
|
static void putc(char c) { UART0_DR = (uint32_t)c; }
|
|
static void puts(const char *s) { while (*s) putc(*s++); }
|
|
static void putnum(uint32_t n) {
|
|
char buf[10]; int i = 0;
|
|
if (n == 0) { putc('0'); return; }
|
|
while (n > 0) { buf[i++] = '0' + (n % 10); n /= 10; }
|
|
while (i > 0) putc(buf[--i]);
|
|
}
|
|
|
|
/* Static task stacks */
|
|
static uint32_t stack1[256] __attribute__((aligned(16)));
|
|
static uint32_t stack2[256] __attribute__((aligned(16)));
|
|
static uint32_t stack3[256] __attribute__((aligned(16)));
|
|
|
|
static uos_task_t* t1;
|
|
static uos_task_t* t2;
|
|
static uos_task_t* t3;
|
|
|
|
/* Task 1 — highest priority (lowest number = highest in UOS) */
|
|
static void task1(void* arg) {
|
|
(void)arg;
|
|
for (int i = 0; i < 3; i++) {
|
|
puts("[T1] t="); putnum(uos_tick_get()); putc('\n');
|
|
uos_tick_delay(3);
|
|
}
|
|
puts("[T1] done\n");
|
|
uos_task_delete(uos_task_self());
|
|
}
|
|
|
|
/* Task 2 */
|
|
static void task2(void* arg) {
|
|
(void)arg;
|
|
for (int i = 0; i < 3; i++) {
|
|
puts("[T2] t="); putnum(uos_tick_get()); putc('\n');
|
|
uos_tick_delay(3);
|
|
}
|
|
puts("[T2] done\n");
|
|
uos_task_delete(uos_task_self());
|
|
}
|
|
|
|
/* Task 3 — lowest priority user task */
|
|
static void task3(void* arg) {
|
|
(void)arg;
|
|
for (int i = 0; i < 3; i++) {
|
|
puts("[T3] t="); putnum(uos_tick_get()); putc('\n');
|
|
uos_tick_delay(3);
|
|
}
|
|
puts("[T3] done\n");
|
|
uos_task_delete(uos_task_self());
|
|
}
|
|
|
|
int main(void) {
|
|
uos_init();
|
|
|
|
puts("\n=== UniversalisOS Native Test ===\n");
|
|
|
|
/* Native UOS task creation — NO FreeRTOS shim */
|
|
t1 = uos_task_create("T1", 3, task1, NULL, stack1, sizeof(stack1));
|
|
t2 = uos_task_create("T2", 5, task2, NULL, stack2, sizeof(stack2));
|
|
t3 = uos_task_create("T3", 7, task3, NULL, stack3, sizeof(stack3));
|
|
|
|
|
|
if (!t1 || !t2 || !t3) {
|
|
for (;;) ;
|
|
}
|
|
|
|
puts("Tasks created, starting scheduler...\n");
|
|
uos_sched_start();
|
|
|
|
/* Should never reach here */
|
|
for (;;) ;
|
|
}
|