spinnaker_tools  development
SpiNNaker API, sark, sc&mp, bmp firmware and build tools
sark.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
10 
11 /*
12  * Copyright (c) 2009 The University of Manchester
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License");
15  * you may not use this file except in compliance with the License.
16  * You may obtain a copy of the License at
17  *
18  * https://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS,
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  */
26 
27 #ifndef __SARK_H__
28 #define __SARK_H__
29 
30 #include <spinnaker.h>
31 #include <version.h>
32 
33 //------------------------------------------------------------------------------
34 
35 #define SARK_EVENT 1
36 
37 //------------------------------------------------------------------------------
38 
49 
50 #define SVC_STACK 384
51 #define IRQ_STACK 256
52 #define FIQ_STACK 256
53 
55 
56 // SARK configuration defaults - these can be modified at SARK
57 // start-up using "sark_config"
58 
59 #define NUM_SDP_MSGS 4
60 #define SARK_SLOT 15
61 #define INIT_EVENTS 16
62 
63 #define DEAD_WORD 0xdeaddead
64 
65 //------------------------------------------------------------------------------
66 
71 #ifdef DOXYGEN
73 typedef void (*int_handler) (void);
74 
75 #else
76 #ifdef __GNUC__
77 # define INT_HANDLER \
78  void __attribute__ ((interrupt ("IRQ")))
79 # define SARK_IS_A_MALLOC(size_arg) \
80  __attribute__ ((malloc, alloc_size(size_arg), assume_aligned(4)))
81 # define SARK_IS_A_CALLOC(size_arg1, size_arg2) \
82  __attribute__ ((malloc, alloc_size(size_arg1, size_arg2), assume_aligned(4)))
83 typedef void (*int_handler) (void);
84 
85 #else
86 # define INT_HANDLER \
87  __irq void
88 # define SARK_IS_A_MALLOC(size_arg) \
89  __attribute__ ((malloc))
90 # define SARK_IS_A_CALLOC(size_arg1, size_arg2) \
91  __attribute__ ((malloc))
92 typedef __irq void (*int_handler) (void);
93 #endif
94 
95 #endif
96 
97 // doxygen has overrides for all of these.
98 #ifndef NONNULL
99 #define NONNULL __attribute__((nonnull))
100 #define NONNULL2 __attribute__((nonnull(2)))
101 #define NORETURN __attribute__((noreturn))
102 #endif
103 
104 //------------------------------------------------------------------------------
105 
106 // Useful macros...
107 
108 #ifndef ntohs
109 
111 # define ntohs(t) ((((t) & 0x00ff) << 8) | (((t) >> 8) & 0x00ff))
112 
114 # define htons(t) ((((t) & 0x00ff) << 8) | (((t) >> 8) & 0x00ff))
115 
116 #endif
117 
119 # define CHIP_ID(x, y) (((x) << 8) + (y))
120 
122 # define CHIP_X(id) ((id) >> 8)
123 
125 # define CHIP_Y(id) ((id) & 255)
126 
127 
128 //------------------------------------------------------------------------------
129 
130 // APLX definitions
131 
136  APLX_FILL = 3,
137  APLX_EXEC = 4,
138 
139  APLX_END = 0xff
140 };
141 
142 #define APLX_ENTRY_SIZE 16
143 #define APLX_BUF_SIZE 64
144 
146 #define APLX_BUFFER (ITCM_TOP - APLX_BUF_SIZE)
147 
148 //------------------------------------------------------------------------------
149 
150 // IPTAG definitions
151 
152 #define TAG_NONE 255
153 #define TAG_HOST 0
154 
155 //------------------------------------------------------------------------------
156 
157 // Definition of range of router MC entries which may be allocated
158 
159 #define RTR_ALLOC_FIRST 1
160 #define RTR_ALLOC_LAST MC_TABLE_SIZE
161 
163 #define RTR_ALLOC_MAX (RTR_ALLOC_LAST - RTR_ALLOC_FIRST)
164 
165 // Flags to sark_xalloc() (etc)
166 
167 #define ALLOC_LOCK 1
168 #define ALLOC_ID 2
169 
177 #define ALLOC_TAG_RETRY 4
178 
179 //------------------------------------------------------------------------------
180 
193  LOCK_RTR
194 };
195 
196 typedef enum spin_lock_e spin_lock;
197 
199 
200 #define A_LOCK_SEMA 5
201 
202 //------------------------------------------------------------------------------
203 
207 };
208 
209 
210 //------------------------------------------------------------------------------
211 
223 
235  RTE_VER
236 };
237 
238 typedef enum rte_code_e rte_code;
239 
244  A_RTE_SVC = 3,
247  A_RTE_IRQ = 6,
248  A_RTE_FIQ = 7,
249  A_RTE_VIC = 8,
250 };
251 
252 //------------------------------------------------------------------------------
253 
254 // Various enumerated types, etc
255 
268 
273 
278 
283 };
284 
285 typedef enum cpu_state_e cpu_state;
286 
288 #define A_STATE_RTE 2
289 
299 };
300 
301 typedef enum event_type_e event_type;
302 
304 #define EVENT_COUNT 6
305 
307 enum event_state_e { // RUN must be first (0)
310  EVENT_STOP
311 };
312 
313 typedef enum event_state_e event_state;
314 
317  SLOT_0,
318  SLOT_1,
319  SLOT_2,
320  SLOT_3,
321  SLOT_4,
322  SLOT_5,
323  SLOT_6,
324  SLOT_7,
325  SLOT_8,
326  SLOT_9,
327  SLOT_10,
328  SLOT_11,
329  SLOT_12,
330  SLOT_13,
331  SLOT_14,
332  SLOT_15,
334  SLOT_MAX = SLOT_15
335 };
336 
337 typedef enum vic_slot_e vic_slot;
338 
341  PRIO_0,
342  PRIO_1,
343  PRIO_2,
344  PRIO_3,
345  PRIO_MAX = PRIO_3
346 };
347 
348 typedef enum event_priority_e event_priority;
349 
354  SW_RTE
355 };
356 
357 typedef enum sw_err_mode_e sw_err_mode;
358 
362  SYNC_WAIT
363 };
364 
365 typedef enum sync_bool_e sync_bool;
366 
367 //------------------------------------------------------------------------------
368 
369 // LED definitions - pass these to "sark_led_set"
370 
371 #define LED_ON(n) (3 << (2 * n))
372 #define LED_OFF(n) (2 << (2 * n))
373 #define LED_INV(n) (1 << (2 * n))
374 #define LED_FLIP(n) (1 << (2 * n))
375 
376 //------------------------------------------------------------------------------
377 
379 enum shm_cmd_e {
384  SHM_CMD
385 };
386 
387 typedef enum shm_cmd_e shm_cmd;
388 
389 //------------------------------------------------------------------------------
390 
392 enum signal_e {
397 
402 
407 
410 };
411 
412 typedef enum signal_e signal;
413 
414 //------------------------------------------------------------------------------
415 
419 
420 # define IO_STD ((char *) 0)
421 # define IO_DBG ((char *) 1)
422 # define IO_BUF ((char *) 2)
423 # define IO_NULL ((char *) 3)
424 
426 
427 //------------------------------------------------------------------------------
428 
431  CMD_VER = 0,
432  CMD_RUN = 1,
433  CMD_READ = 2,
434  CMD_WRITE = 3,
435  CMD_APLX = 4,
436  CMD_FILL = 5,
437 
438  // Following for monitors only
439  CMD_COUNT = 15,
440  CMD_REMAP = 16,
443  CMD_AR = 19,
444 
445  CMD_NNP = 20,
447  CMD_SIG = 22,
448  CMD_FFD = 23,
449 
450  CMD_AS = 24,
451  CMD_LED = 25,
452  CMD_IPTAG = 26,
453  CMD_SROM = 27,
454 
455  CMD_ALLOC = 28,
456  CMD_RTR = 29,
457  CMD_RSVD = 30,
458  CMD_INFO = 31,
459  CMD_SYNC = 32,
460 
461  // 48-63 reserved for BMP
462 
463  CMD_TUBE = 64
464 };
465 
468  RC_OK = 0x80,
469  RC_LEN = 0x81,
470  RC_SUM = 0x82,
471  RC_CMD = 0x83,
472  RC_ARG = 0x84,
473  RC_PORT = 0x85,
474  RC_TIMEOUT = 0x86,
475  RC_ROUTE = 0x87,
476  RC_CPU = 0x88,
477  RC_DEAD = 0x89,
478  RC_BUF = 0x8a,
479  RC_P2P_NOREPLY = 0x8b,
480  RC_P2P_REJECT = 0x8c,
481  RC_P2P_BUSY = 0x8d,
482  RC_P2P_TIMEOUT = 0x8e,
483  RC_PKT_TX = 0x8f,
484 };
485 
488  TYPE_BYTE = 0,
489  TYPE_HALF = 1,
490  TYPE_WORD = 2
491 };
492 
493 //------------------------------------------------------------------------------
494 
495 // Misc typedefs
496 
498 typedef struct divmod {
501 } divmod_t;
502 
504 typedef struct mem_link {
505  struct mem_link *next;
506 } mem_link_t;
507 
509 typedef struct mem_block {
513 } mem_block_t;
514 
515 
517 typedef struct srom_data {
519  uchar mac_addr[6];
520  uchar ip_addr[4];
521  uchar gw_addr[4];
522  uchar net_mask[4];
527 } srom_data_t;
528 
530 typedef struct rtr_entry {
536 } rtr_entry_t;
537 
541 typedef struct app_data {
547 } app_data_t;
548 
549 
550 //------------------------------------------------------------------------------
551 
552 // SDP messages
553 
554 #define NUM_SDP_PORTS 8
555 #define PORT_SHIFT 5
556 #define PORT_MASK 0xe0
557 #define CPU_MASK 0x1f
558 
559 #define PORT_ETH 255
560 
561 #define SDP_BUF_SIZE 256
562 
574 typedef struct sdp_msg { // SDP message - 292 bytes
575  struct sdp_msg *next;
578 
579  // sdp_hdr_t (mandatory)
580 
587 
588  // cmd_hdr_t (optional)
589 
595 
596  // user data (optional)
597 
599 
601 } sdp_msg_t;
602 
603 
604 // Legacy definitions...
605 
607 typedef struct sdp_hdr {
608  uchar flags;
609  uchar tag;
610  uchar dest_port;
611  uchar srce_port;
612  ushort dest_addr;
613  ushort srce_addr;
614 } sdp_hdr_t;
615 
617 typedef struct cmd_hdr {
618  ushort cmd_rc;
619  ushort flags;
620  uint arg1;
621  uint arg2;
622  uint arg3;
623 } cmd_hdr_t;
624 
625 //------------------------------------------------------------------------------
626 
627 // Heap data structures
628 
637 typedef struct block {
638  struct block *next;
639  struct block *free;
640 } block_t;
641 
652 typedef struct {
657  uchar buffer[];
658 } heap_t;
659 
660 
661 //------------------------------------------------------------------------------
662 
663 // Struct "sark_vec" containing ARM exception vectors, etc
664 
673 typedef struct event_vec {
677 } event_vec_t;
678 
686 typedef struct sark_vec {
695 
700 
704 
706 
709 
713  volatile uchar app_flags;
715 
717 } sark_vec_t;
718 
720 static sark_vec_t * const sark_vec = (sark_vec_t *) 0x20;
721 
722 //------------------------------------------------------------------------------
723 
730 typedef struct vcpu { // 128 bytes
731  uint r[8];
739  void *mbox_ap_msg;
740  void *mbox_mp_msg;
741  volatile uchar mbox_ap_cmd;
742  volatile uchar mbox_mp_cmd;
744  char *sw_file;
747  char app_name[16];
748  void *iobuf;
750  uint __PAD[4];
755 } vcpu_t;
756 
757 
758 // For "sark_alib.s" (maintain sync with vcpu_t)
759 
760 #define VCPU_SIZE 128
761 #define VCPU_RT_CODE 44
762 #define VCPU_CPU_STATE 46
763 #define VCPU_APP_ID 47
764 
765 //------------------------------------------------------------------------------
766 
767 // Events
768 
769 #define SARK_MSG_INT (INT0_INT)
770 #define SARK_SIG_INT (INT1_INT)
771 
773 typedef void (*event_proc) (uint, uint);
774 
788 typedef struct event { // 28 bytes
789  struct event *next;
790 
797 
802 } event_t;
803 
805 typedef struct proc_queue {
808 } proc_queue_t;
809 
811 typedef struct pkt {
815 } pkt_t;
816 
822 typedef struct event_data {
825 
829 
832 
833  volatile uchar state;
837 
841 
844 
847 
849 
852  volatile uchar pkt_count;
857 
862 
865 
867 
870  proc_queue_t proc_queue[PRIO_MAX + 1];
871 } event_data_t;
872 
873 //------------------------------------------------------------------------------
874 
876 typedef struct sark_data {
879 
880  uint random[2];
881 
885 
887 
889 
892 
896  void *sdram_buf;
898 } sark_data_t;
899 
900 //
901 
902 #define SARK_VIRT_CPU 0
903 #define SARK_RANDOM 8
904 #define SARK_CPU_CLK 48
905 
906 //------------------------------------------------------------------------------
907 
929 
930 #define SV_SSIZE 32
931 #define SV_USIZE 96
932 #define SV_ISIZE 128
933 #define SV_VSIZE 32
934 #define SV_RSIZE 64
935 #define SV_SIZE 0x1000
936 
937 #define SV_SROM (SYSRAM_TOP - SV_SSIZE)
938 #define SV_UBASE (SV_SROM - SV_USIZE)
939 #define SV_IBASE (SV_UBASE - SV_ISIZE)
940 #define SV_SV SV_IBASE
941 
942 #define SYS_BOOT 256
943 #define SYS_USER_TOP (SYSRAM_TOP - SV_SIZE)
944 #define SYS_USER_BASE (SYSRAM_BASE + SYS_BOOT)
945 
946 #define SV_VECTORS (SV_IBASE - SV_VSIZE)
947 #define SV_RANDOM (SV_VECTORS - SV_RSIZE)
948 
949 #define SV_VCPU SYS_USER_TOP
950 #define SV_SPARE (SV_VCPU + NUM_CPUS * VCPU_SIZE)
951 #define SPARE_SIZE (SV_RANDOM - SV_SPARE)
952 
953 #define SROM_FLAG_BASE (SV_SROM)
954 #define STATUS_MAP_BASE (SV_UBASE)
955 #define RST_BLOCK_BASE (SV_VECTORS)
956 
957 // Bits in srom_data->flags
958 
959 #define SRF_PRESENT 0x8000
960 #define SRF_HW_VER 0x00f0
961 #define SRF_PHY_INIT 0x0008
962 #define SRF_PHY_RST 0x0004
963 #define SRF_PHY_WAIT 0x0002
964 #define SRF_ETH 0x0001
965 #define SRF_NONE 0x0000
966 
973 typedef struct sv {
976 
980 
984 
989 
990  volatile uint64 clock_ms;
991  volatile ushort time_ms;
993 
994  volatile uint unix_time;
996 
999 
1004 
1008 
1012  // NOTE: This is a fixed point number!!!
1014 
1019 
1021 
1024 
1029 
1031 
1032  volatile uchar lock;
1036 
1038 
1043 
1044  uchar status_map[20];
1045  uchar p2v_map[20];
1047 
1051 
1056 
1066 
1067  uchar ip_addr[4];
1071 } sv_t;
1072 
1073 
1074 // Pointers to useful bits of system RAM
1075 
1080 static sv_t* const sv = (sv_t *) SV_SV;
1081 
1083 
1084 static vcpu_t* const sv_vcpu = (vcpu_t *) SV_VCPU;
1085 
1087 static uint* const sv_srom = (uint *) SV_SROM;
1089 static uint* const sv_random = (uint *) SV_RANDOM;
1091 static uint* const sv_vectors = (uint *) SV_VECTORS;
1092 
1094 static uint* const sv_board_info = (uint *) SV_SPARE;
1096 
1097 //------------------------------------------------------------------------------
1098 
1099 // Various bits of global data
1100 
1102 extern sark_data_t sark;
1103 
1105 extern event_data_t event;
1106 
1108 extern uint build_date;
1109 
1111 extern char build_name[];
1112 
1113 //------------------------------------------------------------------------------
1114 
1115 // Routines exported by SARK - sark_alib.s
1116 
1129 
1140 
1153 
1164 
1177 
1189 
1198 void cpu_int_restore (uint cpsr);
1199 
1209 
1219 
1230 void cpu_set_cpsr (uint cpsr);
1231 
1240 
1248 void cpu_set_cp15_cr(uint value);
1249 
1259 void cpu_wfi (void);
1260 
1269 NORETURN void
1271 
1280 NORETURN void
1282 
1295 NORETURN void
1296 rt_error(uint code, ...);
1297 
1310 NONNULL void
1311 sark_mem_cpy(void *dest, const void *src, uint n);
1312 
1323 NONNULL void
1324 sark_str_cpy(char *dest, const char *src);
1325 
1335 NONNULL uint
1336 sark_str_len (char *string);
1337 
1344 void sark_cpu_state (cpu_state state);
1345 
1355 NONNULL void sark_msg_cpy(sdp_msg_t *to, sdp_msg_t *from);
1356 
1372 NONNULL void
1373 sark_word_cpy(void *dest, const void *src, uint n);
1374 
1387 NONNULL void
1388 sark_word_set(void *dest, uint data, uint n);
1389 
1404 
1415 void sark_lock_free (uint cpsr, spin_lock lock);
1416 
1428 NONNULL uint sark_sema_raise(uchar *sema);
1429 
1442 NONNULL uint sark_sema_lower(uchar *sema);
1443 
1455 uint sark_app_raise(void);
1456 
1467 uint sark_app_lower(void);
1468 
1476 uint sark_app_sema (void);
1477 
1485 uint sark_app_cores (void);
1486 
1496 uint sark_app_lead (void);
1497 
1506 void sark_srand (uint seed);
1507 
1518 
1528 
1536 uint sark_count_bits(uint word);
1537 
1548 void sark_bx (uint addr);
1549 
1562 void sark_aplx (uint *table, uint app_id);
1563 
1579 uint *cpu_init_mode (uint *stack, uint mode, uint size);
1580 
1591 
1602 
1603 //------------------------------------------------------------------------------
1604 
1605 // Routines exported by SARK - sark_base.c
1606 
1615 uint sark_chip_id (void);
1616 
1625 uint sark_core_id(void);
1626 
1635 uint sark_app_id(void);
1636 
1645 static inline char *sark_app_name(void)
1646 {
1647  return build_name;
1648 }
1649 
1660 sdp_msg_t *sark_msg_get (void);
1661 
1669 void sark_msg_free (sdp_msg_t *msg);
1670 
1688 NONNULL uint
1689 sark_msg_send(sdp_msg_t *msg, uint timeout);
1690 
1700 void sark_delay_us (uint delay);
1701 
1717 void sw_error_fl (sw_err_mode mode, char *file, uint line);
1718 
1726 # define sw_error(mode) sw_error_fl (mode, __FILE__, __LINE__)
1727 
1746 uint sark_cmd_ver (sdp_msg_t *msg);
1747 
1768 
1790 
1805 
1822 void *sark_block_init(void *buf, uint size, uint count);
1823 
1833 void *sark_block_get (mem_block_t *root);
1834 
1844 void sark_block_free(mem_block_t *root, void *blk);
1845 
1857 sdp_msg_t *sark_shmsg_get(void);
1858 
1870 NONNULL void
1872 
1879 void sark_call_cpp_constructors(void);
1880 
1881 
1882 //------------------------------------------------------------------------------
1883 
1884 // Routines exported by SARK - sark_io.c
1885 
1914 NONNULL2 void
1915 io_printf(char *stream, char *format, ...);
1916 
1932 void io_put_char(char *stream, uint c);
1933 
1939 void sark_io_buf_reset (void);
1940 
1941 //------------------------------------------------------------------------------
1942 
1943 // Routines exported by SARK - sark_alloc.c
1944 
1958 #ifndef DOXYGEN
1959 SARK_IS_A_CALLOC(1, 2)
1960 #endif
1961 void *
1962 sark_alloc(uint count, uint size);
1963 
1971 NONNULL void
1972 sark_free(void *ptr);
1973 
2004 SARK_IS_A_MALLOC(2) void *
2005 sark_xalloc(heap_t *heap, uint size, uint tag, uint flag);
2006 
2021 NONNULL2 void
2022 sark_xfree(heap_t *heap, void *ptr, uint flag);
2023 
2037 uint sark_xfree_id(heap_t *heap, uint app_id, uint flag);
2038 
2051 uint sark_heap_max(heap_t *heap, uint flag);
2052 
2065 heap_t *sark_heap_init(uint *base, uint *top);
2066 
2074 uint rtr_alloc(uint size);
2075 
2090 uint rtr_alloc_id(uint size, uint app_id);
2091 
2100 void rtr_free(uint entry, uint clear);
2101 
2114 uint rtr_free_id(uint app_id, uint clear);
2115 
2123 uint rtr_alloc_max(void);
2124 
2134 void *sark_tag_ptr(uint tag, uint app_id);
2135 
2136 //------------------------------------------------------------------------------
2137 
2138 // Routines exported by SARK - sark_hw.c
2139 
2148 void sark_vic_init (void);
2149 
2162 NONNULL void
2163 sark_vic_set(vic_slot slot, uint interrupt, uint enable, int_handler handler);
2164 
2172 void sark_led_init (void);
2173 
2190 void sark_led_set (uint leds);
2191 
2207 uint rtr_mc_clear (uint start, uint count);
2208 
2223 void rtr_mc_init (uint start);
2224 
2243 NONNULL uint
2244 rtr_mc_load(rtr_entry_t *e, uint count, uint offset, uint app_id);
2245 
2263 uint rtr_mc_set (uint entry, uint key, uint mask, uint route);
2264 
2278 NONNULL uint rtr_mc_get(uint entry, rtr_entry_t *r);
2279 
2290 void rtr_fr_set (uint route);
2291 
2299 uint rtr_fr_get(void);
2300 
2307 void rtr_p2p_init (void);
2308 
2322 void rtr_p2p_set(uint entry, uint value);
2323 
2331 uint rtr_p2p_get(uint entry);
2332 
2344 NONNULL void
2345 rtr_diag_init(const uint *table);
2346 
2361 void rtr_init (uint monitor);
2362 
2374 uint v2p_mask (uint virt_mask);
2375 
2385 uint pl340_init (uint mem_clk);
2386 
2387 //------------------------------------------------------------------------------
2388 
2389 // Routines exported by SARK - sark_event.c
2390 
2401 uint event_alloc (uint events);
2402 
2411 NONNULL
2412 void event_free(event_t *e);
2413 
2426 NONNULL event_t *
2427 event_new(event_proc proc, uint arg1, uint arg2);
2428 
2441 void event_config(event_t* event, event_proc proc, uint arg1, uint arg2);
2442 
2457 uint pkt_tx_k (uint key);
2458 //
2473 uint pkt_tx_kd (uint key, uint data);
2474 
2488 uint pkt_tx_kc (uint key, uint ctrl);
2489 
2505 uint pkt_tx_kdc (uint key, uint data, uint ctrl);
2506 
2525 uint event_start (uint period, uint events, sync_bool wait);
2526 
2538 void event_pause (uint pause);
2539 
2552 void event_stop (uint rc);
2553 
2563 void event_wait (void);
2564 
2578 NONNULL uint
2579 event_queue(event_t *e, event_priority priority);
2580 
2597 NONNULL uint
2598 event_queue_proc(event_proc proc, uint arg1, uint arg2, event_priority priority);
2599 
2612 void event_run(uint restart);
2613 
2630 NONNULL void
2632 
2648 NONNULL void
2650  event_priority priority);
2651 
2662 NONNULL void
2664 
2679 void event_enable (event_type event_num, uint enable);
2680 
2690 void event_register_timer (vic_slot slot);
2691 
2708 void event_register_pkt(uint queue_size, vic_slot slot);
2709 
2721 uint event_user (uint arg1, uint arg2);
2722 
2723 //------------------------------------------------------------------------------
2724 
2725 // Routines exported by SARK - sark_timer.c
2726 
2742 NONNULL void
2743 timer_schedule(event_t *e, uint time);
2744 
2758 NONNULL uint
2759 timer_schedule_proc(event_proc proc, uint arg1, uint arg2, uint time);
2760 
2779 NONNULL void timer_cancel(event_t *e, uint ID);
2780 
2790 void timer_cancel_init(void);
2791 
2792 
2793 //------------------------------------------------------------------------------
2794 
2795 #endif
#define SDP_BUF_SIZE
SDP data buffer capacity.
Definition: sark.h:561
uint * cpu_init_mode(uint *stack, uint mode, uint size)
Sets up stack for a given CPU mode.
uint event_user(uint arg1, uint arg2)
Used to trigger a user event if one has been registered.
Definition: sark_event.c:69
uint sark_cmd_read(sdp_msg_t *msg)
SCP handler for the Read command which reads memory and returns the data read to the host.
Definition: sark_base.c:590
int_handler undef_vec
0x24 Undefined instruction vector
Definition: sark.h:688
void event_free(event_t *e)
Free a previously allocated event.
Definition: sark_event.c:387
void * sark_block_init(void *buf, uint size, uint count)
Initialise a memory buffer into a linked list of "count" blocks of "size" bytes.
Definition: sark_base.c:252
ushort __PAD
0x5e Pad
Definition: sark.h:714
void event_stop(uint rc)
Used to stop event processing.
Definition: sark_event.c:313
ushort free
Index of next free block (or app_id)
Definition: sark.h:532
uint cpu_int_enable(void)
Enable the FIQ and IRQ interrupts in the core by clearing the appropriate bits in the CPSR.
uint event_alloc(uint events)
Create additional free events by calling sark_alloc().
Definition: sark_event.c:548
uchar last_biff_id
66 Last ID used in BIFF
Definition: sark.h:1034
#define SV_VCPU
e5007000
Definition: sark.h:949
void cpu_sleep(void)
Puts the core into sleep mode until an interrupt occurs at which point the interrupt will be serviced...
uchar num_buf
41 Number of SHM buffers
Definition: sark.h:1016
uint cpu_irq_enable(void)
Enable the IRQ interrupt in the core by clearing the appropriate bit in the CPSR.
event_proc pause_proc
Called on pause.
Definition: sark.h:845
ushort fiq_stack
0x44 FIQ stack size (words)
Definition: sark.h:698
uint pkt_tx_kc(uint key, uint ctrl)
Transmit a packet which contains key and control byte (cb) fields.
Definition: sark_pkt.c:152
enum event_type_e event_type
typedef for enum event_type_e
Definition: sark.h:301
vcpu_t * vcpu_base
cc Start of VCPU blocks
Definition: sark.h:1055
uint rc
Failure codes.
Definition: sark.h:831
void sark_lock_free(uint cpsr, spin_lock lock)
Free a previously acquired hardware lock.
uint sark_cmd_ver(sdp_msg_t *msg)
SCP handler for the Version command.
Definition: sark_base.c:577
heap_t * sys_heap
d0 System heap in SDRAM
Definition: sark.h:1057
rtr_entry_t * rtr_copy
d4 Copy of router MC tables
Definition: sark.h:1058
ushort sw_count
58 - SW error count (saturating)
Definition: sark.h:743
uint chksum_64(uint a, uint b)
uint cpu_int_disable(void)
Disable the FIQ and IRQ interrupts in the core by setting the appropriate bits in the CPSR.
void(* event_proc)(uint, uint)
Generic (void) function taking two "uint" args.
Definition: sark.h:773
void rtr_mc_init(uint start)
Initialises the router's multicast (MC) tables and sets up the data structures for allocating router ...
Definition: sark_hw.c:272
ushort seq
Sequence number.
Definition: sark.h:591
void sark_delay_us(uint delay)
Perform a busy-wait for the given number of microseconds.
uint iobuf_size
50 Size of IO buffers (bytes)
Definition: sark.h:1025
uchar soft_wdog
43 Soft watchdog control
Definition: sark.h:1018
event_priority_e
Event queue priorities.
Definition: sark.h:340
uchar dest_port
Destination port/CPU.
Definition: sark.h:583
static sark_vec_t *const sark_vec
A pointer to sark_vec at 0x20.
Definition: sark.h:720
sdp_msg_t * sark_shmsg_get(void)
Get a free SDP message from the shared SysRAM pool.
Definition: sark_base.c:356
uint free_bytes
Number of free bytes left.
Definition: sark.h:656
void sark_srand(uint seed)
Seed the random number generator with the supplied value.
ushort cmd_rc
Command/Return Code.
Definition: sark.h:590
uint ctrl
TCR in 23:16, flags in 1:0.
Definition: sark.h:812
int_handler pabt_vec
0x2c Prefetch abort vector
Definition: sark.h:690
event_t * proc_tail
and tail of that list
Definition: sark.h:807
uint arg2
Arg 2.
Definition: sark.h:593
uint sark_cmd_write(sdp_msg_t *msg)
SCP handler for the Write command which writes memory with data supplied by the host.
Definition: sark_base.c:630
enum spin_lock_e spin_lock
Typedef for enum spin_lock_e.
Definition: sark.h:196
void * sark_tag_ptr(uint tag, uint app_id)
Get a pointer to a tagged allocation.
Definition: sark_alloc.c:499
ushort max
Maximum blocks used.
Definition: sark.h:512
uint * cpu_get_sp(void)
Returns the current value of the core's stack pointer.
uint sync_alignment
44 delay for sync0/1 alignment (us)
Definition: sark.h:1020
uint div
Dividend.
Definition: sark.h:499
uchar cores
Number of cores using this ID.
Definition: sark.h:542
void event_register_timer(vic_slot slot)
Register the use of the second timer on the core so that it can be used to provide delayed events via...
Definition: sark_timer.c:38
void io_printf(char *stream, char *format,...)
A simple "printf" routine.
Definition: sark_io.c:483
#define EVENT_COUNT
For "sark_alib.s" (maintain sync with enum event_type_e)
Definition: sark.h:304
void rtr_init(uint monitor)
Performs a full initialisation of the router.
Definition: sark_hw.c:502
uchar netinit_phase
2d Phase of boot process
Definition: sark.h:1006
volatile uint64 clock_ms
10 Milliseconds since boot
Definition: sark.h:990
uint sysbuf_size
58 Size of system buffers (words)
Definition: sark.h:1027
void sark_call_cpp_constructors(void)
Calls the constructors for any C++ objects created at global scope.
Definition: sark_base.c:397
uint sark_count_bits(uint word)
Count the number of bits set in a word.
Definition: sark_base.c:106
uint v2p_mask(uint virt_mask)
Given a bit mask of virtual core IDs, returns a mask of the corresponding physical core IDs.
Definition: sark_hw.c:74
void event_config(event_t *event, event_proc proc, uint arg1, uint arg2)
Configure a (reusable) event that has already been allocated.
Definition: sark_event.c:583
sw_err_mode_e
Mode for sw_error() calls to decide if rt_error() is to be called.
Definition: sark.h:351
@ SW_NEVER
Never call rt_error.
Definition: sark.h:353
@ SW_OPT
Optional, controlled by sark.sw_rte.
Definition: sark.h:352
@ SW_RTE
Always call rt_error.
Definition: sark.h:354
void * iobuf
88 - IO buffer in SDRAM (or 0)
Definition: sark.h:748
uint rtr_alloc_id(uint size, uint app_id)
Allocate a block of entries in the router multicast table (and associate the supplied app_id with thi...
Definition: sark_alloc.c:327
uint cpu_get_cpsr(void)
Returns the current value of the core's CPSR.
signal_e
Signals passed to applications.
Definition: sark.h:392
@ SIG_CONT
Continue application.
Definition: sark.h:401
@ SIG_SYNC1
Synchronisation barrier 1.
Definition: sark.h:399
@ SIG_PAUSE
Pause application.
Definition: sark.h:400
@ SIG_USR2
Send user signal 2.
Definition: sark.h:408
@ SIG_SYNC0
Synchronisation barrier 0.
Definition: sark.h:398
@ SIG_USR0
Send user signal 0.
Definition: sark.h:405
@ SIG_PWRDN
Powerdown cores.
Definition: sark.h:394
@ SIG_STOP
Stop application and clean up.
Definition: sark.h:395
@ SIG_USR3
Send user signal 3.
Definition: sark.h:409
@ SIG_USR1
Send user signal 1.
Definition: sark.h:406
@ SIG_START
Start application if waiting.
Definition: sark.h:396
@ SIG_INIT
Initialise cores.
Definition: sark.h:393
@ SIG_EXIT
Terminate application.
Definition: sark.h:403
@ SIG_TIMER
Trigger timer for application.
Definition: sark.h:404
enum sw_err_mode_e sw_err_mode
Typedef for enum sw_err_mode_e.
Definition: sark.h:357
volatile uint unix_time
1c Seconds since 1970
Definition: sark.h:994
uchar hw_ver
0a Hardware version
Definition: sark.h:982
struct block * free
Chains free blocks together (in address order)
Definition: sark.h:639
void * sark_alloc(uint count, uint size)
Allocate a block of memory of count × size bytes from the DTCM heap. Returns either a pointer to the ...
Definition: sark_alloc.c:137
uint data
Data (payload) field.
Definition: sark.h:813
enum sync_bool_e sync_bool
Typedef for enum sync_bool_e.
Definition: sark.h:365
void * mbox_mp_msg
52 - mbox msg AP->MP
Definition: sark.h:740
uint exit_rc
Return value from "event_start".
Definition: sark.h:848
void sark_bx(uint addr)
Performs an ARM BX instruction to the address in addr.
uchar srce_port
Source port/CPU.
Definition: sark.h:584
uint sark_sema_lower(uchar *sema)
Lower (decrement) an 8-bit semaphore variable which is accessed via a pointer.
volatile uchar app_flags
0x5d App flags
Definition: sark.h:713
uchar __PAD2
(Spare)
Definition: sark.h:853
cpu_state_e
Runtime state of a core (limited to 16)
Definition: sark.h:263
@ CPU_STATE_12
Spare.
Definition: sark.h:279
@ CPU_STATE_WDOG
Watchdog expired.
Definition: sark.h:267
@ CPU_STATE_IDLE
Idle (SARK stub)
Definition: sark.h:282
@ CPU_STATE_14
Spare.
Definition: sark.h:281
@ CPU_STATE_13
Spare.
Definition: sark.h:280
@ CPU_STATE_RUN
Running (API/Event)
Definition: sark.h:272
@ CPU_STATE_SYNC1
Waiting for sync 1.
Definition: sark.h:275
@ CPU_STATE_DEAD
Dead core.
Definition: sark.h:264
@ CPU_STATE_SYNC0
Waiting for sync 0.
Definition: sark.h:274
@ CPU_STATE_INIT
Initialising (transient)
Definition: sark.h:269
@ CPU_STATE_SARK
Entered c_main.
Definition: sark.h:271
@ CPU_STATE_PWRDN
Powered down.
Definition: sark.h:265
@ CPU_STATE_WAIT
Ready to execute.
Definition: sark.h:270
@ CPU_STATE_PAUSE
Paused in application.
Definition: sark.h:276
@ CPU_STATE_EXIT
Exited application.
Definition: sark.h:277
@ CPU_STATE_RTE
Died with Run Time Error.
Definition: sark.h:266
uint mask
Mask of cores using this ID.
Definition: sark.h:546
uchar clk_div
0e Clock divisors for system & router bus
Definition: sark.h:987
ushort irq_stack
0x42 IRQ stack size (words)
Definition: sark.h:697
uint * sdram_sys
c8 System SDRAM
Definition: sark.h:1054
block_t * last
Last block (zero size, never used for storage)
Definition: sark.h:655
uint rtr_mc_load(rtr_entry_t *e, uint count, uint offset, uint app_id)
Load router MC table from a table in memory.
Definition: sark_hw.c:303
uint arg2
Second arg to proc.
Definition: sark.h:793
rte_code_e
Run time error codes, passed as first arg to rt_error()
Definition: sark.h:213
@ RTE_PKT
Pkt startup failure.
Definition: sark.h:232
@ RTE_TIMER
Timer startup failure.
Definition: sark.h:233
@ RTE_RESET
1 Branch through zero
Definition: sark.h:215
@ RTE_ABORT
Generic user abort.
Definition: sark.h:224
@ RTE_ENABLE
Bad event enable.
Definition: sark.h:230
@ RTE_SVC
3 Undefined SVC or no handler
Definition: sark.h:217
@ RTE_SWERR
Fatal SW error.
Definition: sark.h:228
@ RTE_PABT
4 Prefetch abort
Definition: sark.h:218
@ RTE_DIV0
Divide by zero.
Definition: sark.h:226
@ RTE_IOBUF
Failed to allocate IO buffer.
Definition: sark.h:229
@ RTE_VIC
8 Unconfigured VIC vector
Definition: sark.h:222
@ RTE_NULL
Generic null pointer error.
Definition: sark.h:231
@ RTE_IRQ
6 Unhandled IRQ
Definition: sark.h:220
@ RTE_UNDEF
2 Undefined instruction
Definition: sark.h:216
@ RTE_EVENT
Event startup failure.
Definition: sark.h:227
@ RTE_MALLOC
"malloc" failure
Definition: sark.h:225
@ RTE_VER
SW version conflict.
Definition: sark.h:235
@ RTE_API
API startup failure.
Definition: sark.h:234
@ RTE_NONE
0 No error
Definition: sark.h:214
@ RTE_FIQ
7 Unhandled FIQ
Definition: sark.h:221
@ RTE_DABT
5 Data abort
Definition: sark.h:219
uint sark_rand(void)
Return the next 32-bit pseudo-random number in the sequence.
void sark_block_free(mem_block_t *root, void *blk)
Generic call to free a buffer into a pool whose "root" is supplied.
Definition: sark_base.c:338
heap_t * heap
18 Heap in DTCM
Definition: sark.h:884
uchar app_id
47 - Application ID
Definition: sark.h:738
void sark_free(void *ptr)
Frees a block of memory which was previously allocated by sark_alloc() (i.e., from the DTCM heap).
Definition: sark_alloc.c:215
uchar id_rsvd
number of reserved IDs
Definition: sark.h:834
void event_register_pkt(uint queue_size, vic_slot slot)
Register the use of "pkt" routines.
Definition: sark_pkt.c:34
uchar p2p_up
06 Non-zero if P2P networking active
Definition: sark.h:978
#define SV_SPARE
e5007900
Definition: sark.h:950
void rtr_p2p_set(uint entry, uint value)
Sets a P2P table entry.
Definition: sark_hw.c:417
ushort flags
16 bit flags
Definition: sark.h:518
uchar sw_rte
32 Set to 1 for SW error calls rt_error
Definition: sark.h:894
uint user1
116 - User word 1
Definition: sark.h:752
ushort checksum
checksum (if used)
Definition: sark.h:577
int_handler old_vector
Old FIQ vector.
Definition: sark.h:864
ushort next
Index of next block.
Definition: sark.h:531
uchar user
Non-zero if user event pending.
Definition: sark.h:836
uchar root_chip
40 Set if we are the root chip
Definition: sark.h:1015
uchar lead
Lead core number.
Definition: sark.h:545
void timer_schedule(event_t *e, uint time)
Schedule an event to occur at some time in the future.
Definition: sark_timer.c:62
void cpu_int_restore(uint cpsr)
Restore the CPSR to the state provided in the argument.
pkt_t * pkt_queue
Pointer to packet queue.
Definition: sark.h:856
uint old_select
Keeps old state of vic_select.
Definition: sark.h:860
void timer_cancel_init(void)
Initialise a statically allocated event to be used in place of an event that is cancelled at the head...
Definition: sark_timer.c:231
heap_t * sysram_heap
48 Heap in SysRAM
Definition: sark.h:1022
block_t ** alloc_tag
dc Start of alloc_tag table
Definition: sark.h:1060
void rtr_diag_init(const uint *table)
Initialises the 16 diagnostic registers in the router using the supplied table (which should have 16 ...
Definition: sark_hw.c:488
static char * sark_app_name(void)
Returns a pointer to the name of the application running on this core.
Definition: sark.h:1645
uchar tag
IP tag.
Definition: sark.h:582
uchar led_period
2b LED flash period (* 10 ms)
Definition: sark.h:1003
uint sark_msg_send(sdp_msg_t *msg, uint timeout)
Send an SDP message.
Definition: sark_base.c:531
void cpu_shutdown(void)
Puts the core into sleep mode and disable all interrupts in the VIC.
#define SV_RANDOM
e5007ea0
Definition: sark.h:947
uint ticks
Timer tick counter.
Definition: sark.h:838
uint build_date
Date of build.
void * mbox_ap_msg
48 - mbox msg MP->AP
Definition: sark.h:739
volatile uchar mbox_ap_cmd
56 - mbox command MP->AP
Definition: sark.h:741
uint mem_ptr
60 Memory pointer for NNBC memory setter
Definition: sark.h:1030
uint sark_xfree_id(heap_t *heap, uint app_id, uint flag)
Free all allocated blocks in the specified heap which are tagged with the given "app_id".
Definition: sark_alloc.c:227
ushort mem_clk
26 SDRAM clock in MHz
Definition: sark.h:998
divmod_t sark_div10(uint n)
Divide the argument by 10 and return dividend and modulus in a struct of type divmod_t which has fiel...
sdp_msg_t * msg
Passes msg from SARK to app.
Definition: sark.h:842
uint signal
Passes signal from SARK to app.
Definition: sark.h:843
uchar __PAD1
(spare - included for correct size)
Definition: sark.h:799
enum event_priority_e event_priority
Typedef for enum event_priority_e.
Definition: sark.h:348
uint sark_core_id(void)
Returns the virtual core number of this core.
Definition: sark_base.c:89
uint pkt_tx_k(uint key)
Transmit a packet which contains only a key.
Definition: sark_pkt.c:123
void event_register_int(event_proc proc, event_type event, vic_slot slot)
Register an event_proc to be called when a particular event occurs and associate that with an IRQ or ...
Definition: sark_event.c:88
uint mask
Mask word.
Definition: sark.h:535
uint sark_app_id(void)
Returns the ID of the application running on this core.
Definition: sark_base.c:96
uint pl340_init(uint mem_clk)
Initialises the PL340 memory controller.
Definition: sark_hw.c:205
uint * sdram_bufs
54 SDRAM buffers
Definition: sark.h:1026
uint pkt_tx_kd(uint key, uint data)
Transmit a packet which contains key and data fields.
Definition: sark_pkt.c:93
void rtr_free(uint entry, uint clear)
Free a block of MC table entries which starts with the supplied entry. The relevant router registers ...
Definition: sark_alloc.c:385
spin_lock_e
Definition: sark.h:185
@ LOCK_RTR
Router.
Definition: sark.h:193
@ LOCK_SEMA
Sema access.
Definition: sark.h:191
@ LOCK_API_ROOT
Spin1 API.
Definition: sark.h:190
@ LOCK_MSG
Msg buffers in SysRAM.
Definition: sark.h:186
@ LOCK_HEAP
Heap in System / SDRAM.
Definition: sark.h:192
@ LOCK_MBOX
Mailbox flag variable.
Definition: sark.h:187
@ LOCK_GPIO
GPIO port (unused...)
Definition: sark.h:189
@ LOCK_ETHER
Ethernet Tx (unused...)
Definition: sark.h:188
enum rte_code_e rte_code
Typedef for enum rte_code_e.
Definition: sark.h:238
sark_scp_return_codes
SCP return codes.
Definition: sark.h:467
@ RC_P2P_NOREPLY
No reply to open.
Definition: sark.h:479
@ RC_CMD
Bad/invalid command.
Definition: sark.h:471
@ RC_TIMEOUT
Timeout.
Definition: sark.h:474
@ RC_ARG
Invalid arguments.
Definition: sark.h:472
@ RC_ROUTE
No P2P route.
Definition: sark.h:475
@ RC_DEAD
SHM dest dead.
Definition: sark.h:477
@ RC_SUM
Bad checksum.
Definition: sark.h:470
@ RC_BUF
No free SHM buffers.
Definition: sark.h:478
@ RC_PKT_TX
Pkt Tx failed.
Definition: sark.h:483
@ RC_P2P_TIMEOUT
Dest died?
Definition: sark.h:482
@ RC_CPU
Bad CPU number.
Definition: sark.h:476
@ RC_OK
Command completed OK.
Definition: sark.h:468
@ RC_P2P_BUSY
Dest busy.
Definition: sark.h:481
@ RC_P2P_REJECT
Open rejected.
Definition: sark.h:480
@ RC_PORT
Bad port number.
Definition: sark.h:473
@ RC_LEN
Bad packet length.
Definition: sark.h:469
uint event_queue(event_t *e, event_priority priority)
Places an event on an event queue for execution at a later time.
Definition: sark_event.c:351
sark_scp_memory_size_types
Memory size types.
Definition: sark.h:487
@ TYPE_BYTE
Specifies byte access.
Definition: sark.h:488
@ TYPE_HALF
Specifies short (16-bit) access.
Definition: sark.h:489
@ TYPE_WORD
Specifies word (32-bit) access.
Definition: sark.h:490
uchar __PAD2
(spare - included for correct size)
Definition: sark.h:800
enum vic_slot_e vic_slot
Typedef for enum vic_slot_e.
Definition: sark.h:337
uchar link_en
65 Bit map of enabled links
Definition: sark.h:1033
uint route
Route word.
Definition: sark.h:533
void event_pause(uint pause)
Used to stop (pause) event processing or resume it again.
Definition: sark_event.c:297
enum event_state_e event_state
typedef for enum event_state_e
Definition: sark.h:313
uint utmp0
70 Four temps...
Definition: sark.h:1039
vic_slot_e
Slots in the VIC interrupt controller.
Definition: sark.h:316
@ SLOT_FIQ
Special slot for FIQ.
Definition: sark.h:333
@ SLOT_MAX
Index of largest ordinary slot.
Definition: sark.h:334
uint msg_sent
2c Numbers of msgs sent
Definition: sark.h:891
uint sw_ver
fc Software version number
Definition: sark.h:1070
event_t * timer_queue
List of active timer events.
Definition: sark.h:824
char build_name[]
Name of build.
void sark_shmsg_free(sdp_msg_t *msg)
Return a shared memory SDP message to the shared SysRAM pool.
Definition: sark_base.c:380
uchar clean
Set if this ID has been cleaned.
Definition: sark.h:543
void event_register_pause(event_proc proc, uint arg2)
Register an event_proc to be called when event processing is paused.
Definition: sark_event.c:184
void event_run(uint restart)
Run the event queue until it is empty.
Definition: sark_event.c:421
void sark_mem_cpy(void *dest, const void *src, uint n)
Copy n bytes of memory from src to dest.
enum cpu_state_e cpu_state
Typedef for enum cpu_state_e.
Definition: sark.h:285
ushort udp_port
UDP port for SDP messages.
Definition: sark.h:523
uint user0
112 - User word 0
Definition: sark.h:751
uchar forward
28 NNBC forward parameter
Definition: sark.h:1000
uint * board_info
f8 Pointer to board_info area !!
Definition: sark.h:1069
uint lr
40 - lr
Definition: sark.h:734
void * sdram_buf
34 Pointer to SDRAM buffer
Definition: sark.h:896
uchar bt_flags
67 Board Test flags
Definition: sark.h:1035
uchar __PAD1
33
Definition: sark.h:895
ushort p2p_root
2e The P2P address from which the system was booted
Definition: sark.h:1007
ushort __PAD1
Spare...
Definition: sark.h:524
sark_aplx_command
Commands used in the APLX loader.
Definition: sark.h:133
@ APLX_RCOPY
Relative copy.
Definition: sark.h:135
@ APLX_END
End marker (rarely used)
Definition: sark.h:139
@ APLX_ACOPY
Absolute copy.
Definition: sark.h:134
@ APLX_FILL
Fill memory.
Definition: sark.h:136
@ APLX_EXEC
Execute.
Definition: sark.h:137
app_data_t * app_data
e4 Array of app_id structs
Definition: sark.h:1063
ushort rtr_free
e0 Start of free router entry list
Definition: sark.h:1061
ushort p2p_active
e2 Count of active P2P addresses
Definition: sark.h:1062
void rtr_fr_set(uint route)
Sets the fixed-route register in the router.
Definition: sark_hw.c:383
void sark_led_init(void)
Initialises the hardware (GPIO port) which drives the LEDs attached to the SpiNNaker chip.
Definition: sark_hw.c:130
int_handler fiq_vector
New FIQ vector (or 0)
Definition: sark.h:863
uint utmp1
74
Definition: sark.h:1040
void sark_led_set(uint leds)
Controls one or more of the LEDs attached to the SpiNNaker chip.
Definition: sark_hw.c:146
static sv_t *const sv
Definition: sark.h:1080
void rtr_p2p_init(void)
Initialise the router point-to-point (P2P) table.
Definition: sark_hw.c:407
uint cpu_get_cp15_cr(void)
Returns the current value of the core's CP15 Control register.
volatile ushort time_ms
18 Milliseconds in second (0..999)
Definition: sark.h:991
uchar pkt_insert
Insert point for packet queue.
Definition: sark.h:850
uint * stack_top
0x50 Points to top of stacks
Definition: sark.h:703
uint boot_sig
5c Boot signature word
Definition: sark.h:1028
ushort eth_addr
08 P2P address of nearest Ethernet node
Definition: sark.h:981
uchar boot_delay
42 Delay between boot NN pkts (us)
Definition: sark.h:1017
int_handler aplx_proc
0x34 Pointer to "proc_aplx"
Definition: sark.h:692
ushort cpu_clk
30 CPU clock speed (MHz)
Definition: sark.h:893
uint ID
Unique ID for active event (0 if inactive)
Definition: sark.h:796
uint sark_app_cores(void)
Used to get the number of cores on this chip which are running the current application.
Definition: sark_base.c:164
ushort count
Count of blocks in use.
Definition: sark.h:511
uint cpu_fiq_disable(void)
Disable the FIQ interrupt in the core by setting the appropriate bit in the CPSR.
uint rtr_free_id(uint app_id, uint clear)
Free all allocated blocks in the router which are tagged with the given "app_id".
Definition: sark_alloc.c:442
ushort pkt_size
Size of packet queue (<= 256)
Definition: sark.h:854
uint pause_arg2
Arg2 to pause_proc (arg1 is pause)
Definition: sark.h:846
uint sark_lock_get(spin_lock lock)
Acquires one of the 32 built-in hardware locks provided by the chip.
static uint *const sv_srom
SROM.
Definition: sark.h:1087
sync_bool_e
Startup synchronisation bool.
Definition: sark.h:360
@ SYNC_WAIT
Wait for synchronisation.
Definition: sark.h:362
@ SYNC_NOWAIT
Don't wait.
Definition: sark.h:361
uint vic_select
Builds VIC IRQ/FIQ select word.
Definition: sark.h:858
uint rtr_mc_set(uint entry, uint key, uint mask, uint route)
Sets a given entry in the router MC table.
Definition: sark_hw.c:332
uint * heap_base
0x4c Points to base of heap
Definition: sark.h:702
uint user2
120 - User word 2
Definition: sark.h:753
mem_link_t * free
Pointer to first free block.
Definition: sark.h:510
void cpu_set_cpsr(uint cpsr)
Set the core's CPSR to the supplied value.
ushort stack_size
0x46 Total stack size (bytes)
Definition: sark.h:699
static uint *const sv_board_info
Board information.
Definition: sark.h:1094
uchar tp_scale
0f Scale for router phase timer
Definition: sark.h:988
sark_data_t sark
Main SARK variables.
Definition: sark_base.c:54
uchar rom_cpus
bd SC&MP ROM good cores
Definition: sark.h:1049
void sark_msg_free(sdp_msg_t *msg)
Return an SDP message buffer which was acquired by sark_msg_get() to the free buffer pool.
Definition: sark_base.c:295
uint psr
32 - cpsr
Definition: sark.h:732
void sark_cpu_state(cpu_state state)
Sets the CPU state field in the VCPU block for this core.
Definition: sark_base.c:133
uint id
Holds unique ID for active events.
Definition: sark.h:828
void * sark_xalloc(heap_t *heap, uint size, uint tag, uint flag)
Allocate a memory block from the specified heap.
Definition: sark_alloc.c:48
uint arg1
First arg to proc.
Definition: sark.h:792
void event_wait(void)
Wait for a signal from the monitor processor (i.e., host) before proceeding. Can be used to implement...
Definition: sark_event.c:194
uint fr_copy
f4 (Virtual) copy of router FR reg
Definition: sark.h:1068
void sark_vic_set(vic_slot slot, uint interrupt, uint enable, int_handler handler)
Initialises one of the VIC slots to set up an interrupt handler.
Definition: sark_hw.c:54
uint sark_heap_max(heap_t *heap, uint flag)
Search the supplied heap and return the size of the largest free block (in bytes).
Definition: sark_alloc.c:253
enum signal_e signal
Typedef for enum signal_e.
Definition: sark.h:412
uint utmp2
78
Definition: sark.h:1041
struct mem_link * next
Pointer to next free block.
Definition: sark.h:505
uint pkt_count
38 Count of thrown packets
Definition: sark.h:897
uint key
Key (non-payload!) field.
Definition: sark.h:814
void * sark_block_get(mem_block_t *root)
Generic call to get a buffer from a pool whose "root" is supplied.
Definition: sark_base.c:315
uchar phys_cpu
45 - Physical CPU
Definition: sark.h:736
uint sp
36 - sp
Definition: sark.h:733
void sark_word_cpy(void *dest, const void *src, uint n)
A fast copy for memory buffers.
uint * heap_base
14 Bottom of heap area
Definition: sark.h:883
void cpu_wfi(void)
Puts the core into sleep mode until an interrupt occurs at which point the function will return.
uchar num_events
0x5a Number of initial events
Definition: sark.h:710
#define SV_VECTORS
e5007ee0
Definition: sark.h:946
uint event_queue_proc(event_proc proc, uint arg1, uint arg2, event_priority priority)
Creates a new event and places it on an event queue for execution at a later time.
Definition: sark_event.c:366
uint vic_enable
Builds VIC interrupt enable word.
Definition: sark.h:859
uint tp_timer
20 Router time phase timer
Definition: sark.h:995
heap_t * sdram_heap
4c Heap in SDRAM
Definition: sark.h:1023
vcpu_t * vcpu
1c Pointer to VCPU block
Definition: sark.h:886
struct block * next
Chains all blocks together (in address order)
Definition: sark.h:638
uint sark_chip_id(void)
Returns the ID of this chip as a 16-bit number.
Definition: sark_base.c:82
ushort length
length
Definition: sark.h:576
uchar p2p_sql
0d P2P sequence length (**)
Definition: sark.h:986
int_handler reset_vec
0x20 Reset vector
Definition: sark.h:687
int_handler irq_vec
0x38 IRQ vector
Definition: sark.h:693
int_handler svc_vec
0x28 SVC vector
Definition: sark.h:689
uint arg1
Arg 1.
Definition: sark.h:592
uint * stack_base
10 Bottom of stack area (& heap limit)
Definition: sark.h:882
uchar slot
VIC slot.
Definition: sark.h:675
uint pkt_tx_kdc(uint key, uint data, uint ctrl)
Transmit a packet which contains key, data and control byte (cb) fields.
Definition: sark_pkt.c:63
uint * code_top
0x48 Points to top of code
Definition: sark.h:701
uint utmp3
7c
Definition: sark.h:1042
void sw_error_fl(sw_err_mode mode, char *file, uint line)
Generates a software error, logging the filename and line number at which the error occurs.
Definition: sark_base.c:184
uchar retry
29 NNBC retry parameter
Definition: sark.h:1001
ushort p2p_dims
02 P2P dimensions
Definition: sark.h:975
uint timer_schedule_proc(event_proc proc, uint arg1, uint arg2, uint time)
Allocates an event, initialises it with the supplied parameters and schedules it to occur at some tim...
Definition: sark_timer.c:142
uchar priority
Priority for queued events.
Definition: sark.h:676
void timer_cancel(event_t *e, uint ID)
Cancel a timer event that was previously scheduled.
Definition: sark_timer.c:167
uint sw_ver
92 - SW version
Definition: sark.h:749
uchar p2pb_repeats
0c Number of times to send out P2PB packets
Definition: sark.h:985
uint old_enable
Keeps old state of vic_enable.
Definition: sark.h:861
uint failed
Counts failures of event_new.
Definition: sark.h:830
uint led0
30 LED definition words (for up
Definition: sark.h:1009
int clock_drift
38 drift of clock from boot chip clock in ticks / us
Definition: sark.h:1011
ushort dbg_addr
04 P2P address for debug messages
Definition: sark.h:977
uint cpu_irq_disable(void)
Disable the IRQ interrupt in the core by setting the appropriate bit in the CPSR.
uchar pkt_remove
Remove point for packet queue.
Definition: sark.h:851
uint random
3c Random number seed
Definition: sark.h:1013
enum shm_cmd_e shm_cmd
Typedef for enum shm_cmd_e.
Definition: sark.h:387
sdp_msg_t * sark_msg_get(void)
Get an SDP message buffer from the pool maintained by SARK.
Definition: sark_base.c:270
shm_cmd_e
Mailbox commands passed to APs.
Definition: sark.h:379
@ SHM_SIGNAL
Signal application.
Definition: sark.h:383
@ SHM_IDLE
Idle state of mailbox.
Definition: sark.h:380
@ SHM_MSG
Passing SDP message.
Definition: sark.h:381
@ SHM_NOP
Does nothing...
Definition: sark.h:382
@ SHM_CMD
Command to MP.
Definition: sark.h:384
ushort pkt_max
Max occupancy of packet queue.
Definition: sark.h:855
heap_t * sark_heap_init(uint *base, uint *top)
Initialise an area of memory as a heap.
Definition: sark_alloc.c:290
uint __PAD1
Private padding.
Definition: sark.h:600
uint rtr_fr_get(void)
Gets the fixed-route register from the router and masks off the top 8 bits.
Definition: sark_hw.c:399
mem_block_t msg_root
20 Control block for SDP messages
Definition: sark.h:888
event_type_e
Types of event.
Definition: sark.h:291
@ EVENT_SIG
Signal from hosts.
Definition: sark.h:296
@ EVENT_DMA
DMA complete.
Definition: sark.h:297
@ EVENT_TIMER
Timer elapsed.
Definition: sark.h:292
@ EVENT_USER
User triggered event.
Definition: sark.h:295
@ EVENT_SDP
SDP packet received.
Definition: sark.h:294
@ EVENT_RXPKT
MC packet received.
Definition: sark.h:293
@ EVENT_MAX
Maximum event number.
Definition: sark.h:298
ushort board_addr
be Position of chip on PCB
Definition: sark.h:1050
sark_alib_rte_codes
For "sark_alib.s" (maintain sync with enum rte_code_e)
Definition: sark.h:241
@ A_RTE_RESET
Branch through zero.
Definition: sark.h:242
@ A_RTE_FIQ
Unhandled FIQ.
Definition: sark.h:248
@ A_RTE_DABT
Data abort.
Definition: sark.h:246
@ A_RTE_IRQ
Unhandled IRQ.
Definition: sark.h:247
@ A_RTE_VIC
Unconfigured VIC vector.
Definition: sark.h:249
@ A_RTE_SVC
Undefined SVC or no handler.
Definition: sark.h:244
@ A_RTE_PABT
Prefetch abort.
Definition: sark.h:245
@ A_RTE_UNDEF
Undefined instruction.
Definition: sark.h:243
ushort max
Maximum number ever used.
Definition: sark.h:827
uint rtr_alloc(uint size)
Allocate a block of entries in the router multicast table (and associate the caller's app_id with thi...
Definition: sark_alloc.c:373
void event_register_queue(event_proc proc, event_type event, vic_slot slot, event_priority priority)
Register an event_proc to be placed on an event queue when a particular event occurs and associate th...
Definition: sark_event.c:130
void rt_error(uint code,...)
Called to signal a fatal error.
uint sw_line
64 - SW source line (could be short?)
Definition: sark.h:745
uint arg2
Arg2 for user event.
Definition: sark.h:840
uchar peek_time
2a Timeout for link read/write (us)
Definition: sark.h:1002
static vcpu_t *const sv_vcpu
"sv_vcpu" points to base of array of "vcpu_t"
Definition: sark.h:1084
uint __PAD3
Spare...
Definition: sark.h:526
uchar last_id
07 Last ID used in NNBC
Definition: sark.h:979
ushort ltpc_period
1a Local Time Phase Control message interval (*10 ms)
Definition: sark.h:992
mem_block_t shm_root
68 Control block for SHM bufs
Definition: sark.h:1037
event_t * event_new(event_proc proc, uint arg1, uint arg2)
Allocate a new event from the free queue and intialise "proc", "arg1" and "arg2" fields.
Definition: sark_event.c:504
void sark_msg_cpy(sdp_msg_t *to, sdp_msg_t *from)
Copies an SDP message from one buffer to another.
event_proc proc
Proc to be called or NULL.
Definition: sark.h:791
uchar __PAD3
(spare - included for correct size)
Definition: sark.h:801
uchar app_id
0x5c App ID
Definition: sark.h:712
uchar num_cpus
bc Number of good cores
Definition: sark.h:1048
volatile uchar lock
64 Lock variable
Definition: sark.h:1032
static uint *const sv_vectors
VECTORS.
Definition: sark.h:1091
uint key
Key word.
Definition: sark.h:534
event_t * free
List of free events.
Definition: sark.h:823
static uint *const sv_random
RANDOM.
Definition: sark.h:1089
uchar sema
Semaphore.
Definition: sark.h:544
uint arg1
Arg1 for user event.
Definition: sark.h:839
event_state_e
State of event execution.
Definition: sark.h:307
@ EVENT_PAUSE
Paused.
Definition: sark.h:309
@ EVENT_RUN
Running.
Definition: sark.h:308
@ EVENT_STOP
Stopped.
Definition: sark.h:310
volatile uchar mbox_mp_cmd
57 - mbox command AP->MP
Definition: sark.h:742
ushort dest_addr
Destination address.
Definition: sark.h:585
uint rtr_mc_get(uint entry, rtr_entry_t *r)
Gets a given entry in the router MC table.
Definition: sark_hw.c:366
uint sark_app_lower(void)
Lowers a semaphore associated with the AppID running on this core.
Definition: sark_base.c:149
ushort srce_addr
Source address.
Definition: sark.h:586
uchar api
0x5b API active
Definition: sark.h:711
ushort p2p_addr
00 P2P address of this chip
Definition: sark.h:974
void sark_str_cpy(char *dest, const char *src)
Copies a NULL terminated string from src to dest.
uchar flags
Flag byte.
Definition: sark.h:581
uchar reuse
do not free event after queue processing
Definition: sark.h:798
#define SV_SROM
e5007fe0
Definition: sark.h:937
uint cpu_fiq_enable(void)
Enable the FIQ interrupt in the core by clearing the appropriate bit in the CPSR.
volatile uchar pkt_count
Count of items in packet queue.
Definition: sark.h:852
uint mod
Modulus.
Definition: sark.h:500
uchar cpu_state
46 - CPU state
Definition: sark.h:737
uint phys_cpu
04 Physical CPU number
Definition: sark.h:878
ushort cpu_clk
24 CPU clock in MHz
Definition: sark.h:997
uint sark_app_raise(void)
Raise a semaphore associated with the AppID running on this core.
Definition: sark_base.c:141
ushort svc_stack
0x40 SVC stack size (words)
Definition: sark.h:696
uchar netinit_bc_wait
2c Minimum time after last BC during netinit (*10 ms)
Definition: sark.h:1005
uint virt_cpu
00 Virtual CPU number
Definition: sark.h:877
struct sdp_msg * next
Next in free list.
Definition: sark.h:575
app_flags_e
Flags in app_flags field.
Definition: sark.h:205
@ APP_FLAG_WAIT
Wait for start signal.
Definition: sark.h:206
uint * sdram_base
c0 Base of user SDRAM
Definition: sark.h:1052
volatile uchar state
Stop/pauses event loop.
Definition: sark.h:833
void(* int_handler)(void)
The basic type of an interrupt handler. Takes no arguments. Returns nothing.
Definition: sark.h:73
sark_scp_command_codes
SCP command codes.
Definition: sark.h:430
@ CMD_SIG
Send signal to apps.
Definition: sark.h:447
@ CMD_REMAP
Remap application core.
Definition: sark.h:440
@ CMD_APP_COPY_RUN
Copy app from adjacent chip and reset.
Definition: sark.h:446
@ CMD_SROM
Read/write/erase serial ROM.
Definition: sark.h:453
@ CMD_COUNT
Count state of application processors.
Definition: sark.h:439
@ CMD_APLX
Run via APLX (Deprecated)
Definition: sark.h:435
@ CMD_LED
Control LEDs.
Definition: sark.h:451
@ CMD_READ
Read memory.
Definition: sark.h:433
@ CMD_RUN
Run at PC (Deprecated)
Definition: sark.h:432
@ CMD_VER
Return version/core info.
Definition: sark.h:431
@ CMD_WRITE
Write memory.
Definition: sark.h:434
@ CMD_INFO
Get chip/core info.
Definition: sark.h:458
@ CMD_NNP
Send broadcast NN packet.
Definition: sark.h:445
@ CMD_RSVD
Reserved (used elsewhere in software)
Definition: sark.h:457
@ CMD_ALLOC
Memory allocation.
Definition: sark.h:455
@ CMD_AS
Application core APLX start.
Definition: sark.h:450
@ CMD_FILL
Fill memory.
Definition: sark.h:436
@ CMD_AR
Application core reset.
Definition: sark.h:443
@ CMD_LINK_READ
Read neighbour memory.
Definition: sark.h:441
@ CMD_FFD
Send flood-fill data.
Definition: sark.h:448
@ CMD_SYNC
Control sending of synchronization msgs.
Definition: sark.h:459
@ CMD_RTR
Router control.
Definition: sark.h:456
@ CMD_IPTAG
Configure IPTags.
Definition: sark.h:452
@ CMD_LINK_WRITE
Write neighbour memory.
Definition: sark.h:442
@ CMD_TUBE
Tube output.
Definition: sark.h:463
uint sark_sema_raise(uchar *sema)
Raise (increment) an 8-bit semaphore variable which is accessed via a pointer.
uint time
Definition: sark.h:794
event_t * proc_head
List of queued "proc" events.
Definition: sark.h:806
uint arg3
Arg 3.
Definition: sark.h:594
uchar sark_slot
0x59 VIC slot for MP->AP interrupt
Definition: sark.h:708
uint stack_fill
0x54 Stack fill word
Definition: sark.h:705
uchar rt_code
44 - RT error code
Definition: sark.h:735
uint * hop_table
d8 P2P hop table
Definition: sark.h:1059
uchar num_msgs
0x58 Number of SDP msgs buffers
Definition: sark.h:707
void io_put_char(char *stream, uint c)
Routine to put a character to an output stream.
Definition: sark_io.c:152
void sark_xfree(heap_t *heap, void *ptr, uint flag)
Free a memory block in the specified heap.
Definition: sark_alloc.c:149
uint rtr_p2p_get(uint entry)
Gets a P2P table entry.
Definition: sark_hw.c:437
uint __PAD2
Spare...
Definition: sark.h:525
uint chksum_32(uint a)
Compute 4-bit ones-complement checksum of a 32-bit quantity.
#define SV_SV
e5007f00
Definition: sark.h:940
uint sark_app_sema(void)
Used to get the value of the semaphore associated with the AppID running on this core.
Definition: sark_base.c:157
event_data_t event
SARK event variables.
Definition: sark_event.c:63
void sark_word_set(void *dest, uint data, uint n)
A fast memory setter for a block of memory.
int_handler fiq_vec
0x3c FIQ vector
Definition: sark.h:694
void cpu_set_cp15_cr(uint value)
Set the core's CP15 Control Register to the supplied value.
void sark_vic_init(void)
Performs a full software initialisation of the VIC.
Definition: sark_hw.c:38
uint led1
34 to 15 LEDs)
Definition: sark.h:1010
char * sw_file
60 - SW source file name
Definition: sark.h:744
uint sark_str_len(char *string)
Counts the number of characters in a zero terminated string.
Definition: sark_base.c:120
uint user3
124 - User word 3
Definition: sark.h:754
uint time
68 - Time of loading
Definition: sark.h:746
uchar wait
Wait state.
Definition: sark.h:835
block_t * free
Root of free block chain.
Definition: sark.h:653
uint mbox_flags
ec AP->MP communication flags
Definition: sark.h:1065
block_t * first
First block.
Definition: sark.h:654
ushort count
Number of events currently in use.
Definition: sark.h:826
struct event * next
Next in Q or NULL.
Definition: sark.h:789
uint sark_cmd_fill(sdp_msg_t *msg)
SCP handler for the Fill command which fills memory with a data word.
Definition: sark_base.c:670
uint * sysram_base
c4 Base of user SysRAM
Definition: sark.h:1053
uchar eth_up
0b Non-zero if Ethernet active
Definition: sark.h:983
ushort proc
Handler address (squeezed into 16 bits!)
Definition: sark.h:674
uint rtr_alloc_max(void)
Return the size of the largest free block in the router multicast table (or zero if table is full).
Definition: sark_alloc.c:468
int_handler dabt_vec
0x30 Data abort vector
Definition: sark.h:691
uint event_start(uint period, uint events, sync_bool wait)
Start event processing.
Definition: sark_event.c:219
uint rtr_mc_clear(uint start, uint count)
Initialises a set of the router's multicast (MC) table registers so that routing is disabled.
Definition: sark_hw.c:255
void event_enable(event_type event_num, uint enable)
Enable or disable an event.
Definition: sark_event.c:156
uint msg_rcvd
28 Numbers of msgs received
Definition: sark.h:890
void sark_io_buf_reset(void)
Routine to reset the IOBUF for the core.
Definition: sark_io.c:110
sdp_msg_t * shm_buf
e8 SHM buffers
Definition: sark.h:1064
void sark_aplx(uint *table, uint app_id)
Used to unpack an APLX table whose address is provided.
uint sark_app_lead(void)
Returns the core ID of the lowest numbered core on this chip which is running the current application...
Definition: sark_base.c:171
Stores info relating to AppIDs.
Definition: sark.h:541
Heap data block.
Definition: sark.h:637
Command header: legacy.
Definition: sark.h:617
Returned (div, mod) from divmod()
Definition: sark.h:498
Struct holding data for "sark_event" and "sark_timer".
Definition: sark.h:822
Event structure used by "event_xxx" and "timer_xxx" routines.
Definition: sark.h:788
An event_vec fits into 32 bits and contains a handler address in 16 bits and a priority and slot numb...
Definition: sark.h:673
Heap root structure.
Definition: sark.h:652
Used in the block memory allocator (8 bytes)
Definition: sark.h:509
Struct holding a packet.
Definition: sark.h:811
Struct holding head and tail of a list of "event_t".
Definition: sark.h:805
Copy of router entry (16 bytes)
Definition: sark.h:530
A struct holding all of the variables maintained by SARK.
Definition: sark.h:876
A struct of type sark_vec_t lives at address 0x20, that is, it is built into the code section.
Definition: sark.h:686
SDP header: legacy.
Definition: sark.h:607
SDP message definition.
Definition: sark.h:574
Contents of SV SROM area (32 bytes)
Definition: sark.h:517
Struct holding the System Variables.
Definition: sark.h:973
Struct containing information about each virtual processor.
Definition: sark.h:730
uchar v2p_map[MAX_CPUS]
Virtual-core-ID to physical-core-ID map.
Definition: scamp-3.c:100
static uint start(sync_bool sync, uint start_paused)
Begins a simulation by enabling the timer (if called for) and beginning the dispatcher loop....
Definition: spin1_api.c:837
Header file describing SpiNNaker hardware.
unsigned long long uint64
Unsigned integer - 64 bits.
Definition: spinnaker.h:40
unsigned char uchar
Unsigned integer - 8 bits.
Definition: spinnaker.h:37
unsigned int uint
Unsigned integer - 32 bits.
Definition: spinnaker.h:39
unsigned short ushort
Unsigned integer - 16 bits.
Definition: spinnaker.h:38
Header file describing SpiNNaker low-level tool version.