19#ifndef __SPIN1_API_H__
20#define __SPIN1_API_H__
30#define SPINN_SYSRAM_BASE SYSRAM_BASE
32#define SPINN_SYSRAM_SIZE SYSRAM_SIZE
35#define SPINN_SDRAM_BASE SDRAM_BASE
37#define SPINN_SDRAM_SIZE SDRAM_SIZE
49#define SUCCESS (uint) 1
51#define FAILURE (uint) 0
341static inline NONNULL
uint
355#define SPIN1_INLINE static __inline __attribute__((always_inline))
357#define SPIN1_INLINE static __forceinline
361SPIN1_INLINE
void spin1_store_barrier(
void)
365 asm volatile(
"" : : :
"cc",
"memory");
371SPIN1_INLINE
void spin1_memory_barrier(
void)
375 asm volatile(
"" : : :
"cc",
"memory");
395 uint old_val, new_val;
399 "mrs %[old_val], cpsr \n\
400 orr %[new_val], %[old_val], #0x80 \n\
401 msr cpsr_c, %[new_val] \n"
402 : [old_val]
"=r" (old_val), [new_val]
"=r" (new_val)
406 __asm { mrs old_val, cpsr }
407 __asm { orr new_val, old_val, 0x80 }
408 __asm { msr cpsr_c, new_val }
411 spin1_memory_barrier();
430 uint old_val, new_val;
434 "mrs %[old_val], cpsr \n\
435 orr %[new_val], %[old_val], #0x40 \n\
436 msr cpsr_c, %[new_val] \n"
437 : [old_val]
"=r" (old_val), [new_val]
"=r" (new_val)
441 __asm { mrs old_val, cpsr }
442 __asm { orr new_val, old_val, 0x40 }
443 __asm { msr cpsr_c, new_val }
446 spin1_memory_barrier();
465 uint old_val, new_val;
469 "mrs %[old_val], cpsr \n\
470 orr %[new_val], %[old_val], #0xc0 \n\
471 msr cpsr_c, %[new_val] \n"
472 : [old_val]
"=r" (old_val), [new_val]
"=r" (new_val)
476 __asm { mrs old_val, cpsr }
477 __asm { orr new_val, old_val, 0xc0 }
478 __asm { msr cpsr_c, new_val }
481 spin1_memory_barrier();
499 spin1_store_barrier();
503 "msr cpsr_c, %[value]"
505 : [value]
"r" (value)
508 __asm { msr cpsr_c, value }
545static inline SARK_IS_A_MALLOC(1) void*
Spinnaker Application Runtime Kernel API.
void sark_delay_us(uint delay)
Perform a busy-wait for the given number of microseconds.
void sark_srand(uint seed)
Seed the random number generator with the supplied value.
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
enum sync_bool_e sync_bool
Typedef for enum sync_bool_e.
Definition sark.h:365
uint sark_rand(void)
Return the next 32-bit pseudo-random number in the sequence.
uint sark_msg_send(sdp_msg_t *msg, uint timeout)
Send an SDP message.
Definition sark_base.c:531
enum rte_code_e rte_code
Typedef for enum rte_code_e.
Definition sark.h:238
void sark_led_set(uint leds)
Controls one or more of the LEDs attached to the SpiNNaker chip.
Definition sark_hw.c:146
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
sdp_msg_t * sark_msg_get(void)
Get an SDP message buffer from the pool maintained by SARK.
Definition sark_base.c:270
SDP message definition.
Definition sark.h:574
volatile uchar load
The current system load.
Definition scamp-3.c:184
uint dumped_mc_packets
total dumped MC packets by the router
Definition spin1_api.h:609
@ FRPL_PACKET_RECEIVED
Fixed route packet with payload received.
Definition spin1_api.h:71
@ MCPL_PACKET_RECEIVED
Multicast packet with payload received.
Definition spin1_api.h:69
@ NUM_EVENTS
Count of possible events.
Definition spin1_api.h:63
@ MC_PACKET_RECEIVED
Multicast packet received.
Definition spin1_api.h:64
@ SDP_PACKET_RX
SDP message received.
Definition spin1_api.h:67
@ DMA_TRANSFER_DONE
DMA transfer complete.
Definition spin1_api.h:65
@ USER_EVENT
User-triggered interrupt.
Definition spin1_api.h:68
@ TIMER_TICK
Regular timer tick.
Definition spin1_api.h:66
@ FR_PACKET_RECEIVED
Fixed route packet received.
Definition spin1_api.h:70
uint spin1_send_packet(uint key, uint data, uint TCR)
Send a packet. Do not normally call directly; use spin1_send_mc_packet() and spin1_send_fr_packet() i...
Definition spin1_api.c:1158
void spin1_pause(void)
Pause the simulation on this core. Waits for spin1_resume().
Definition spin1_api.c:382
uint user_event_queue_full
user event queue full count
Definition spin1_api.h:616
void spin1_set_timer_tick_and_phase(uint time, uint phase)
Set the timer tick rate and phase offset.
Definition spin1_api.c:708
uint spin1_trigger_user_event(uint arg0, uint arg1)
This function triggers a USER EVENT, i.e., a software interrupt.
Definition spin1_api.c:1485
volatile uint discarded_mc_packets
total discarded MC packets by API
Definition spin1_api.h:610
uint spin1_dma_transfer(uint tag, void *system_address, void *tcm_address, uint direction, uint length)
Initiates a DMA transfer.
Definition spin1_api.c:962
static void spin1_msg_free(sdp_msg_t *msg)
Frees a received SDP message.
Definition spin1_api.h:326
static uint spin1_rand(void)
This function generates a pseudo-random 32-bit integer.
Definition spin1_api.h:597
uint spin1_get_id(void)
Returns a global (machine-wide) ID for the processor.
Definition spin1_api.c:1252
static void * spin1_malloc(uint bytes)
Returns a pointer to a newly-allocated block of memory of size "bytes" in DTCM.
Definition spin1_api.h:546
uint total_times_tick_tic_callback_overran
the total number of times the timer tic callback overran
Definition spin1_api.h:625
void spin1_flush_rx_packet_queue(void)
Discards all received packets which are yet to be processed.
Definition spin1_api.c:1122
diagnostics_t diagnostics
Miscellaneous diagnostic information, available to the application.
Definition spin1_api.c:133
uint warnings
warnings type bit map
Definition spin1_api.h:607
uint total_mc_packets
total routed MC packets during simulation
Definition spin1_api.h:608
uint dma_bursts
total DMA bursts completed
Definition spin1_api.h:612
void spin1_dma_flush(void)
Flushes any current transfers in the DMA controller.
Definition spin1_api.c:1018
uint dma_transfers
total DMA transfers requested
Definition spin1_api.h:611
void spin1_rte(rte_code code)
Soft-RTEs the core.
Definition spin1_api.c:820
uint spin1_fiq_disable(void)
Sets the F bit in the CPSR in order to disable FIQ interrupts in the processor.
uint tx_packet_queue_full
transmitter packet queue full count
Definition spin1_api.h:615
uint spin1_schedule_callback(callback_t cback, uint arg0, uint arg1, uint priority)
This function places a cback into the scheduling queue corresponding to its priority.
Definition spin1_api.c:1417
uint writeBack_errors
write-back buffer error count
Definition spin1_api.h:617
uint spin1_irq_disable(void)
Sets the I bit in the CPSR in order to disable IRQ interrupts to the processor.
uint number_timer_tic_in_queue
the number of timer tic callbacks in the queue
Definition spin1_api.h:622
void spin1_flush_tx_packet_queue(void)
Flushes the outbound packet queue.
Definition spin1_api.c:1147
void spin1_resume(sync_bool sync)
Resume the simulation on this core that was paused with spin1_pause().
Definition spin1_api.c:406
uint spin1_get_simulation_time(void)
Returns the number of timer periods which have elapsed since the beginning of the simulation.
Definition spin1_api.c:658
uint in_timer_callback
bool which states if currently in timer callback
Definition spin1_api.h:621
uchar leadAp
lead appl. core has special functions
Definition spin1_api.c:32
void spin1_memcpy(void *dst, void const *src, uint len)
Directly copies data from src to dst.
Definition spin1_api.c:1093
uint dumped_fr_packets
total dumped FR packets by the router
Definition spin1_api.h:619
uint spin1_int_disable(void)
Sets the F and I bits in the CPSR in order to disable FIQ and IRQ interrupts in the processor.
static sdp_msg_t * spin1_msg_get(void)
Gets an SDP message that has been sent to this core.
Definition spin1_api.h:332
uint total_fr_packets
total routed FR packets during simulation
Definition spin1_api.h:618
static uint spin1_send_fr_packet(uint key, uint data, uint load)
This function enqueues a request to send a fixed-route packet.
Definition spin1_api.h:311
static void spin1_delay_us(uint n)
This function implements a delay measured in microseconds.
Definition spin1_api.h:168
@ NO_PAYLOAD
No payload word present.
Definition spin1_api.h:100
@ WITH_PAYLOAD
Payload word present.
Definition spin1_api.h:101
void(* callback_t)(uint, uint)
User callback for event handling.
Definition spin1_api.h:109
uint largest_number_of_concurrent_timer_tic_overruns
the max number of timer tics callbacks being queued at any time
Definition spin1_api.h:623
static void spin1_set_timer_tick(uint time)
Set the timer tick rate. No phase offset.
Definition spin1_api.h:141
void spin1_callback_off(uint event_id)
Disables a callback for a class of event.
Definition spin1_api.c:594
static uint spin1_send_sdp_msg(sdp_msg_t *msg, uint timeout)
Sends an SDP message.
Definition spin1_api.h:342
void spin1_exit(uint error)
Terminates a simulation passing a return code.
Definition spin1_api.c:679
static void spin1_srand(uint seed)
This function is used to initialize the seed for the pseudo-random number generator.
Definition spin1_api.h:583
static const uint VIC_EVENTS[]
Match events above to their VIC interrupts. Indices must match!
Definition spin1_api.h:75
uint spin1_get_chip_id(void)
Returns the (machine-wide) chip ID.
Definition spin1_api.c:1292
void spin1_enable_timer_schedule_proc(void)
This function enables the use of timer_schedule_proc.
Definition spin1_api.c:1453
static uint spin1_send_mc_packet(uint key, uint data, uint load)
This function enqueues a request to send a multicast packet.
Definition spin1_api.h:290
uint spin1_get_core_id(void)
Returns the core ID.
Definition spin1_api.c:1272
uint exit_code
simulation exit code
Definition spin1_api.h:606
uint spin1_start(sync_bool sync)
Begins a simulation by enabling the timer (if called for) and beginning the dispatcher loop....
Definition spin1_api.c:921
@ DMA_READ
DMA read from SDRAM to TCM.
Definition spin1_api.h:91
@ DMA_WRITE
DMA write from TCM to SDRAM.
Definition spin1_api.h:92
uint discarded_fr_packets
total discarded FR packets by API
Definition spin1_api.h:620
uint task_queue_full
task queue full count
Definition spin1_api.h:614
void spin1_mode_restore(uint value)
Sets the CPSR to the value given in sr, in order to restore the CPSR following a call to spin1_irq_di...
uint spin1_start_paused(void)
Begins a simulation by enabling the timer (if called for) and beginning the dispatcher loop once the ...
Definition spin1_api.c:926
uint dma_queue_full
DMA queue full count.
Definition spin1_api.h:613
static void spin1_led_control(uint p)
This function controls LEDs according to an input pattern.
Definition spin1_api.h:566
void spin1_callback_on(uint event_id, callback_t cback, int priority)
Enables a callback for a class of event.
Definition spin1_api.c:546
diagnostic data available to the application
Definition spin1_api.h:605
@ PKT_FR_PL
Fixed-route with payload.
Definition spinnaker.h:1057
@ PKT_FR
Packet is fixed route packet.
Definition spinnaker.h:1050
@ PKT_MC_PL
Multicast with payload.
Definition spinnaker.h:1054
@ PKT_MC
Packet is multicast packet.
Definition spinnaker.h:1046
@ SOFTWARE_INT
Used only for local software interrupt generation.
Definition spinnaker.h:356
@ CC_FR_INT
Local comms controller fixed route packet received.
Definition spinnaker.h:382
@ DMA_DONE_INT
Local DMA controller transfer complete.
Definition spinnaker.h:367
@ CC_MC_INT
Local comms controller multicast packet received.
Definition spinnaker.h:379
@ TIMER1_INT
Local counter/timer interrupt 1.
Definition spinnaker.h:359
unsigned char uchar
Unsigned integer - 8 bits.
Definition spinnaker.h:37
unsigned int uint
Unsigned integer - 32 bits.
Definition spinnaker.h:39