1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
|
/****************************************************************************
* include/nuttx/arch.h
*
* Copyright (C) 2007-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_ARCH_H
#define __INCLUDE_NUTTX_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <sched.h>
#include <arch/arch.h>
/****************************************************************************
* Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
typedef CODE void (*sig_deliver_t)(FAR struct tcb_s *tcb);
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* These are standard interfaces that must be exported to the
* scheduler from architecture-specific code.
****************************************************************************/
/****************************************************************************
* Name: up_initialize
*
* Description:
* up_initialize will be called once during OS
* initialization after the basic OS services have been
* initialized. The architecture specific details of
* initializing the OS will be handled here. Such things as
* setting up interrupt service routines, starting the
* clock, and registering device drivers are some of the
* things that are different for each processor and hardware
* platform.
*
* up_initialize is called after the OS initialized but
* before the init process has been started and before the
* libraries have been initialized. OS services and driver
* services are available.
*
****************************************************************************/
void up_initialize(void);
/****************************************************************************
* Name: up_idle
*
* Description:
* up_idle() is the logic that will be executed
* when their is no other ready-to-run task. This is processor
* idle time and will continue until some interrupt occurs to
* cause a context switch from the idle task.
*
* Processing in this state may be processor-specific. e.g.,
* this is where power management operations might be performed.
*
****************************************************************************/
void up_idle(void);
/****************************************************************************
* Name: up_initial_state
*
* Description:
* A new thread is being started and a new TCB
* has been created. This function is called to initialize
* the processor specific portions of the new TCB.
*
* This function must setup the intial architecture registers
* and/or stack so that execution will begin at tcb->start
* on the next context switch.
*
****************************************************************************/
void up_initial_state(FAR struct tcb_s *tcb);
/****************************************************************************
* Name: up_create_stack
*
* Description:
* Allocate a stack for a new thread and setup
* up stack-related information in the TCB.
*
* The following TCB fields must be initialized:
* adj_stack_size: Stack size after adjustment for hardware,
* processor, etc. This value is retained only for debug
* purposes.
* stack_alloc_ptr: Pointer to allocated stack
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
* initial value of the stack pointer.
*
* Inputs:
* tcb: The TCB of new task
* stack_size: The requested stack size. At least this much
* must be allocated.
*
****************************************************************************/
#ifndef CONFIG_CUSTOM_STACK
int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size);
#endif
/****************************************************************************
* Name: up_use_stack
*
* Description:
* Setup up stack-related information in the TCB
* using pre-allocated stack memory
*
* The following TCB fields must be initialized:
* adj_stack_size: Stack size after adjustment for hardware,
* processor, etc. This value is retained only for debug
* purposes.
* stack_alloc_ptr: Pointer to allocated stack
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
* initial value of the stack pointer.
*
* Inputs:
* tcb: The TCB of new task
* stack_size: The allocated stack size.
*
****************************************************************************/
#ifndef CONFIG_CUSTOM_STACK
int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size);
#endif
/****************************************************************************
* Name: up_release_stack
*
* Description:
* A task has been stopped. Free all stack
* related resources retained int the defunct TCB.
*
****************************************************************************/
#ifndef CONFIG_CUSTOM_STACK
void up_release_stack(FAR struct tcb_s *dtcb);
#endif
/****************************************************************************
* Name: up_unblock_task
*
* Description:
* A task is currently in an inactive task list
* but has been prepped to execute. Move the TCB to the
* ready-to-run list, restore its context, and start execution.
*
* This function is called only from the NuttX scheduling
* logic. Interrupts will always be disabled when this
* function is called.
*
* Inputs:
* tcb: Refers to the tcb to be unblocked. This tcb is
* in one of the waiting tasks lists. It must be moved to
* the ready-to-run list and, if it is the highest priority
* ready to run taks, executed.
*
****************************************************************************/
void up_unblock_task(FAR struct tcb_s *tcb);
/****************************************************************************
* Name: up_block_task
*
* Description:
* The currently executing task at the head of
* the ready to run list must be stopped. Save its context
* and move it to the inactive list specified by task_state.
*
* This function is called only from the NuttX scheduling
* logic. Interrupts will always be disabled when this
* function is called.
*
* Inputs:
* tcb: Refers to a task in the ready-to-run list (normally
* the task at the head of the list). It most be
* stopped, its context saved and moved into one of the
* waiting task lists. It it was the task at the head
* of the ready-to-run list, then a context to the new
* ready to run task must be performed.
* task_state: Specifies which waiting task list should be
* hold the blocked task TCB.
*
****************************************************************************/
void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state);
/****************************************************************************
* Name: up_release_pending
*
* Description:
* When tasks become ready-to-run but cannot run because
* pre-emption is disabled, they are placed into a pending
* task list. This function releases and makes ready-to-run
* all of the tasks that have collected in the pending task
* list. This can cause a context switch if a new task is
* placed at the head of the ready to run list.
*
* This function is called only from the NuttX scheduling
* logic when pre-emptioni is re-enabled. Interrupts will
* always be disabled when this function is called.
*
****************************************************************************/
void up_release_pending(void);
/****************************************************************************
* Name: up_reprioritize_rtr
*
* Description:
* Called when the priority of a running or
* ready-to-run task changes and the reprioritization will
* cause a context switch. Two cases:
*
* 1) The priority of the currently running task drops and the next
* task in the ready to run list has priority.
* 2) An idle, ready to run task's priority has been raised above the
* the priority of the current, running task and it now has the
* priority.
*
* This function is called only from the NuttX scheduling
* logic. Interrupts will always be disabled when this
* function is called.
*
* Inputs:
* tcb: The TCB of the task that has been reprioritized
* priority: The new task priority
*
****************************************************************************/
void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority);
/****************************************************************************
* Name: _exit
*
* Description:
* This function causes the currently executing task to cease
* to exist. This is a special case of task_delete() where the task to
* be deleted is the currently executing task. It is more complex because
* a context switch must be perform to the next ready to run task.
*
* Unlike other UP APIs, this function may be called directly from user
* programs in various states. The implementation of this function should
* disable interrupts before performing scheduling operations.
*
****************************************************************************/
/* Prototype is in unistd.h */
/****************************************************************************
* Name: up_assert and up_assert_code
*
* Description:
* Assertions may be handled in an architecture-specific
* way.
*
****************************************************************************/
/* Prototype is in assert.h */
/****************************************************************************
* Name: up_schedule_sigaction
*
* Description:
* This function is called by the OS when one or more
* signal handling actions have been queued for execution.
* The architecture specific code must configure things so
* that the 'igdeliver' callback is executed on the thread
* specified by 'tcb' as soon as possible.
*
* This function may be called from interrupt handling logic.
*
* This operation should not cause the task to be unblocked
* nor should it cause any immediate execution of sigdeliver.
* Typically, a few cases need to be considered:
*
* (1) This function may be called from an interrupt handler
* During interrupt processing, all xcptcontext structures
* should be valid for all tasks. That structure should
* be modified to invoke sigdeliver() either on return
* from (this) interrupt or on some subsequent context
* switch to the recipient task.
* (2) If not in an interrupt handler and the tcb is NOT
* the currently executing task, then again just modify
* the saved xcptcontext structure for the recipient
* task so it will invoke sigdeliver when that task is
* later resumed.
* (3) If not in an interrupt handler and the tcb IS the
* currently executing task -- just call the signal
* handler now.
*
****************************************************************************/
#ifndef CONFIG_DISABLE_SIGNALS
void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver);
#endif
/****************************************************************************
* Name: up_allocate_heap
*
* Description:
* The heap may be statically allocated by defining CONFIG_HEAP_BASE and
* CONFIG_HEAP_SIZE. If these are not defined, then this function will be
* called to dynamically set aside the heap region.
*
****************************************************************************/
#ifndef CONFIG_HEAP_BASE
void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
#endif
/****************************************************************************
* Name: up_setpicbase, up_getpicbase
*
* Description:
* It NXFLAT external modules (or any other binary format that requires)
* PIC) are supported, then these macros must defined to (1) get or get
* the PIC base register value. These must be implemented with in-line
* assembly.
*
****************************************************************************/
#ifndef CONFIG_PIC
# define up_setpicbase(picbase)
# define up_getpicbase(ppicbase)
#endif
/****************************************************************************
* Address Environment Interfaces
*
* Low-level interfaces used in binfmt/ to instantiate tasks with address
* environments. These interfaces all operate on type task_addrenv_t which
* is an abstract representation of a task's address environment and must be
* defined in arch/arch.h if CONFIG_ADDRENV is defined.
*
* up_addrenv_create - Create an address environment
* up_addrenv_vaddr - Returns the virtual base address of the address
* environment
* up_addrenv_select - Instantiate an address environment
* up_addrenv_restore - Restore an address environment
* up_addrenv_destroy - Destroy an address environment.
* up_addrenv_assign - Assign an address environment to a TCB
*
* Higher-level interfaces used by the tasking logic. These interfaces are
* used by the functions in sched/ and all operate on the TCB which as been
* assigned an address environment by up_addrenv_assign().
*
* up_addrenv_share - Clone the address environment assigned to one TCB
* to another. This operation is done when a pthread
* is created that share's the same address
* environment.
* up_addrenv_release - Release the TCBs reference to an address
* environment when a task/thread exits.
*
****************************************************************************/
/****************************************************************************
* Name: up_addrenv_create
*
* Description:
* This function is called from the binary loader logic when a new
* task is created in order to instantiate an address environment for the
* task. up_addrenv_create is essentially the allocator of the physical
* memory for the new task.
*
* Input Parameters:
* envsize - The size (in bytes) of the address environment needed by the
* task.
* addrenv - The location to return the representation of the task address
* environment.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_ADDRENV
int up_addrenv_create(size_t envsize, FAR task_addrenv_t *addrenv);
#endif
/****************************************************************************
* Name: up_addrenv_vaddr
*
* Description:
* Return the virtual address associated with the newly create address
* environment. This function is used by the binary loaders in order
* get an address that can be used to initialize the new task.
*
* Input Parameters:
* addrenv - The representation of the task address environment previously
* returned by up_addrenv_create.
* vaddr - The location to return the virtual address.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_ADDRENV
int up_addrenv_vaddr(FAR task_addrenv_t addrenv, FAR void **vaddr);
#endif
/****************************************************************************
* Name: up_addrenv_select
*
* Description:
* After an address environment has been established for a task (via
* up_addrenv_create(). This function may be called to to instantiate
* that address environment in the virtual address space. this might be
* necessary, for example, to load the code for the task from a file or
* to access address environment private data.
*
* Input Parameters:
* addrenv - The representation of the task address environment previously
* returned by up_addrenv_create.
* oldenv
* The address environment that was in place before up_addrenv_select().
* This may be used with up_addrenv_restore() to restore the original
* address environment that was in place before up_addrenv_select() was
* called. Note that this may be a task agnostic, hardware
* representation that is different from task_addrenv_t.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_ADDRENV
int up_addrenv_select(task_addrenv_t addrenv, hw_addrenv_t *oldenv);
#endif
/****************************************************************************
* Name: up_addrenv_restore
*
* Description:
* After an address environment has been temporarilty instantiated by
* up_addrenv_select, this function may be called to to restore the
* original address environment.
*
* Input Parameters:
* oldenv - The hardware representation of the address environment
* previously returned by up_addrenv_select.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_ADDRENV
int up_addrenv_restore(hw_addrenv_t oldenv);
#endif
/****************************************************************************
* Name: up_addrenv_destroy
*
* Description:
* Called from the binary loader loader during error handling to destroy
* the address environment previously created by up_addrenv_create().
*
* Input Parameters:
* addrenv - The representation of the task address environment previously
* returned by up_addrenv_create.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_ADDRENV
int up_addrenv_destroy(task_addrenv_t addrenv);
#endif
/****************************************************************************
* Name: up_addrenv_assign
*
* Description:
* Assign an address environment to a TCB.
*
* Input Parameters:
* addrenv - The representation of the task address environment previously
* returned by up_addrenv_create.
* tcb - The TCB of the task to receive the address environment.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_ADDRENV
int up_addrenv_assign(task_addrenv_t addrenv, FAR struct tcb_s *tcb);
#endif
/****************************************************************************
* Name: up_addrenv_share
*
* Description:
* This function is called from the core scheduler logic when a thread
* is created that needs to share the address ennvironment of its parent
* task. In this case, the parent's address environment needs to be
* "cloned" for the child.
*
* Input Parameters:
* ptcb - The TCB of the parent task that has the address environment.
* ctcb - The TCB of the child thread needing the address environment.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_ADDRENV
int up_addrenv_share(FAR const struct tcb_s *ptcb, FAR struct tcb_s *ctcb);
#endif
/****************************************************************************
* Name: up_addrenv_release
*
* Description:
* This function is called when a task or thread exits in order to release
* its reference to an address environment. When there are no further
* references to an address environment, that address environment should
* be destroyed.
*
* Input Parameters:
* tcb - The TCB of the task or thread whose the address environment will
* be released.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifdef CONFIG_ADDRENV
int up_addrenv_release(FAR struct tcb_s *tcb);
#endif
/****************************************************************************
* Name: up_interrupt_context
*
* Description:
* Return true is we are currently executing in
* the interrupt handler context.
*
****************************************************************************/
bool up_interrupt_context(void);
/****************************************************************************
* Name: up_enable_irq
*
* Description:
* On many architectures, there are three levels of interrupt enabling: (1)
* at the global level, (2) at the level of the interrupt controller,
* and (3) at the device level. In order to receive interrupts, they
* must be enabled at all three levels.
*
* This function implements enabling of the device specified by 'irq'
* at the interrupt controller level if supported by the architecture
* (irqrestore() supports the global level, the device level is hardware
* specific).
*
* Since this API is not supported on all architectures, it should be
* avoided in common implementations where possible.
*
****************************************************************************/
#ifndef CONFIG_ARCH_NOINTC
void up_enable_irq(int irq);
#endif
/****************************************************************************
* Name: up_disable_irq
*
* Description:
* This function implements disabling of the device specified by 'irq'
* at the interrupt controller level if supported by the architecture
* (irqsave() supports the global level, the device level is hardware
* specific).
*
* Since this API is not supported on all architectures, it should be
* avoided in common implementations where possible.
*
****************************************************************************/
#ifndef CONFIG_ARCH_NOINTC
void up_disable_irq(int irq);
#endif
/****************************************************************************
* Name: up_prioritize_irq
*
* Description:
* Set the priority of an IRQ.
*
* Since this API is not supported on all architectures, it should be
* avoided in common implementations where possible.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQPRIO
int up_prioritize_irq(int irq, int priority);
#endif
/****************************************************************************
* Name: up_romgetc
*
* Description:
* In Harvard architectures, data accesses and instruction accesses occur
* on different busses, perhaps concurrently. All data accesses are
* performed on the data bus unless special machine instructions are
* used to read data from the instruction address space. Also, in the
* typical MCU, the available SRAM data memory is much smaller that the
* non-volatile FLASH instruction memory. So if the application requires
* many constant strings, the only practical solution may be to store
* those constant strings in FLASH memory where they can only be accessed
* using architecture-specific machine instructions.
*
* A similar case is where strings are retained in "external" memory such
* as EEPROM or serial FLASH. This case is similar only in that again
* special operations are required to obtain the string data; it cannot
* be accessed directly from a string pointer.
*
* If CONFIG_ARCH_ROMGETC is defined, then the architecture logic must
* export the function up_romgetc(). up_romgetc() will simply read one
* byte of data from the instruction space.
*
* If CONFIG_ARCH_ROMGETC, certain C stdio functions are effected: (1)
* All format strings in printf, fprintf, sprintf, etc. are assumed to
* lie in FLASH (string arguments for %s are still assumed to reside in
* SRAM). And (2), the string argument to puts and fputs is assumed to
* reside in FLASH. Clearly, these assumptions may have to modified for
* the particular needs of your environment. There is no "one-size-fits-all"
* solution for this problem.
*
****************************************************************************/
#ifdef CONFIG_ARCH_ROMGETC
char up_romgetc(FAR const char *ptr);
#else
# define up_romgetc(ptr) (*ptr)
#endif
/****************************************************************************
* Name: up_mdelay and up_udelay
*
* Description:
* Some device drivers may require that the plaform-specific logic
* provide these timing loops for short delays.
*
***************************************************************************/
void up_mdelay(unsigned int milliseconds);
void up_udelay(useconds_t microseconds);
/****************************************************************************
* Name: up_cxxinitialize
*
* Description:
* If C++ and C++ static constructors are supported, then this function
* must be provided by board-specific logic in order to perform
* initialization of the static C++ class instances.
*
* This function should then be called in the application-specific
* user_start logic in order to perform the C++ initialization. NOTE
* that no component of the core NuttX RTOS logic is involved; This
* function definition only provides the 'contract' between application
* specific C++ code and platform-specific toolchain support
*
***************************************************************************/
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
void up_cxxinitialize(void);
#endif
/****************************************************************************
* These are standard interfaces that are exported by the OS
* for use by the architecture specific logic
****************************************************************************/
/****************************************************************************
* Name: sched_process_timer
*
* Description:
* This function handles system timer events.
* The timer interrupt logic itself is implemented in the
* architecture specific code, but must call the following OS
* function periodically -- the calling interval must be
* MSEC_PER_TICK.
*
****************************************************************************/
void sched_process_timer(void);
/****************************************************************************
* Name: irq_dispatch
*
* Description:
* This function must be called from the achitecture-
* specific logic in order to dispatch an interrupt to
* the appropriate, registered handling logic.
*
***************************************************************************/
void irq_dispatch(int irq, FAR void *context);
/****************************************************************************
* Board-specific button interfaces exported by the board-specific logic
****************************************************************************/
/****************************************************************************
* Name: up_buttoninit
*
* Description:
* up_buttoninit() must be called to initialize button resources. After
* that, up_buttons() may be called to collect the current state of all
* buttons or up_irqbutton() may be called to register button interrupt
* handlers.
*
* NOTE: This interface may or may not be supported by board-specific
* logic. If the board supports button interfaces, then CONFIG_ARCH_BUTTONS
* will be defined.
*
****************************************************************************/
#ifdef CONFIG_ARCH_BUTTONS
void up_buttoninit(void);
#endif
/****************************************************************************
* Name: up_buttons
*
* Description:
* After up_buttoninit() has been called, up_buttons() may be called to
* collect the state of all buttons. up_buttons() returns an 8-bit bit set
* with each bit associated with a button. A bit set to "1" means that the
* button is depressed; a bit set to "0" means that the button is released.
* The correspondence of the each button bit and physical buttons is board-
* specific.
*
* NOTE: This interface may or may not be supported by board-specific
* logic. If the board supports button interfaces, then CONFIG_ARCH_BUTTONS
* will be defined
*
****************************************************************************/
#ifdef CONFIG_ARCH_BUTTONS
uint8_t up_buttons(void);
#endif
/****************************************************************************
* Name: up_irqbutton
*
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource.
* The previous interrupt handler address is returned (so that it may
* restored, if so desired).
*
* NOTE: This interface may or may not be supported by board-specific
* logic. If the board supports any button interfaces, then
* CONFIG_ARCH_BUTTONS will be defined; If the board supports interrupt
* buttons, then CONFIG_ARCH_IRQBUTTONS will also be defined.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
#endif
/************************************************************************************
* Relay control functions
*
* Description:
* Non-standard functions for relay control.
*
************************************************************************************/
#ifdef CONFIG_ARCH_RELAYS
void up_relaysinit(void);
void relays_setstat(int relays, bool stat);
bool relays_getstat(int relays);
void relays_setstats(uint32_t relays_stat);
uint32_t relays_getstats(void);
void relays_onoff(int relays, uint32_t mdelay);
void relays_onoffs(uint32_t relays_stat, uint32_t mdelay);
void relays_resetmode(int relays);
void relays_powermode(int relays);
void relays_resetmodes(uint32_t relays_stat);
void relays_powermodes(uint32_t relays_stat);
#endif
/****************************************************************************
* Debug interfaces exported by the architecture-specific logic
****************************************************************************/
/****************************************************************************
* Name: up_putc
*
* Description:
* Output one character on the console
*
****************************************************************************/
int up_putc(int ch);
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_ARCH_H */
|