-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement kernel mode. More tests for interrupts. Fixes Issue #18.
- Loading branch information
Sarah Mount
committed
Jul 2, 2016
1 parent
7cc2e5a
commit 6f3173c
Showing
17 changed files
with
371 additions
and
39 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* Based on code by Ola Jeppsson @olajep | ||
* From: https://github.com/olajep/esim-test-bins | ||
*/ | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
|
||
void fpu_interrupt_handler() __attribute__ ((interrupt)); | ||
void fpu_interrupt_handler() { | ||
printf("fpu_handler:\tyou should see this message only once.\n"); | ||
} | ||
|
||
int main() { | ||
register uint32_t r38 __asm__("r38"); /* tmp for enabling fp exceptions. */ | ||
|
||
float a = 1e38; | ||
float b = 1e38; | ||
float c; | ||
|
||
uint32_t *ivt_usr, *ivt_exception; /* Interrupt vector pointers. */ | ||
uint32_t addr_usr, addr_exception; /* Relative branch address. */ | ||
uint32_t br32_usr, br32_exception; /* Relative address branch instruction. */ | ||
|
||
ivt_usr = (uint32_t *) 0x4; | ||
addr_usr = (uint32_t) &fpu_interrupt_handler; | ||
addr_usr -= (uint32_t) ivt_usr; /* Adjust for user interrupt branch address. */ | ||
addr_usr = (addr_usr >> 1); /* Lowest bit is skipped (alignment). */ | ||
br32_usr = 0xe8; | ||
br32_usr |= ((addr_usr & (0x00ffffff))) << 8; | ||
*ivt_usr = br32_usr; | ||
|
||
/* Clear imask. */ | ||
__asm__("movt r40, 0"); | ||
__asm__("mov r40, 0"); | ||
__asm__("movts imask, r40"); | ||
|
||
/* Enable float exceptions. */ | ||
__asm__("movfs r38, config"); | ||
r38 |= 14; | ||
__asm__("movts config, r38"); | ||
|
||
/* Trigger fpu interrupt. */ | ||
c = a * b; | ||
|
||
/* Disable fpu exceptions. */ | ||
__asm__("movfs r38, config"); | ||
r38 = r38 & ~(1 << 1); /* Invalid floating-point exception. */ | ||
r38 = r38 & ~(1 << 2); /* Overflow floating-point exception. */ | ||
r38 = r38 & ~(1 << 3); /* Underflow floating-point exception. */ | ||
__asm__("movts config, r38"); | ||
|
||
/* Trigger fpu interrupt. */ | ||
c = a * b; | ||
|
||
printf("Test complete.\n"); | ||
return 0; | ||
} |
Binary file not shown.
Oops, something went wrong.