1/* @title: Processor Exception Synchronous Work */
2#pragma once
3#include <linker/symbols.h>
4#include <stddef.h>
5#include <stdint.h>
6
7#define EXCEPTION_SYNC_CB_SCRATCH_BUFFER_SIZE 32 /* bytes */
8
9struct exception_sync_cb;
10struct irq_context;
11
12enum exception_sync_cb_result {
13 EXCEPTION_SYNC_CB_OK = 0,
14 EXCEPTION_SYNC_CB_ERR = -1, /* TODO: more */
15};
16
17typedef enum exception_sync_cb_result (*exception_sync_cb_fn)(
18 struct exception_sync_cb *this, struct irq_context *irqc,
19 uint8_t scratch_buf[EXCEPTION_SYNC_CB_SCRATCH_BUFFER_SIZE]);
20
21struct exception_sync_cb {
22 const char *name;
23 uint8_t vector;
24 exception_sync_cb_fn fn;
25 void *private;
26};
27
28LINKER_SECTION_DEFINE(struct exception_sync_cb, exception_sync_cbs);
29#define EXCEPTION_SYNC_CB_REGISTER(n, v, func, priv) \
30 LINKER_SECTION_OBJECT(struct exception_sync_cb, exception_sync_cbs) \
31 exception_sync_cb_##n = { \
32 .name = #n, .vector = v, .fn = func, .private = priv};
33