summaryrefslogtreecommitdiff
path: root/cleopatre/plcdrv/arm/inc/hal.h
blob: b4b648b800e25c726582921768101a19660c235b (plain)
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
#ifndef hal_h
#define hal_h
/* Cleopatre project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal.h
 * \brief   interfaces for mailbox layer
 * \ingroup Cleopatre - PlcDrv
 *
 * this file content interfaces and exported macros, variables... For the
 * Hardware Abstraction Layer
 */

#ifdef __UTESTS__
#include "hal_utests.h"
#endif

#define A2L_RING_MASK            (A2L_RING_SIZE-1)
#define L2A_RING_MASK            (L2A_RING_SIZE-1)

/** hal layer context structure */
struct halctx {
    uint32_t *A2L_ptr;
    uint32_t *L2A_ptr;
    const uint32_t *A2L_head;
    uint32_t *A2L_tail;
    uint32_t *L2A_head;
    const uint32_t *L2A_tail;
    uint32_t *A2L_it;
    uint32_t *L2A_it;
    uint32_t *L2A_it_mask;
    uint32_t (*virt_to_phys)(uint32_t);
    uint32_t (*phys_to_virt)(uint32_t);
};

/** 
 * Initialize the hal layer
 *
 * \param  init  user information.
 * \return  hal context.
 */
struct halctx* halmbx_init(struct init_info *info);

/** 
 * UnInitialize the hal layer
 * 
 * \param  ctx  hal context.
 */
void halmbx_uninit(struct halctx *ctx);

/** 
 * Check if Leon to Arm mailbox queue is empty.
 *
 * \return  0 if the queue is empty.
 */
int halmbx_L2Amail_not_empty_queue(void);

/** 
 * Check Arm to Leon mailbox queue status.
 *
 * \return  queue state.
 */
int halmbx_A2Lmail_status_queue(void);

/** 
 * Check Leon to Arm mailbox queue status.
 *
 * \return  queue state.
 */
int halmbx_L2Amail_status_queue(void);

/** 
 * Copy message to the ring buffer.
 *
 * \param  message  pointer to the message align on 32bits.
 * \param  size  message size in bytes and align on 32bits.
 * \return  error code.
 */
int halmbx_copy_to_ring (uint32_t *message, int size);

/** 
 * Copy message from the ring buffer.
 *
 * \param  message  pointer to the message align on 32bits.
 * \param  size  max message size in bytes and align on 32bits.
 * \return  error code.
 */
int halmbx_copy_from_ring (uint32_t *message, int size);

/** 
 * Update the ring management for Leon to Arm mailbox (TX).
 *
 * \param  size  real size of the last proceed message.
 * \return  error code.
 */
int halmbx_A2Lmail_update (int size);

/** 
 * Update the ring management for Arm to Leon mailbox (RX).
 *
 * \param  size  real size of the last proceed message.
 * \return  error code.
 */
int halmbx_L2Amail_update (int size);

/** 
 * Enable the Leon to Arm Trigger Interrupt.
 */
void L2At_it_enable(void);

/** 
 * Disable the Arm to Leon Acknowledge Interrupt.
 */
void A2La_it_disable(void);

/** 
 * Disable the Leon to Arm Trigger Interrupt.
 */
void L2At_it_disable(void);

/** 
 * Set the Arm to Leon Interrupt.
 */
void set_A2Lt_interrupt(void);

/** 
 * Set the Arm to Leon acknowledge Interrupt.
 */
void set_L2Aa_interrupt(void);

/** 
 * Clear the Leon to Arm Interrupt.
 */
void clr_L2At_interrupt(void);

/** 
 * Clear the Leon to Arm acknowledge Interrupt.
 */
void clr_A2La_interrupt(void);

#endif /* hal_h */