5 struct lockclass
* lockclass_Init(int CPU
){
6 struct lockclass
*this = (struct lockclass
*) g_malloc(sizeof(struct lockclass
));
7 lockclassContext_Init(&this->_fsm
, this);
9 this->local_stack
= g_array_new(FALSE
, FALSE
, sizeof(struct lockstruct
*));
13 struct lockstruct
* lockstruct_Init(guint32 address
){
14 struct lockstruct
*this = (struct lockstruct
*) g_malloc(sizeof(struct lockstruct
));
15 this->lock_add
= address
;
16 this->taken_irqs_off
=0;
17 this->taken_irqs_on
=0;
18 this->hardirq_context
=0;
21 int irq_check(struct lockclass
*fsm
, void *lock
, int hardirqs_off
, int hardirq_context
){
22 struct lockstruct
*lock_check
= (struct lockstruct
*)lock
;
24 lock_check
->hardirq_context
=hardirq_context
;
25 if(hardirq_context
&& lock_check
->taken_irqs_on
)
27 else if(lock_check
->hardirq_context
&& !hardirqs_off
)
32 int empty_stack(struct lockclass
*fsm
){
33 return fsm
->local_stack
->len
;
35 int lock_held(struct lockclass
*fsm
, struct lockstruct
*lock
){
36 //loop through stack & return 1 if found, 0 otherwise
37 int i
, len
=fsm
->local_stack
->len
;
40 struct lockstruct
*temp
= g_array_index(fsm
->local_stack
, struct lockstruct
*, i
);
46 int lock_held_on_behalf(struct lockclass
*fsm
, guint32 pid
){
47 //loop through stack & return 1 if a lock is being held on behalf of pid
48 int i
, len
=fsm
->local_stack
->len
;
51 struct lockstruct
*temp
=g_array_index(fsm
->local_stack
, struct lockstruct
*, i
);
59 void lockclass_test(){
60 //the smc compiler didn't generate the right code since no action was specified. (only a guard)
63 void lockclass_warning(struct lockclass
*fsm
, char *msg
, struct lockstruct
*lock
){
64 printf("WARNING: %s\n", msg
);
66 printf("Lock 0x%x: taken_hard_irqs_on: %d, taken_hard_irqs_off %d, hardirq_context %d\n ",
67 lock
->lock_add
, lock
->taken_irqs_on
, lock
->taken_irqs_off
, lock
->hardirq_context
);
69 void lockclass_pushlock(struct lockclass
*fsm
, struct lockstruct
*lock
){
70 g_array_append_val(fsm
->local_stack
, lock
);
73 void lockclass_poplock(struct lockclass
*fsm
, struct lockstruct
*lock
){
75 struct lockstruct
*temp
;
76 for(i
=fsm
->local_stack
->len
-1; i
>=0; i
--){
77 temp
=g_array_index(fsm
->local_stack
, struct lockstruct
*, i
);
79 g_array_remove_index(fsm
->local_stack
, i
);
This page took 0.032041 seconds and 5 git commands to generate.