Access parts of the base system. More...
Go to the source code of this file.
Classes | |
| struct | system_argv_t |
| Command line arguments passed to us from launcher. More... | |
Macros | |
| #define | SYSTEM_BUS_CLOCK_HZ 243000000 |
| Memory bus clock speed. | |
| #define | SYSTEM_CORE_CLOCK_HZ 729000000 |
| Core clock speed. | |
| #define | SYSTEM_TB_CLOCK_HZ (SYSTEM_BUS_CLOCK_HZ / 4) |
| Time base (internal CPU counter) clock speed. | |
| #define | SYSTEM_US_TO_TICKS(us) |
| Convert microseconds to time base ticks. | |
| #define | SYSTEM_MS_TO_TICKS(ms) |
| Convert miliseconds to time base ticks. | |
| #define | SYSTEM_S_TO_TICKS(s) |
| Convert seconds to time base ticks. | |
| #define | SYSTEM_MEM_UNCACHED(address) |
| Convert a memory address into a uncached virtual address. | |
| #define | SYSTEM_MEM_CACHED(address) |
| Convert a memory address into a cached virtual address. | |
| #define | SYSTEM_MEM_PHYSICAL(address) |
| Convert a memory address into a physical address. | |
| #define | PACKED __attribute__((packed)) |
| Pack a data structure. | |
| #define | MEM2 __attribute__((section(".mem2"))) |
| #define | SYSTEM_MAIN_STACK_SIZE (1024*1024*4) |
| Size of the stack of the application main. | |
| #define | SYSTEM_GET_MSR(msr) |
| Gets the value of the MSR register. | |
| #define | SYSTEM_SET_MSR(msr) |
| Sets the value of the MSR register. | |
| #define | SYSTEM_GET_DEC(msr) |
| Gets the value of the decrementing register. | |
| #define | SYSTEM_SET_DEC(msr) |
| Sets the value of the decrementing register. | |
| #define | SYSTEM_DISABLE_ISR(ee_enabled) |
| Disables interrupts. | |
| #define | SYSTEM_ENABLE_ISR(ee_enabled) |
| Enables interrupts if ee_enabled is set. | |
| #define | SYSTEM_SYNC() |
| Insures all previous instructions have executed. | |
| #define | SYSTEM_ISYNC() |
| Refetches any instructions that may have been fetched earlier. | |
| #define | ASSERT(x) |
| Triggers a crash with debug info if a condition fails. | |
| #define | ASSERT_OUT_OF_MEMORY(x) |
| Triggers a out of memory assertion if the condition fails. | |
| #define | ALIGN(x) |
| Add an alignment attribute to some data. | |
| #define | SYSTEM_SWITCH_SP(x) |
| Switches the stack pointer with pxCurrentTCB in a task switch. | |
Functions | |
| uint64_t | system_get_time_base_int () |
| Gets the time base register of the CPU. | |
| void | system_delay_int (uint64_t ticks) |
| Sleeps for a certain number of ticks. | |
| void | system_flush_dcache (const void *data, uint32_t size) |
| Flushes data cache in a range. | |
| void | system_invalidate_dcache (void *data, uint32_t size) |
| Invalidates data cache in a range. | |
| void | system_invalidate_icache (void *data, uint32_t size) |
| Invalidates the instruction cache in a range. | |
| void * | system_aligned_malloc (uint32_t bytes, uint32_t alignment) |
| Allocate memory with alignment. | |
| void | system_aligned_free (void *ptr) |
| Free allocated memory with alignment. | |
| void | system_initialize () |
| Initializes the system. | |
| void | system_get_boot_path (const char *device, char *buffer, size_t length) |
| Looks in the argv command line for a specific boot path. | |
Variables | |
| system_argv_t | system_argv |
Access parts of the base system.
Access parts of the base system. Like time and such.
| #define ALIGN | ( | x | ) |
Add an alignment attribute to some data.
Used to make a variable memory aligned for hardware
| #define ASSERT | ( | x | ) |
Triggers a crash with debug info if a condition fails.
Triggers a crash with debug info if a condition fails.
| #define ASSERT_OUT_OF_MEMORY | ( | x | ) |
Triggers a out of memory assertion if the condition fails.
Normally out of memory errors are propagated up as a return value. But in the event a driver, or some critical system fails to allocate the heap at runtime, and must crash, then this assertion can be used.
Games can also use it if they find a memory condition fatal for whatever reason.
| #define PACKED __attribute__((packed)) |
Pack a data structure.
Attribute to make it so fields in a data structure are not alignment padded.
| #define SYSTEM_BUS_CLOCK_HZ 243000000 |
Memory bus clock speed.
Clock speed of the memory bus. It also defines the time of the CPU.
| #define SYSTEM_CORE_CLOCK_HZ 729000000 |
Core clock speed.
Clock speed of the CPU core.
| #define SYSTEM_DISABLE_ISR | ( | ee_enabled | ) |
Disables interrupts.
Disables interrupts, returns the external interrupt enable bit.
| #define SYSTEM_ENABLE_ISR | ( | ee_enabled | ) |
Enables interrupts if ee_enabled is set.
Enables interrupts if ee_enabled is set. Can be used along with SYSTEM_DISABLE_ISR, to only reenable interrupts if they were enabled in the first place.
| #define SYSTEM_GET_DEC | ( | msr | ) |
Gets the value of the decrementing register.
Gets the value of the decrementing register. When it his zero an interrupt will be triggered. Used for context switching.
| #define SYSTEM_GET_MSR | ( | msr | ) |
Gets the value of the MSR register.
Gets the value of the MSR register.
| #define SYSTEM_ISYNC | ( | ) |
Refetches any instructions that may have been fetched earlier.
Refetches any instructions that may have been fetched earlier.
| #define SYSTEM_MAIN_STACK_SIZE (1024*1024*4) |
Size of the stack of the application main.
Size of the stack of the application main. When the system starts, the main() will be a FreeRTOS task of this stack size.
| #define SYSTEM_MEM_CACHED | ( | address | ) |
Convert a memory address into a cached virtual address.
Converts a cached address into a cached virtual address. This is done by setting the MSB nibble.
| #define SYSTEM_MEM_PHYSICAL | ( | address | ) |
Convert a memory address into a physical address.
Converts a cached address into a physical address. This is done by setting the MSB nibble.
| #define SYSTEM_MEM_UNCACHED | ( | address | ) |
Convert a memory address into a uncached virtual address.
Converts a cached address into a uncached virtual address. This is done by setting the MSB nibble.
| #define SYSTEM_MS_TO_TICKS | ( | ms | ) |
Convert miliseconds to time base ticks.
Convert miliseconds to time base ticks.
| #define SYSTEM_S_TO_TICKS | ( | s | ) |
Convert seconds to time base ticks.
Convert seconds to time base ticks.
| #define SYSTEM_SET_DEC | ( | msr | ) |
Sets the value of the decrementing register.
Sets the value of the decrementing register. When it his zero an interrupt will be triggered. Used for context switching.
| #define SYSTEM_SET_MSR | ( | msr | ) |
Sets the value of the MSR register.
Sets the value of the MSR register.
| #define SYSTEM_SWITCH_SP | ( | x | ) |
Switches the stack pointer with pxCurrentTCB in a task switch.
Switches the stack pointer with pxCurrentTCB in a task switch. Do not call this outside of exception handers/syscalls that switch execution context.
| #define SYSTEM_SYNC | ( | ) |
Insures all previous instructions have executed.
Insures all previous instructions have executed.
| #define SYSTEM_TB_CLOCK_HZ (SYSTEM_BUS_CLOCK_HZ / 4) |
Time base (internal CPU counter) clock speed.
Clock speed of the CPU's internal clock. It is 1/4th the bus clock speed.
| #define SYSTEM_US_TO_TICKS | ( | us | ) |
Convert microseconds to time base ticks.
Convert microseconds to time base ticks.
|
extern |
Free allocated memory with alignment.
Free allocated memory with alignment.
|
extern |
Allocate memory with alignment.
Allocate memory aligned to a certain number of bytes. A lot of hardware requires aligned memory. Usually 32 bytes.
Must be a power of 2.
Offsets the pointer by the alignment and stores the original unaligned pointer before the pointer returned.
|
extern |
Sleeps for a certain number of ticks.
Waits for a certain number of ticks to elapse.
No interrupts version.
Recommend using FreeRTOS vTaskDelay instead.
| ticks | Number of ticks to wait for |
|
extern |
Flushes data cache in a range.
Flushes the CPUs data cache in a range such that all changes from CPU be visible to hardware.
Does not call sync after, so right after this the cache may not be done flushing.
|
extern |
Looks in the argv command line for a specific boot path.
When mounting a file system, this can be used to change the directory into the one the program was launched from if the file system is the one its running from.
For example passing a device of "sd" into device, it will fill buffer with the /apps/my_app/ path if the game was launched from the sd. If not it will return / into it.
| device | Boot device |
| buffer | Outputted path buffer |
| length | Length of path buffer. |
|
extern |
Gets the time base register of the CPU.
Returns the 64 bit internal timer value of the CPU. Ticks up at speed of SYSTEM_TB_CLOCK_HZ.
No interrupts version.
|
extern |
Initializes the system.
Initializes the system. Called from start.s, so this all happens before the C program starts running.
|
extern |
Invalidates data cache in a range.
Invalidates the CPUs data cache in a range such that all changes from hardware are visible to the CPU.
|
extern |
Invalidates the instruction cache in a range.
Invalidates the CPUs instruction cache in a range such that all changes from CPU be visible to instruction fetching.
Does not call isync after, so right after this the cache may not be done invalidating.