N64 bootup and cache interfaces. More...
Files | |
file | n64sys.c |
N64 System Interface. | |
file | n64sys.h |
N64 System Interface. | |
Defines | |
#define | cache_op(op) |
Helper macro to perform cache refresh operations. | |
#define | UncachedAddr(_addr) ((void *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address. | |
#define | UncachedShortAddr(_addr) ((short *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address. | |
#define | UncachedUShortAddr(_addr) ((unsigned short *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address. | |
#define | UncachedLongAddr(_addr) ((long *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address. | |
#define | UncachedULongAddr(_addr) ((unsigned long *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address. | |
#define | CachedAddr(_addr) (((void *)(((unsigned long)(_addr))&~0x20000000)) |
Return the cached memory address for a given address. | |
#define | COUNTS_PER_SECOND (93750000/2) |
Number of updates to the count register per second. | |
Functions | |
int | sys_get_boot_cic () |
Return the boot CIC. | |
void | sys_set_boot_cic (int bc) |
Set the boot CIC. | |
volatile unsigned long | get_ticks (void) |
Read the number of ticks since system startup. | |
volatile unsigned long | get_ticks_ms (void) |
Read the number of millisecounds since system startup. | |
void | wait_ticks (unsigned long wait) |
Spin wait until the number of ticks have elapsed. | |
void | wait_ms (unsigned long wait) |
Spin wait until the number of millisecounds have elapsed. | |
void | data_cache_hit_writeback (volatile void *addr, unsigned long length) |
Force a data cache writeback over a memory region. | |
void | data_cache_hit_invalidate (volatile void *addr, unsigned long length) |
Force a data cache invalidate over a memory region. | |
void | data_cache_hit_writeback_invalidate (volatile void *addr, unsigned long length) |
Force a data cache writeback invalidate over a memory region. | |
void | data_cache_index_writeback_invalidate (volatile void *addr, unsigned long length) |
Force a data cache index writeback invalidate over a memory region. | |
void | inst_cache_hit_writeback (volatile void *addr, unsigned long length) |
Force an instruction cache writeback over a memory region. | |
void | inst_cache_hit_invalidate (volatile void *addr, unsigned long length) |
Force an instruction cache invalidate over a memory region. | |
void | inst_cache_index_invalidate (volatile void *addr, unsigned long length) |
Force an instruction cache index invalidate over a memory region. | |
Variables | |
int | __bootcic = 6102 |
Boot CIC. |
N64 bootup and cache interfaces.
The N64 system interface provides a way for code to interact with the memory setup on the system. This includes cache operations to invalidate or flush regions and the ability to set the boot CIC. The newlib Interface Hooks use the knowledge of the boot CIC to properly determine if the expansion pak is present, giving 4MB of additional memory. Aside from this, the MIPS r4300 uses a manual cache management strategy, where SW that requires passing buffers to and from hardware components using DMA controllers needs to ensure that cache and RDRAM are in sync. A set of operations to invalidate and/or write back cache is provided for both instruction cache and data cache.
#define cache_op | ( | op | ) |
addr=(void*)(((unsigned long)addr)&(~3));\ for (;length>0;length-=4,addr+=4) \ asm ("\tcache %0,(%1)\n"::"i" (op), "r" (addr))
Helper macro to perform cache refresh operations.
[in] | op | Operation to perform |
#define CachedAddr | ( | _addr | ) | (((void *)(((unsigned long)(_addr))&~0x20000000)) |
Return the cached memory address for a given address.
[in] | _addr | Address in RAM to convert to a cached address |
#define COUNTS_PER_SECOND (93750000/2) |
Number of updates to the count register per second.
The count register updates at "half maximum instruction issue rate". This appears to be half the CPU clock. Every second, this many counts will have passed in the count register
#define UncachedAddr | ( | _addr | ) | ((void *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address.
[in] | _addr | Address in RAM to convert to an uncached address |
#define UncachedLongAddr | ( | _addr | ) | ((long *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address.
[in] | _addr | Address in RAM to convert to an uncached address |
#define UncachedShortAddr | ( | _addr | ) | ((short *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address.
[in] | _addr | Address in RAM to convert to an uncached address |
#define UncachedULongAddr | ( | _addr | ) | ((unsigned long *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address.
[in] | _addr | Address in RAM to convert to an uncached address |
#define UncachedUShortAddr | ( | _addr | ) | ((unsigned short *)(((unsigned long)(_addr))|0x20000000)) |
Return the uncached memory address for a given address.
[in] | _addr | Address in RAM to convert to an uncached address |
void data_cache_hit_invalidate | ( | volatile void * | addr, | |
unsigned long | length | |||
) |
Force a data cache invalidate over a memory region.
Use this to force the N64 to update cache from RDRAM.
[in] | addr | Pointer to memory in question |
[in] | length | Length in bytes of the data pointed at by addr |
void data_cache_hit_writeback | ( | volatile void * | addr, | |
unsigned long | length | |||
) |
Force a data cache writeback over a memory region.
Use this to force cached memory to be written to RDRAM.
[in] | addr | Pointer to memory in question |
[in] | length | Length in bytes of the data pointed at by addr |
void data_cache_hit_writeback_invalidate | ( | volatile void * | addr, | |
unsigned long | length | |||
) |
Force a data cache writeback invalidate over a memory region.
Use this to force cached memory to be written to RDRAM and then cache updated.
[in] | addr | Pointer to memory in question |
[in] | length | Length in bytes of the data pointed at by addr |
void data_cache_index_writeback_invalidate | ( | volatile void * | addr, | |
unsigned long | length | |||
) |
Force a data cache index writeback invalidate over a memory region.
[in] | addr | Pointer to memory in question |
[in] | length | Length in bytes of the data pointed at by addr |
volatile unsigned long get_ticks | ( | void | ) |
Read the number of ticks since system startup.
volatile unsigned long get_ticks_ms | ( | void | ) |
Read the number of millisecounds since system startup.
void inst_cache_hit_invalidate | ( | volatile void * | addr, | |
unsigned long | length | |||
) |
Force an instruction cache invalidate over a memory region.
Use this to force the N64 to update cache from RDRAM.
[in] | addr | Pointer to memory in question |
[in] | length | Length in bytes of the data pointed at by addr |
void inst_cache_hit_writeback | ( | volatile void * | addr, | |
unsigned long | length | |||
) |
Force an instruction cache writeback over a memory region.
Use this to force cached memory to be written to RDRAM.
[in] | addr | Pointer to memory in question |
[in] | length | Length in bytes of the data pointed at by addr |
void inst_cache_index_invalidate | ( | volatile void * | addr, | |
unsigned long | length | |||
) |
Force an instruction cache index invalidate over a memory region.
[in] | addr | Pointer to memory in question |
[in] | length | Length in bytes of the data pointed at by addr |
int sys_get_boot_cic | ( | ) |
Return the boot CIC.
void sys_set_boot_cic | ( | int | bc | ) |
Set the boot CIC.
This function will set the boot CIC. If the value isn't in the range of 6102-6106, the boot CIC is set to the default of 6102.
[in] | bc | Boot CIC value |
void wait_ms | ( | unsigned long | wait | ) |
Spin wait until the number of millisecounds have elapsed.
[in] | wait | Number of millisecounds to wait |
void wait_ticks | ( | unsigned long | wait | ) |
Spin wait until the number of ticks have elapsed.
[in] | wait | Number of ticks to wait |
int __bootcic = 6102 |
Boot CIC.
Defaults to 6102.