Setting up repository
[linux-libre-firmware.git] / ath9k_htc / target_firmware / magpie_fw_dev / target / cmnos / cmnos_api.h
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 #ifndef __CMNOS_API_H__
36 #define __CMNOS_API_H__
37
38 /*
39  * This file contains wrappers to OS operating system functions
40  * that are available in all versions of the operating system.
41  *
42  * Target software must always use these wrappers to access OS
43  * services -- it may not access any OS services directly.
44  */
45
46 #include "sys_cfg.h"
47
48 #include "xtensa/config/core.h"
49 #include "xtensa/hal.h"
50 #include "xtensa/xtruntime.h"
51
52 /* cmnos interface */
53 #include "printf_api.h"
54 #include "uart_api.h"
55 #include "dbg_api.h"
56 #include "mem_api.h"
57 #include "misc_api.h"
58 #include "string_api.h"
59 #include "timer_api.h"
60 #include "romp_api.h"
61 #include "allocram_api.h"
62 #include "tasklet_api.h"
63 #include "clock_api.h"
64 #include "intr_api.h"
65 #include "wdt_api.h"
66 #include "eeprom_api.h"
67 #include "usb_api.h"
68 #include <hif_pci.h>
69 #include <hif_gmac.h>
70
71 #if defined(PROJECT_K2)
72 #if SYSTEM_MODULE_SFLASH
73 #include "sflash_api.h"
74 #endif
75 #endif
76
77 #define AR6K_ROM_START 0x004e0000
78 #define AR6K_ROM_ADDR(byte_offset) (AR6K_ROM_START+(byte_offset))
79 #define TARG_ROM_ADDRS(byte_offset) AR6K_ROM_ADDR(byte_offset)
80
81 #define IML_SIGNAL_UNUSED0_ADDR TARG_ROM_ADDRS(0)   /* Cannot be used -- aligned */
82 #define IML_SIGNAL_ASSERT_ADDR  TARG_ROM_ADDRS(1)   /* Signal an assertion failure */
83 #define IML_SIGNAL_PRINTF_ADDR  TARG_ROM_ADDRS(2)   /* Signal a printf request */
84 #define IML_SIGNAL_UNUSED4_ADDR TARG_ROM_ADDRS(4)   /* Cannot be used -- aligned */
85 #define IML_SIGNAL_UNUSED8_ADDR TARG_ROM_ADDRS(8)   /* Cannot be used -- aligned */
86 #define IML_SIGNAL_UNUSEDC_ADDR TARG_ROM_ADDRS(0xc) /* Cannot be used -- aligned */
87 #define IML_SIGNAL_MASK         0xfffe000f
88 #define IML_LINENUM_SHIFT       4
89
90 #define NOW() xthal_get_ccount()
91
92 #if defined(__XTENSA__)
93 #define _A_BARRIER asm volatile("memw")
94 #else
95 #define _A_BARRIER
96 #endif
97
98 #define A_ASSERT( __bool )                                                  \
99     do {                                                                    \
100         if (0 == (__bool)) {                                                \
101             (void)*((volatile int *)(IML_SIGNAL_ASSERT_ADDR+(__LINE__<<4)));\
102             _A_BARRIER;                                                     \
103         }                                                                   \
104     } while (0)
105
106
107 #define A_IML_IS_ASSERT(vaddr) \
108         (((vaddr) & IML_SIGNAL_MASK) == (IML_SIGNAL_ASSERT_ADDR & IML_SIGNAL_MASK))
109
110
111 #define PRINT_FAILURE_STATE()                                           \
112 do {                                                                    \
113     uint32_t  epc1, epc2, epc3, epc4;                                   \
114                                                                         \
115     asm volatile("rsr %0,%1" : "=r" (epc1) : "n" (EPC_1));              \
116     asm volatile("rsr %0,%1" : "=r" (epc2) : "n" (EPC_2));              \
117     asm volatile("rsr %0,%1" : "=r" (epc3) : "n" (EPC_3));              \
118     asm volatile("rsr %0,%1" : "=r" (epc4) : "n" (EPC_4));              \
119                                                                         \
120     A_PRINTF("\tepc1=0x%x, epc2=0x%x, epc3=0x%x, epc4=0x%x\n",            \
121                 epc1, epc2, epc3, epc4);                                \
122     A_PRINTF("0x%08x, 0x%08x, 0x%08x, \n\r",                            \
123         DEBUG_SYSTEM_STATE, WATCH_DOG_RESET_COUNTER,                    \
124         WATCH_DOG_MAGIC_PATTERN);                                       \
125 } while(0)
126 ////////////////////////////////////////////////////////////////////////////////////
127
128
129 //#define A_CMN(sym)   _A_OS_INDIRECTION_TABLE->cmnos.sym
130 #define A_CMN(sym)   _A_MAGPIE_INDIRECTION_TABLE->cmnos.sym
131
132 #if SYSTEM_MODULE_MEM
133 /* Mem interfaces */
134 #define A_MEMSET(addr, value, size)     \
135     A_CMN(mem._memset((char *)(addr), (int)(value), (int)(size)))
136
137 #define A_MEMZERO(addr, size)           \
138     A_CMN(mem._memset((char *)(addr), (int)0, (int)(size)))
139
140 #define A_MEMCPY(dst, src, size)        \
141     A_CMN(mem._memcpy((char *)(dst), (char *)(src), (int)(size)))
142
143 #define A_MEMMOVE(dst, src, size)       \
144     A_CMN(mem._memmove((char *)(dst), (char *)(src), (int)(size)))
145
146 #define A_MEMCMP(p1, p2, nbytes)        \
147     A_CMN(mem._memcmp)((void *)(p1), (void *)(p2), (int)(nbytes))
148 #else
149 /* Mem interfaces */
150 #define A_MEMSET(addr, value, size)
151
152 #define A_MEMZERO(addr, size)
153
154 #define A_MEMCPY(dst, src, size)
155
156 #define A_MEMMOVE(dst, src, size)
157
158 #define A_MEMCMP(p1, p2, nbytes)
159 #endif 
160
161
162 #if 1
163     /* String interfaces */
164     #define A_STRCPY(dst, src)          A_CMN(string._strcpy((dst), (src)))
165     #define A_STRNCPY(dst, src, n)      A_CMN(string._strncpy((dst), (src), (n)))
166     #define A_STRLEN(str)               A_CMN(string._strlen(str))
167     #define A_STRCMP(str1, str2)        A_CMN(string._strcmp((str1), (str2)))
168     #define A_STRNCMP(str1, str2, n)    A_CMN(string._strncmp((str1), (str2), (n)))
169 #endif
170
171 #if SYSTEM_MODULE_PRINT
172 /* Printf support */
173 #define A_PRINTF_INIT()                 A_CMN(printf._printf_init())
174 #define A_PRINTF                        A_CMN(printf._printf)
175 #else
176 #define A_PRINTF_INIT()
177 #define A_PRINTF
178 #endif /* SYSTEM_MODULE_PRINT */
179
180 #if SYSTEM_MODULE_UART
181 /* Serial port support */
182 #define A_UART_INIT()                 A_CMN(uart._uart_init())
183
184 #define A_UART_HWINIT(freq, baud)     \
185         A_CMN(uart._uart_hwinit((freq), (baud)))
186
187 #define A_UART_ENABLED()              (HOST_INTEREST->hi_uart_enable)
188
189 #define A_PUTS(str)                      A_CMN(uart._uart_str_out(str))
190
191 #define A_PUTC(ch)                      A_CMN(uart._uart_char_put(ch))
192 #define A_GETC(pCh)                     A_CMN(uart._uart_char_get(pCh))
193
194 #define A_UART_TASK()                 A_CMN(uart._uart_task())
195 #define A_UART_CONFIG(x)                 A_CMN(uart._uart_config(x))
196
197 #else
198
199 #define A_UART_INIT()
200
201 #define A_UART_HWINIT(freq, baud)
202
203 #define A_UART_ENABLED() 
204
205 #define A_PUTS(str)          
206
207 #define A_PUTC(ch)
208 #define A_GETC(pCh)
209
210 #define A_UART_TASK()
211 #define A_UART_CONFIG(x)
212
213 #endif
214
215 #if SYSTEM_MODULE_MISC
216 /* Reset Support */
217 #define A_RESET()                        A_CMN(misc._system_reset())
218 #define A_RESET_MAC()                    A_CMN(misc._mac_reset())
219
220 /* Assertion failure */
221 #define A_ASSFAIL(regdump)               A_CMN(misc._assfail((regdump)))
222
223 /* Report a failure to the Host */
224 #define A_REPORT_FAILURE(data, len)      \
225         A_CMN(misc._report_failure_to_host((data), (len)))
226
227 /* UNALIGNED references are used for ASSERTs */
228 #define A_MISALIGNED_LOAD_HANDLER(dump)  A_CMN(misc._misaligned_load_handler(dump))
229
230 /* reture the host interface type */
231 #define A_IS_HOST_PRESENT()              A_CMN(misc._is_host_present())
232 #define A_KBHIT(delay)                  A_CMN(misc._kbhit(delay))
233 #define A_GET_ROM_VER()                 A_CMN(misc._rom_version_get())
234 #else
235 /* Reset Support */
236 #define A_RESET()
237 #define A_RESET_MAC()
238
239 /* Assertion failure */
240 #define A_ASSFAIL(regdump)
241
242 #define A_MISALIGNED_LOAD_HANDLER(dump)
243
244 /* Report a failure to the Host */
245 #define A_REPORT_FAILURE(data, len)
246
247 #define A_IS_HOST_PRESENT()
248 #define A_KBHIT(delay)
249 #define A_GET_ROM_VER()
250 #endif 
251
252 //#if SYSTEM_MODULE_DBG
253 /* debug Support */
254 //#define A_DBG_INIT()                    A_CMN(dbg._dbg_init())
255 //#define A_DBG_TASK()                    A_CMN(dbg._dbg_task())
256 //#else
257 //#define A_DBG_INIT()
258 //#define A_DBG_TASK()
259 //#endif
260
261 #if SYSTEM_MODULE_USB
262 /* debug Support */
263 #define A_USB_INIT()                    A_CMN(usb._usb_init())
264 #define A_USB_ROM_TASK()                A_CMN(usb._usb_rom_task())
265 #define A_USB_FW_TASK()                 A_CMN(usb._usb_fw_task())
266 #define A_USB_INIT_PHY()                A_CMN(usb._usb_init_phy())
267
268 #define A_USB_EP0_SETUP()               A_CMN(usb._usb_ep0_setup())
269 #define A_USB_EP0_TX_DATA()             A_CMN(usb._usb_ep0_tx_data())
270 #define A_USB_EP0_RX_DATA()             A_CMN(usb._usb_ep0_rx_data())
271                           
272 #define A_USB_GET_CONFIG()              A_CMN(usb._usb_get_configuration())
273 #define A_USB_SET_CONFIG()              A_CMN(usb._usb_set_configuration())
274                           
275 #define A_USB_GET_INTERFACE()           A_CMN(usb._usb_get_interface())
276 #define A_USB_SET_INTERFACE()           A_CMN(usb._usb_set_interface())
277                           
278 #define A_USB_STANDARD_CMD()            A_CMN(usb._usb_standard_cmd())
279 #define A_USB_VENDOR_CMD()              A_CMN(usb._usb_vendor_cmd())
280                           
281 #define A_USB_POWER_OFF()               A_CMN(usb._usb_power_off())
282 #define A_USB_RESET_FIFO()              A_CMN(usb._usb_reset_fifo())
283 #define A_USB_GEN_WDT()                 A_CMN(usb._usb_gen_wdt())
284 #define A_USB_JUMP_BOOT()               A_CMN(usb._usb_jump_boot())
285
286 #define A_USB_GET_DESCRIPTOR()          A_CMN(usb._usb_get_descriptor())
287 #define A_USB_SET_ADDRESS()             A_CMN(usb._usb_set_address())
288 #define A_USB_SET_FEATURE()             A_CMN(usb._usb_set_feature())
289 #define A_USB_CLEAR_FEATURE()           A_CMN(usb._usb_clr_feature())
290
291 #define A_USB_GET_STATUS()              A_CMN(usb._usb_get_status())
292 #define A_USB_SETUP_DESC()              A_CMN(usb._usb_setup_desc())
293 #define A_USB_STATUS_IN()               A_CMN(usb._usb_status_in())
294 #define A_USB_REG_OUT()                 A_CMN(usb._usb_reg_out())
295
296 #define A_USB_EP0_TX()                  A_CMN(usb._usb_ep0_tx())
297 #define A_USB_EP0_RX()                  A_CMN(usb._usb_ep0_rx())
298 #define A_USB_CLK_INIT()                A_CMN(usb._usb_clk_init())
299
300 #else
301 #define A_USB_INIT()
302 #define A_USB_TASK()    
303 #define A_USB_INIT_PHY()
304
305 #define A_USB_EP0_SETUP()     
306 #define A_USB_EP0_TX()        
307 #define A_USB_EP0_RX()        
308                               
309 #define A_USB_GET_CONFIG()    
310 #define A_USB_SET_CONFIG()    
311                               
312 #define A_USB_GET_INTERFACE() 
313 #define A_USB_SET_INTERFACE() 
314                               
315 #define A_USB_STANDARD_CMD()  
316 #define A_USB_VENDOR_CMD()    
317                               
318 #define A_USB_POWER_OFF()
319 #define A_USB_RESET_FIFO()
320 #define A_USB_GEN_WDT()
321 #define A_USB_JUMP_BOOT()
322
323 #define A_USB_GET_DESCRIPTOR()
324 #define A_USB_SET_ADDRESS()   
325 #define A_USB_SET_FEATURE()   
326 #define A_USB_CLEAR_FEATURE() 
327
328 #define A_USB_GET_STATUS()
329 #define A_USB_SETUP_DESC()
330
331
332 #define A_USB_STATUS_IN()
333 #define A_USB_REG_OUT()
334
335 #define A_USB_EP0_TX()
336 #define A_USB_EP0_RX()
337
338 #define A_USB_CLK_INIT()
339 #endif
340
341 #if SYSTEM_MODULE_INTR
342 /* Low-level interrupt support intended for use by OS modules */
343 #define A_INTR_GET_INTRENABLE()         A_CMN(intr._get_intrenable())
344 #define A_INTR_SET_INTRENABLE(val)      A_CMN(intr._set_intrenable(val))
345 #define A_INTR_GET_INTRPENDING()        A_CMN(intr._get_intrpending())
346 #define A_INTR_UNBLOCK_ALL_INTRLVL()    A_CMN(intr._unblock_all_intrlvl())
347
348 /* Interrupt support */
349 #define A_INTR_INIT()                   A_CMN(intr._intr_init())
350
351 #define  A_INTR_DISABLE(pOld)                           \
352     do {                                                \
353         *(pOld) = A_CMN(intr._intr_disable());        \
354     } while (0)
355
356 #define  A_INTR_RESTORE(old)            A_CMN(intr._intr_restore((old)))
357
358 #define A_INVOKE_ISR(inum)              A_CMN(intr._intr_invoke_isr(inum))
359
360 #define A_INTR_MASK(inum)               A_CMN(intr._intr_mask_inum(inum))
361 #define A_INTR_UNMASK(inum)             A_CMN(intr._intr_unmask_inum(inum))
362
363 #define A_ATTACH_ISR(inum, isr, arg)    A_CMN(intr._intr_attach_isr(inum, isr, arg))
364 #else
365 #define A_INTR_INIT()
366 #define  A_INTR_DISABLE(pOld)
367 #define  A_INTR_RESTORE(old)
368
369 #define A_INTR_GET_INTRENABLE()
370 #define A_INTR_SET_INTRENABLE(val)
371 #define A_INTR_GET_INTRPENDING()
372 #define A_INTR_UNBLOCK_ALL_INTRLVL()
373 #define A_INVOKE_ISR(inum)
374 #define A_INTR_MASK(inum)
375 #define A_INTR_UNMASK(inum)
376 #define A_ATTACH_ISR(inum, isr, arg)
377
378 #endif
379
380 /* Tasklet Support */
381 #define A_TASKLET_INIT()                    A_CMN(tasklet._tasklet_init())
382 #define A_TASKLET_INIT_TASK(f, arg, t)      A_CMN(tasklet._tasklet_init_task(f, arg, t))
383 #define A_TASKLET_DISABLE(t)                A_CMN(tasklet._tasklet_disable(t))
384 #define A_TASKLET_SCHEDULE(t)               A_CMN(tasklet._tasklet_schedule(t))
385 #define A_TASKLET_RUN()                     A_CMN(tasklet._tasklet_run())
386
387
388 /* RAM Allocation Support */
389 #if defined(__mips__)
390 #define alloc_arena_start _end
391 #endif
392 #if defined(__XTENSA__)
393 #define alloc_arena_start _end
394 #endif
395
396 #if SYSTEM_MODULE_CLOCK
397
398 #define A_CLOCK_INIT(refclk_guess)    A_CMN(clock._clock_init(refclk_guess))
399 #define A_CLOCK_TICK()                A_CMN(clock._clock_tick())
400 #define A_CLOCK_GET_TICK()            A_CMN(clock._clock_get_tick())
401
402 /*
403  * Get the number of millisecond ticks since the system was started.
404  * Note that this only approximates 1Ms.  It's actually 32 ticks of
405  * a 32KHz clock.
406  *
407  * Returns a A_UINT32 value.
408  */
409 #define A_MILLISECONDS()                A_CMN(clock._milliseconds())
410
411 /*
412  * Get the frequency of the reference clock, expressed as
413  * an A_refclk_speed_t.
414  */
415 #define A_REFCLK_SPEED_GET()            A_CMN(clock._refclk_speed_get())
416
417 /* Spin delay */
418 #define A_DELAY_USECS(us)               A_CMN(clock._delay_us(us))
419
420 #define A_UART_FREQUENCY()              A_CMN(clock._uart_frequency())
421
422 #define A_CLOCKREGS_INIT()              A_CMN(clock._clockregs_init())
423
424 /* which_band is either A_BAND_24GHZ or A_BAND_5GHZ */
425 #define A_WLAN_BAND_SET(which_band)      \
426         A_CMN(clock._wlan_band_set(which_band))
427
428 /* Called whenever the system clock changes speed */
429 #define A_SYSCLK_CHANGE()               A_CMN(clock._sysclk_change())
430
431 #else
432
433 #define A_CLOCK_INIT(refclk_guess)
434 #define A_CLOCK_TICK()
435 #define A_CLOCK_GET_TICK()
436 #define A_MILLISECONDS()
437 #define A_REFCLK_SPEED_GET()
438 #define A_DELAY_USECS(us)
439 #define A_UART_FREQUENCY()
440 #define A_CLOCKREGS_INIT()
441 #define A_WLAN_BAND_SET(which_band)
442 #define A_SYSCLK_CHANGE()
443
444 #endif
445
446 // Timer
447 #define A_INIT_TIMER(pTimer, pFunction, pArg) \
448     A_CMN(timer._timer_setfn((pTimer), (pFunction), (pArg)))
449
450 /* Set a (possibly periodic) timer for "period" Milliseconds. */
451 #define A_TIMEOUT_MS(pTimer, period) \
452     A_CMN(timer._timer_arm((pTimer), (period)))
453
454 #define A_UNTIMEOUT(pTimer) \
455     A_CMN(timer._timer_disarm(pTimer))
456
457 #define A_TIMER_RUN() \
458     A_CMN(timer._timer_run())
459
460 #define A_PCI_BOOT_INIT() \
461     A_CMN(pci.pci_boot_init()) 
462
463 #define A_GMAC_BOOT_INIT() \
464     A_CMN(gmac.gmac_boot_init()) 
465
466 #if SYSTEM_MODULE_ALLOCRAM
467 /* Default size of ALLOCRAM area */
468 #define ARENA_SZ_DEFAULT 12000
469
470 #define A_ALLOCRAM_INIT(arena_start, arena_size)                                   \
471 do {                                                                               \
472     extern unsigned int alloc_arena_start;                                                 \
473     void *astart;                                                                  \
474     int asize;                                                                     \
475     astart = (arena_start) ? (void *)(arena_start) : &alloc_arena_start;           \
476     asize = (arena_size) ? (arena_size) : (ARENA_SZ_DEFAULT);                      \
477     A_CMN(allocram.cmnos_allocram_init((astart), (asize)));                        \
478 } while (0)
479
480 #define A_ALLOCRAM(nbytes)    A_CMN(allocram.cmnos_allocram(0, (nbytes)))
481
482 #define A_ALLOCRAM_DEBUG()    A_CMN(allocram.cmnos_allocram_debug())
483
484 #else
485 #define A_ALLOCRAM_INIT(arena_start, arena_size)
486 #define A_ALLOCRAM(nbytes)
487 #define A_ALLOCRAM_DEBUG()
488 #endif
489
490 #if SYSTEM_MODULE_ROM_PATCH
491
492 #define A_ROMP_INIT()           A_CMN(romp._romp_init())
493 #define A_ROMP_DOWNLOAD(x)      A_CMN(romp._romp_download(x))
494 #define A_ROMP_DECODE(addr)     A_CMN(romp._romp_decode(addr))
495 #define A_ROMP_INSTALL()        A_CMN(romp._romp_install())
496 #else
497 #define A_ROMP_INIT()
498 #define A_ROMP_DOWNLOAD(x)
499 #define A_ROMP_DECODE(addr)
500 #define A_ROMP_INSTALL()
501 #endif
502
503 #if SYSTEM_MODULE_WDT
504
505 #define A_WDT_INIT()            A_CMN(wdt_timer._wdt_init())
506 #define A_WDT_ENABLE()          A_CMN(wdt_timer._wdt_enable())
507 #define A_WDT_DISABLE()         A_CMN(wdt_timer._wdt_disable())
508 #define A_WDT_SET(t)            A_CMN(wdt_timer._wdt_set(t))
509 #define A_WDT_TASK()            A_CMN(wdt_timer._wdt_task())
510 #define A_WDT_LASTBOOT()        A_CMN(wdt_timer._wdt_last_boot())
511 #define A_WDT_RESET()           A_CMN(wdt_timer._wdt_reset())
512
513 #else
514 #define A_WDT_INIT()
515 #define A_WDT_ENABLE()
516 #define A_WDT_DISABLE()
517 #define A_WDT_SET(t)
518 #define A_WDT_TASK()
519 #define A_WDT_LASTBOOT()
520 #define A_WDT_RESET()
521 #endif
522
523
524 #if SYSTEM_MODULE_EEPROM
525 #define A_EEP_INIT()                    A_CMN(eep._eep_init())
526 #define A_EEP_READ(off, len, buf)       A_CMN(eep._eep_read(off, len, buf))
527 #define A_EEP_WRITE(off, len, buf)      A_CMN(eep._eep_write(off, len, buf))
528 #define A_EEP_IS_EXIST()                A_CMN(eep._eep_is_exist())
529 #else
530 #define A_EEP_INIT()
531 #define A_EEP_READ(off, len, buf)
532 #define A_EEP_WRITE(off, len, buf)
533 #define A_EEP_IS_EXIST()
534 #endif
535
536
537
538 struct _A_os_linkage_check; /* OS-dependent */
539
540 typedef struct _A_cmnos_indirection_table {
541     int (* hal_linkage_check)(int sz, struct _A_os_linkage_check *);
542     unsigned int *start_bss;
543     void (* app_start)(void);
544     
545 #if SYSTEM_MODULE_MEM
546     struct mem_api    mem;
547 #endif
548
549 #if SYSTEM_MODULE_MISC
550     struct misc_api     misc;
551 #endif
552
553 #if SYSTEM_MODULE_PRINT
554     struct printf_api    printf;
555 #endif
556
557 #if SYSTEM_MODULE_UART
558     struct uart_api      uart;
559 #endif
560
561 //#if SYSTEM_MODULE_DBG
562 //    struct dbg_api      dbg;
563 //#endif
564
565 #if SYSTEM_MODULE_PCI
566    struct pci_api pci;
567 #endif
568
569 #if SYSTEM_MODULE_GMAC
570    struct gmac_api gmac;
571 #endif
572
573 #if SYSTEM_MODULE_USB
574     struct usb_api      usb;
575 #endif
576
577 #if SYSTEM_MODULE_CLOCK
578     struct clock_api     clock;
579 #endif
580
581 #if SYSTEM_MODULE_TIMER
582     struct timer_api     timer;
583 #endif
584
585 #if SYSTEM_MODULE_INTR
586     struct intr_api     intr;
587 #endif
588
589 #if SYSTEM_MODULE_ALLOCRAM
590     struct allocram_api     allocram;
591 #endif
592
593 #if SYSTEM_MODULE_ROM_PATCH
594     struct romp_api     romp;
595 #endif
596
597 #if SYSTEM_MODULE_WDT
598     struct wdt_api     wdt_timer;
599 #endif
600
601 #if SYSTEM_MODULE_EEPROM
602     struct eep_api     eep;
603 #endif
604
605     struct string_api   string;
606     struct tasklet_api  tasklet;
607
608 } _A_cmnos_indirection_table_t;
609
610 /* Module installation  for cmnos modules */
611
612 #if SYSTEM_MODULE_MEM
613 extern void cmnos_mem_module_install(struct mem_api *);
614 #endif
615
616 #if SYSTEM_MODULE_MISC
617 extern void cmnos_misc_module_install(struct misc_api *);
618 #endif
619
620 #if SYSTEM_MODULE_PRINT
621 extern void cmnos_printf_module_install(struct printf_api *);
622 #endif
623
624 #if SYSTEM_MODULE_UART
625 extern void cmnos_uart_module_install(struct uart_api *);
626 #endif
627
628 //#if SYSTEM_MODULE_DBG
629 //extern void cmnos_dbg_module_install(struct dbg_api *);
630 //#endif
631
632 #if SYSTEM_MODULE_USB
633 extern void cmnos_usb_module_install(struct usb_api *);
634 #endif
635
636 #if SYSTEM_MODULE_INTR
637 extern void cmnos_intr_module_install(struct intr_api *);
638 #endif
639
640 #if SYSTEM_MODULE_CLOCK
641 extern void cmnos_clock_module_install(struct clock_api *);
642 #endif
643
644 #if SYSTEM_MODULE_TIMER
645 extern void cmnos_timer_module_install(struct timer_api *);
646 #endif
647
648 #if SYSTEM_MODULE_ALLOCRAM
649 extern void cmnos_allocram_module_install(struct allocram_api *);
650 #endif
651
652 #if SYSTEM_MODULE_ROM_PATCH
653 extern void cmnos_romp_module_install(struct romp_api *);
654 #endif
655
656 #if SYSTEM_MODULE_WDT
657 extern void cmnos_wdt_module_install(struct wdt_api *);
658 #endif
659
660 #if SYSTEM_MODULE_EEPROM
661 extern void cmnos_eep_module_install(struct eep_api *);
662 #endif
663
664 #if SYSTEM_MODULE_PCI
665 extern void cmnos_pci_module_install(struct pci_api *);
666 #endif
667
668 extern void cmnos_tasklet_module_install(struct tasklet_api *);
669
670 extern void cmnos_string_module_install(struct string_api *tbl);
671
672 #endif /* __CMNOS_API_H__ */