Skip to content

Commit 6ec8361

Browse files
authored
Merge pull request #180 from f9micro/notification
Add unified notification system
2 parents 3499966 + 9708590 commit 6ec8361

30 files changed

Lines changed: 2048 additions & 46 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ jobs:
6262
- name: Enable test suite
6363
run: |
6464
# Enable test suite, disable conflicting apps
65+
sed -i 's/^CONFIG_PINGPONG=y/# CONFIG_PINGPONG is not set/' .config
6566
echo "CONFIG_TESTS=y" >> .config
66-
echo "# CONFIG_PINGPONG is not set" >> .config
67-
echo "# CONFIG_L4_TEST is not set" >> .config
68-
make oldconfig
67+
python3 tools/kconfig/genconfig.py --header-path include/autoconf.h Kconfig
6968
7069
- name: Build kernel with tests
7170
run: make

‎board/discoveryf4/defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,4 @@ CONFIG_PINGPONG=y
163163
# Test Cases
164164
#
165165
# CONFIG_EXTI_INTERRUPT_TEST is not set
166-
CONFIG_L4_TEST=y
167166
# CONFIG_LCD_TEST is not set

‎board/discoveryf429/defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,4 @@ CONFIG_PINGPONG=y
163163
# Test Cases
164164
#
165165
CONFIG_EXTI_INTERRUPT_TEST=y
166-
CONFIG_L4_TEST=y
167166
CONFIG_LCD_TEST=y

‎board/netduinoplus2/defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,4 @@ CONFIG_PINGPONG=y
163163
# Test Cases
164164
#
165165
# CONFIG_EXTI_INTERRUPT_TEST is not set
166-
CONFIG_L4_TEST=y
167166
# CONFIG_LCD_TEST is not set

‎board/nucleof429/defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ CONFIG_ETH_USER_IRQ=y
66
CONFIG_BUILD_USER_APPS=y
77
CONFIG_PINGPONG=y
88
CONFIG_EXTI_INTERRUPT_TEST=y
9-
CONFIG_L4_TEST=y

‎include/debug.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ typedef enum {
2323
DL_SYSCALL = 0x0010,
2424
DL_SCHEDULE = 0x0020,
2525
DL_MEMORY = 0x0040,
26-
DL_IPC = 0x0080
26+
DL_IPC = 0x0080,
27+
DL_NOTIFICATIONS = 0x0100 /* Unified notification system */
2728
} dbg_layer_t;
2829

2930
#ifndef CONFIG_DEBUG

‎include/interrupt_ipc.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ enum {
77
IRQ_IPC_TID = 1,
88
IRQ_IPC_HANDLER = 2,
99
IRQ_IPC_ACTION = 3,
10-
IRQ_IPC_PRIORITY = 4
10+
IRQ_IPC_PRIORITY = 4,
11+
IRQ_IPC_FLAGS = 5
1112
};
1213

13-
#define IRQ_IPC_MSG_NUM IRQ_IPC_PRIORITY
14+
#define IRQ_IPC_MSG_NUM IRQ_IPC_FLAGS
1415

1516
/* irq actions */
1617
enum { USER_IRQ_ENABLE = 0, USER_IRQ_DISABLE = 1, USER_IRQ_FREE = 2 };
1718

19+
/* IRQ delivery mode flags */
20+
#define IRQ_DELIVER_IPC 0x0000 /* Full IPC delivery (default) */
21+
#define IRQ_DELIVER_NOTIFY 0x0001 /* Fast notification delivery */
22+
1823
#define USER_INTERRUPT_LABEL 0x928
1924

2025
#endif

‎include/ktimer.h‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
#include <types.h>
1010

11+
/* Forward declaration */
12+
struct tcb;
13+
1114
void ktimer_handler(void);
1215

1316
/* Returns 0 if successfully handled
@@ -22,14 +25,50 @@ typedef struct ktimer_event {
2225

2326
uint32_t delta;
2427
void *data;
28+
29+
/* Notification mode: if notify_thread is non-NULL, timer uses
30+
* async event notification instead of calling handler directly.
31+
* This integrates with Event-Chaining + ASYNC_SOFTIRQ subsystem.
32+
*/
33+
struct tcb *notify_thread; /* Target thread for notification */
34+
uint32_t notify_bits; /* Notification bit mask to signal */
35+
36+
/* Deadline tracking for periodic timers (prevents drift accumulation).
37+
* For periodic timers, deadline tracks absolute target time.
38+
* Reschedule based on: next_ticks = max(1, deadline - now)
39+
* This maintains phase-lock to original schedule even if softirq delayed.
40+
*/
41+
uint64_t deadline; /* Absolute deadline (in ticks since boot) */
2542
} ktimer_event_t;
2643

2744
void ktimer_event_init(void);
2845

2946
int ktimer_event_schedule(uint32_t ticks, ktimer_event_t *kte);
47+
48+
/* Callback-based timer (traditional API) */
3049
ktimer_event_t *ktimer_event_create(uint32_t ticks,
3150
ktimer_event_handler_t handler,
3251
void *data);
52+
53+
/* Notification-based timer (Event-Chaining + ASYNC_SOFTIRQ integration).
54+
* When timer expires, posts async event to notify_thread with notify_bits.
55+
* Thread receives notification via Event-Chaining callback.
56+
*
57+
* @param ticks Timer period in ticks
58+
* @param notify_thread Target thread to notify (must be valid TCB)
59+
* @param notify_bits Notification bit mask to signal
60+
* @param periodic If 0, one-shot timer. If non-zero, reschedule with same
61+
* period.
62+
* @return Allocated timer event, or NULL if pool exhausted
63+
*
64+
* NOTE: For one-shot timers, event is freed automatically after firing.
65+
* For periodic timers, event remains allocated until explicitly freed.
66+
*/
67+
ktimer_event_t *ktimer_event_create_notify(uint32_t ticks,
68+
struct tcb *notify_thread,
69+
uint32_t notify_bits,
70+
int periodic);
71+
3372
void ktimer_event_handler(void);
3473

3574
#ifdef CONFIG_KTIMER_TICKLESS

0 commit comments

Comments
 (0)