-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfingerprint.c
More file actions
93 lines (73 loc) · 2.53 KB
/
Copy pathfingerprint.c
File metadata and controls
93 lines (73 loc) · 2.53 KB
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
/*
* fingerprint.c
*
* Created on: 2014-02-23
* Author: Jonah
*/
#include <stdint.h>
#include <system.h>
#include "fingerprint.h"
//*********************************
//Control register addresses
//*********************************
void fprint_enable_task(int task_id){
//When enabling, the current state register
//takes the task_id with a 1 in the MSB.
uint32_t* fprint_currentstate = (uint32_t*)(FPRINT_BASE_ADDRESS
+ FPRINT_SPR_CURRENTSTATE);
*fprint_currentstate = FPRINT_CURRENTSTATE_ENABLE_MASK | task_id;
}
void fprint_disable_task(int task_id){
//When a task is checked in, the task number
//must be rewritten to the current state register
//with the MSB set to 0.
uint32_t* fprint_currentstate = (uint32_t*)(FPRINT_BASE_ADDRESS
+ FPRINT_SPR_CURRENTSTATE);
*fprint_currentstate = FPRINT_CURRENTSTATE_DISABLE_MASK | task_id;
}
void fprint_reset_irq(void){
//In the case of a collision
//Reset the exception register in the fingerprint unit.
uint32_t* fprint_collision = (uint32_t*)(COMPARATOR_BASE_ADDRESS
+ COMPARATOR_EXCEPTION_OFFSET);
*fprint_collision = 0;
}
int comp_get_status(Fprint_Status* fps){
Fprint_Status* f = (uint32_t*)(COMPARATOR_BASE_ADDRESS +
COMPARATOR_EXCEPTION_OFFSET);
fps->status_reg = f->status_reg;
fps->successful_reg = f->successful_reg;
fps->failed_reg = f->failed_reg;
return 0;
}
void comp_set_core_assignment(int table_column, int core_id, int task_id){
uint32_t* fprint_core_entry = (uint32_t*)(COMPARATOR_BASE_ADDRESS +
COMPARATOR_CORE_ASSIGNMENT_OFFSET);
*fprint_core_entry = (table_column << COMP_DATA_CORE_SHIFT)
+ (task_id << COMP_DATA_TASKID_SHIFT) + core_id;
}
void comp_set_core_assignment_table(Core_Assignment_Table* ca){
int i,j;
for(i = 0; i < CA_TABLE_MAX_REDUNDANCY; i++){
for(j = 0; j < CA_TABLE_NUM_TASKS; j++){
uint32_t a = ca->table[i][j];
set_core_assignment(i,a,j);
}
}
}
void comp_set_success_maxcount_value(int task_id, int logical_core_id, int maxcount) {
uint32_t* fprint_maxcount_reg = (uint32_t*)(COMPARATOR_BASE_ADDRESS
+ COMP_SUCCESS_COUNTER_MAX_REG);
*fprint_maxcount_reg = (logical_core_id << COMP_DATA_CORE_SHIFT)
+ (task_id << COMP_DATA_TASKID_SHIFT) + maxcount;
}
void comp_set_nmr(int task_id, int nmr) {
uint32_t* nmr_reg = (uint32_t*)(COMPARATOR_BASE_ADDRESS
+ COMPARATOR_NMR_REG_OFFSET);
*nmr_reg = (task_id << COMP_DATA_TASKID_SHIFT) + nmr;
}
void comp_checkpoint_irq_reset(int core_id) {
int *checkpoint_irq = (int *) (COMP_CPU_IRQ_BASE
+ (core_id << COMP_CPU_IRQ_CORE_SHIFT));
*checkpoint_irq = 0;
}