SpiNNFrontEndCommon 7.1.1
Common support code for user-facing front end systems.
Loading...
Searching...
No Matches
data_specification.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
21#include "data_specification.h"
22
23#include <sark.h>
24#include <debug.h>
25
27enum {
34 VERSION_MASK = 0xFFFF,
37 VERSION_SHIFT = 16
38};
39
40#define N_REGIONS 32
41
42
48static inline void verify_checksum(data_specification_metadata_t *ds_regions,
49 uint32_t region) {
50 uint32_t *data = ds_regions->regions[region].pointer;
51 uint32_t checksum = ds_regions->regions[region].checksum;
52 uint32_t n_words = ds_regions->regions[region].n_words;
53
54 // If the region is not in use or marked as having no size, skip
55 if (data == NULL || n_words == 0) {
56 return;
57 }
58
59 // Do simple unsigned 32-bit checksum
60 uint32_t sum = 0;
61 for (uint32_t i = 0; i < n_words; i++) {
62 sum += data[i];
63 }
64 if (sum != checksum) {
65 log_error("[ERROR] Region %u with %u words starting at 0x%08x: "
66 "checksum %u does not match computed sum %u",
67 region, n_words, data, checksum, sum);
69 }
70
71 // Avoid checking this again (unless it is changed)
72 ds_regions->regions[region].checksum = 0;
73 ds_regions->regions[region].n_words = 0;
74}
75
77 // Get pointer to 1st virtual processor info struct in SRAM
78 vcpu_t *virtual_processor_table = (vcpu_t*) SV_VCPU;
79
80 // Get the address this core's DTCM data starts at from the user data
81 // member of the structure associated with this virtual processor
82 uint user0 = virtual_processor_table[spin1_get_core_id()].user0;
83
84 log_debug("SDRAM data begins at address: %08x", user0);
85
86 // Cast to the correct type
88 for (uint32_t region = 0; region < N_REGIONS; region++) {
89 verify_checksum(ds_regions, region);
90 }
91
92 return ds_regions;
93}
94
97 // Check for the magic number
99 log_error("[ERROR] Magic number is incorrect: %08x", ds_regions->magic_number);
100 return false;
101 }
102
103 if (ds_regions->version != DATA_SPECIFICATION_VERSION) {
104 log_error("[ERROR] Version number is incorrect: %08x", ds_regions->version);
105 return false;
106 }
107
108 // Log what we have found
109 log_info("magic = %08x, version = %d.%d", ds_regions->magic_number,
110 ds_regions->version >> VERSION_SHIFT,
111 ds_regions->version & VERSION_MASK);
112
113 return true;
114}
data_specification_metadata_t * data_specification_get_data_address(void)
Gets the location of the data for this core using the user0 entry of the SARK VCPU structure.
static void verify_checksum(data_specification_metadata_t *ds_regions, uint32_t region)
Verify the checksum of a region; on failure, RTE.
@ DATA_SPECIFICATION_VERSION
The version of the spec we support; only one was ever supported.
@ VERSION_MASK
The mask to apply to the version number to get the minor version.
@ VERSION_SHIFT
@ DATA_SPECIFICATION_MAGIC_NUMBER
bool data_specification_read_header(data_specification_metadata_t *ds_regions)
Reads the header from the address given and checks if the parameters are of the correct values.
Data Specification region access API.
uint32_t n_words
The number of valid words in the region.
region_desc_t regions[]
The regions; as many as required.
uint32_t checksum
Simple checksum which is rounded 32-bit unsigned sum of words.
uint32_t magic_number
A magic number, used to verify that the pointer is sane.
uint32_t version
The version of the DSE data layout specification being followed.
The central structure that the DSE writes.
static uint32_t data[ITEMS_PER_DATA_PACKET]
SpiNNaker debug header file.
void log_error(const char *message,...)
This function logs errors. Errors usually indicate a serious fault in the program,...
void log_debug(const char *message,...)
This function logs debugging messages. This level of message is normally not printed except when the ...
void log_info(const char *message,...)
This function logs informational messages. This is the lowest level of message normally printed.
#define SV_VCPU
RTE_SWERR
uint user0
void rt_error(uint code,...)
#define NULL
uint spin1_get_core_id(void)
unsigned int uint