This commit is contained in:
2026-06-08 23:39:25 +07:00
parent 09224c1552
commit 3a194bdb2a
11 changed files with 360 additions and 91 deletions
-28
View File
@@ -1,28 +0,0 @@
#include <stdio.h>
#include <string.h>
#include "esp_heap_caps.h"
#include "esp_cpu.h"
typedef int (*func_t)(void);
void run_app_from_iram(void)
{
uint8_t code[] = {
0x36, 0x41, 0x00, 0x2c, 0xa2, 0x1d, 0xf0
};
void *exec = heap_caps_malloc(sizeof(code),
MALLOC_CAP_EXEC | MALLOC_CAP_8BIT);
memcpy(exec, code, sizeof(code));
//esp_cpu_invalidate_icache_all();
func_t f = (func_t)exec;
int result = f();
printf("Result = %d\n", result); // Должно быть 42
heap_caps_free(exec);
}
-2
View File
@@ -1,6 +1,4 @@
#ifndef RT_HPP
#define RT_HPP
void run_app_from_iram();
#endif
+56
View File
@@ -0,0 +1,56 @@
#ifndef UART_HPP
#define UART_HPP
#include "drivers/fs/handlers.hpp"
#include "boot/answer_code.hpp"
extern Handler_vfs boot_handler;
Result uart_read(descriptor *fn) {
int c = getchar();
fn->ret.int_v = c;
return {OS_OK, *fn};
}
Result uart_write(descriptor *fn) {
for (int i = 0; i < 8; i++) {
if (fn->args[i].type == argNONE_t) {
break;
}
switch (fn->args[i].type) {
case argINT_t:
printf("%d",fn->args[i].value.valueINT);
break;
case argFLOAT_t:
printf("%f",fn->args[i].value.valueFLOAT);
break;
case argSTRING_t:
printf("%s", fn->args[i].value.valueSTRING);
break;
default:
break;
}
}
return {OS_OK, *fn};
}
uint32_t regist_uart() {
uint32_t err;
err = boot_handler.link_function("/uart/read", uart_read);
printf("\tmount uart_read: ");
if (err != OS_OK) {
return err;
printf("err(%s)\n", get_error(err));
}
printf("ok\n");
err = boot_handler.link_function("/uart/write", uart_write);
printf("\tmount uart_write: ");
if (err != OS_OK) {
return err;
printf("err(%s)\n", get_error(err));
}
printf("ok\n");
return OS_OK;
}
#endif