-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
azertyfun
committed
Oct 14, 2016
1 parent
c255def
commit b5be64e
Showing
7 changed files
with
178 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#include "iacm.h" | ||
|
||
typedef enum { | ||
ACTION_SET_MODE, | ||
ACTION_SET_RUN_TIME, | ||
ACTION_SET_SLEEP_TIME, | ||
ACTION_SET_INTERRUPT_MESSAGE, | ||
ACTION_GET_CLOCK_RATE, | ||
ACTION_GET_RCLOCK_RATE, | ||
ACTION_RESET_SYSTEM = 0x505 | ||
} iacm_action; | ||
|
||
void *iacm_init (u16 iacm, u16 UNUSED (int_number), Int_handler *UNUSED (int_handler_location)) { | ||
Iacm_driver_data *data = kmalloc (0, sizeof (Iacm_driver_data)); | ||
data->iacm = iacm; | ||
|
||
return data; | ||
} | ||
|
||
|
||
void iacm_destroy (Iacm_driver_data *UNUSED (data)) { | ||
// Nothing to free | ||
} | ||
|
||
u16 iacm_update_function (void *data, u16 message, u16 arg1, u16 arg2) { | ||
switch ((Iacm_message)message) { | ||
case IACM_SET_MODE: | ||
iacm_set_mode (data, arg1); | ||
break; | ||
case IACM_SET_RUN_TIME: | ||
iacm_set_run_time (data, arg1); | ||
break; | ||
case IACM_SET_SLEEP_TIME: | ||
iacm_set_sleep_time (data, arg1); | ||
break; | ||
case IACM_SET_INTERRUPT_MESSAGE: | ||
iacm_set_interrupt_message (data, arg1); | ||
break; | ||
case IACM_GET_CLOCK_RATE: | ||
iacm_get_clock_rate (data, (u16 *)arg1, (u16 *)arg2); | ||
break; | ||
case IACM_GET_RCLOCK_RATE: | ||
iacm_get_rclock_rate (data, (u16 *)arg1, (u16 *)arg2); | ||
break; | ||
case IACM_RESET_SYSTEM: | ||
iacm_reset_system (data); | ||
break; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
|
||
void iacm_set_mode (Iacm_driver_data *data, u16 mode) { | ||
register u16 action __asm("A") = ACTION_SET_MODE; | ||
register u16 arg_b __asm("B") = mode; | ||
__asm volatile("hwi %0" | ||
: | ||
: "X"(data->iacm), | ||
"r"(action), | ||
"r"(arg_b)); | ||
} | ||
|
||
|
||
void iacm_set_run_time (Iacm_driver_data *data, u16 time) { | ||
register u16 action __asm("A") = ACTION_SET_RUN_TIME; | ||
register u16 arg_b __asm("B") = time; | ||
__asm volatile("hwi %0" | ||
: | ||
: "X"(data->iacm), | ||
"r"(action), | ||
"r"(arg_b)); | ||
} | ||
|
||
|
||
void iacm_set_sleep_time (Iacm_driver_data *data, u16 time) { | ||
register u16 action __asm("A") = ACTION_SET_SLEEP_TIME; | ||
register u16 arg_b __asm("B") = time; | ||
__asm volatile("hwi %0" | ||
: | ||
: "X"(data->iacm), | ||
"r"(action), | ||
"r"(arg_b)); | ||
} | ||
|
||
|
||
void iacm_set_interrupt_message (Iacm_driver_data *data, u16 message) { | ||
register u16 action __asm("A") = ACTION_SET_INTERRUPT_MESSAGE; | ||
register u16 arg_b __asm("B") = message; | ||
__asm volatile("hwi %0" | ||
: | ||
: "X"(data->iacm), | ||
"r"(action), | ||
"r"(arg_b)); | ||
} | ||
|
||
|
||
void iacm_get_clock_rate (Iacm_driver_data *data, u16 *rate_high, u16 *rate_low) { | ||
register u16 action __asm("A") = ACTION_GET_CLOCK_RATE; | ||
__asm volatile("hwi %2" | ||
: "=X"(*rate_high), | ||
"=X"(*rate_low) | ||
: "X"(data->iacm), | ||
"r"(action)); | ||
} | ||
|
||
|
||
void iacm_get_rclock_rate (Iacm_driver_data *data, u16 *rate_high, u16 *rate_low) { | ||
register u16 action __asm("A") = ACTION_GET_RCLOCK_RATE; | ||
__asm volatile("hwi %2" | ||
: "=X"(*rate_high), | ||
"=X"(*rate_low) | ||
: "X"(data->iacm), | ||
"r"(action)); | ||
} | ||
|
||
|
||
void iacm_reset_system (Iacm_driver_data *data) { | ||
register u16 action __asm("A") = ACTION_RESET_SYSTEM; | ||
__asm volatile("hwi %0" | ||
: | ||
: "X"(data->iacm), | ||
"r"(action)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "kernel/interrupt_handler/interrupt_handler.h" | ||
#include "types.h" | ||
|
||
typedef enum { | ||
IACM_SET_MODE, | ||
IACM_SET_RUN_TIME, | ||
IACM_SET_SLEEP_TIME, | ||
IACM_SET_INTERRUPT_MESSAGE, | ||
IACM_GET_CLOCK_RATE, | ||
IACM_GET_RCLOCK_RATE, | ||
IACM_RESET_SYSTEM | ||
} Iacm_message; | ||
|
||
typedef struct { | ||
u16 iacm; | ||
} Iacm_driver_data; | ||
|
||
|
||
void *iacm_init (u16 iacm, u16 UNUSED (int_number), Int_handler *UNUSED (int_handler_location)); | ||
void iacm_destroy (Iacm_driver_data *UNUSED (data)); | ||
u16 iacm_update_function (void *data, u16 message, u16 arg1, u16 arg2); | ||
void iacm_set_mode (Iacm_driver_data *data, u16 mode); | ||
void iacm_set_run_time (Iacm_driver_data *data, u16 time); | ||
void iacm_set_sleep_time (Iacm_driver_data *data, u16 time); | ||
void iacm_set_interrupt_message (Iacm_driver_data *data, u16 message); | ||
void iacm_get_clock_rate (Iacm_driver_data *data, u16 *rate_high, u16 *rate_low); | ||
void iacm_get_rclock_rate (Iacm_driver_data *data, u16 *rate_high, u16 *rate_low); | ||
void iacm_reset_system (Iacm_driver_data *data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters