KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mboot.h
Go to the documentation of this file.
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : mboot.h
11  * Created : July 2013
12  * Author : David Calvo, Vincent van Beveren
13  */
14 
15 #ifndef MBOOT_H_
16 #define MBOOT_H_
17 /**
18  * @file
19  *
20  * @ingroup wbdrivers
21  *
22  * Multiboot Driver, exposes one function, mbootLoad.
23  */
24 #include <stdint.h>
25 #include <stdbool.h>
26 
27 #include "lm32soc/dev_soc.h"
28 #include "cfg_soc.h"
29 
30 
31 #define MBOOT_GOLDEN 0 //!< The golden image index position.
32 #define MBOOT_RUNTIME 1 //!< Runtime image
33 #define MBOOT_RUNTIME_2 2 //!< Runtime image 2
34 #define MBOOT_DIAGNOSTIC 3 //!< Diagnostic image
35 
36 
37 #define MBOOT_STS_VALID BIT(0) // MBoot register valid
38 #define MBOOT_STS_FALLBACK BIT(1) // Fallback used
39 #define MBOOT_STS_IPROG BIT(2) // IProg issued
40 #define MBOOT_STS_WTO_ERROR BIT(3) // Watchdog timeout error
41 #define MBOOT_STS_ID_ERROR BIT(4) // ID error
42 #define MBOOT_STS_CRC_ERROR BIT(5) // CRC error
43 #define MBOOT_STS_WRAP_ERROR BIT(6) // WRAP error
44 
45 /**
46  * Returns the ID-code
47  *
48  * @return The 32 bits Xilinx device ID code.
49  */
50 static inline uint32_t mbootIDCode()
51 {
52  return MBOOT->IDCODE;
53 }
54 
55 /**
56  * Returns the boot status
57  *
58  * @param previous Status of previous boot (instead of current)
59  *
60  * @return A bitmask of a combination of MBOOT_STS_* bits.
61  */
62 static inline int mbootBootStatus(bool previous)
63 {
64  return 0xFF & ( MBOOT->BOOTSTS >> (previous ? 8 : 0));
65 }
66 
67 
68 /**
69  * Boots a specific image.
70  *
71  * @param imgNo The image to boot
72  */
73 void mbootLoad(int imgNo);
74 
75 /**
76  * Configures and starts the ICAPE2 watchdog.
77  *
78  * The watchdog can run in two modes:
79  * user - in which the user application must feed the watchdog. Otherwise a reconfigure will
80  * be triggered
81  * config - in this case the watchdog will be used to detect faulty reconfigurations.
82  *
83  * @param timer Timer value, runs approx. at MBOOT_WATCHDOG_FREQ.
84  * @param config Use as configuration timer instead of user timer.
85  */
86 void mbootWDogStart(uint32_t timer, bool config);
87 
88 /**
89  * Feed the watchdog.
90  */
91 static inline void mbootWDogFeed()
92 {
93  MBOOT->CMD = MBOOT_CMD_LTIMER;
94 }
95 
96 /**
97  * Stop the watchdog.
98  */
99 static inline void mbootWDogStop()
100 {
101  MBOOT->WTIMER = 0;
102 }
103 
104 #endif /* MBOOT_H_ */
static void mbootWDogFeed()
Feed the watchdog.
Definition: mboot.h:91
Defines the configuration of the LM32 SOC for the CLBv2.
static int mbootBootStatus(bool previous)
Returns the boot status.
Definition: mboot.h:62
void mbootLoad(int imgNo)
Boots a specific image.
Definition: mboot.c:38
static void mbootWDogStop()
Stop the watchdog.
Definition: mboot.h:99
#define MBOOT
Multiboot base pointer.
Definition: dev_soc.h:60
void mbootWDogStart(uint32_t timer, bool config)
Configures and starts the ICAPE2 watchdog.
static uint32_t mbootIDCode()
Returns the ID-code.
Definition: mboot.h:50
This file assigns all device structures to memory mapped structures.
#define MBOOT_CMD_LTIMER
Reload watchdog.
Definition: dev_mboot.h:33