1 /*
2 * Copyright (c) 2017, Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "sys/alt_irq.h"
8 #include "altera_common.h"
9
10 #define ALTERA_MAX_IRQ 32
11
12 static alt_isr_func alt_hal_isr[ALTERA_MAX_IRQ];
13
14 #ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
alt_ic_isr_register(alt_u32 ic_id,alt_u32 irq,alt_isr_func isr,void * isr_context,void * flags)15 int alt_ic_isr_register(alt_u32 ic_id, alt_u32 irq,
16 alt_isr_func isr, void *isr_context, void *flags)
17
18 {
19 if (irq <= ALTERA_MAX_IRQ)
20 {
21 alt_hal_isr[irq] = isr;
22 return 0;
23 }
24 else
25 {
26 return -EINVAL;
27 }
28
29 }
30 #else
alt_irq_register(alt_u32 irq,void * context,alt_isr_func isr)31 int alt_irq_register(alt_u32 irq, void* context, alt_isr_func isr)
32 {
33 if (irq <= ALTERA_MAX_IRQ)
34 {
35 alt_hal_isr[irq] = isr;
36 return 0;
37 }
38 else
39 {
40 return -EINVAL;
41 }
42 }
43 #endif
44
alt_handle_irq(void * base,alt_u32 id)45 void alt_handle_irq(void* base, alt_u32 id)
46 {
47 /* Null pointer check for handler function */
48 if (!alt_hal_isr[id])
49 return;
50
51 #ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
52 alt_hal_isr[id]((void*)base);
53 #else
54 alt_hal_isr[id]((void*)base, id);
55 #endif
56 }
57
58
59 /* Add Altera HAL extern function definations here */
60
61 /*
62 * alt_tick() should only be called by the system clock driver. This is used
63 * to notify the system that the system timer period has expired.
64 */
65
alt_tick(void)66 void alt_tick (void)
67 {
68 }
69
70 #include "priv/alt_dev_llist.h"
alt_dev_llist_insert(alt_dev_llist * dev,alt_llist * list)71 int alt_dev_llist_insert (alt_dev_llist* dev, alt_llist* list)
72 {
73 return 0;
74 }
75
76 #include "priv/alt_busy_sleep.h"
77 #include <zephyr/kernel.h>
alt_busy_sleep(unsigned int us)78 unsigned int alt_busy_sleep (unsigned int us)
79 {
80 k_busy_wait(us);
81 return 0;
82 }
83
alt_printf(const char * fmt,...)84 void alt_printf(const char *fmt, ...)
85 {
86 }
87