24#define SYSTEM_BUS_CLOCK_HZ 243000000
31#define SYSTEM_CORE_CLOCK_HZ 729000000
39 #define SYSTEM_TB_CLOCK_HZ (SYSTEM_BUS_CLOCK_HZ / 4)
46#define SYSTEM_US_TO_TICKS(us) (SYSTEM_TB_CLOCK_HZ / 1000000 * (us))
53#define SYSTEM_MS_TO_TICKS(ms) (SYSTEM_TB_CLOCK_HZ / 1000 * (ms))
60#define SYSTEM_S_TO_TICKS(s) (SYSTEM_TB_CLOCK_HZ * (s))
68#define SYSTEM_MEM_UNCACHED(address) (((uint32_t)(address) & 0x1FFFFFFF) | 0xC0000000)
76#define SYSTEM_MEM_CACHED(address) (((uint32_t)(address) & 0x1FFFFFFF) | 0x80000000)
84#define SYSTEM_MEM_PHYSICAL(address) ((uint32_t)(address) & 0x1FFFFFFF)
91 const char* command_line;
92 int command_line_length;
105#define PACKED __attribute__((packed))
112#define MEM2 __attribute__((section(".mem2")))
121#define SYSTEM_MAIN_STACK_SIZE (1024*1024*4)
128#define SYSTEM_GET_MSR(msr) \
129 __asm__ __volatile__( \
130 "mfmsr %0" : "=r"(msr) \
138#define SYSTEM_SET_MSR(msr) \
139 __asm__ __volatile__( \
140 "mtmsr %0" : : "r"(msr) \
149#define SYSTEM_GET_DEC(msr) \
150 __asm__ __volatile__( \
151 "mfdec %0" : "=r"(msr) \
160#define SYSTEM_SET_DEC(msr) \
161 __asm__ __volatile__( \
162 "mtdec %0" : : "r"(msr) \
170#define SYSTEM_DISABLE_ISR(ee_enabled) \
173 SYSTEM_GET_MSR(msr); \
174 ee_enabled = (msr >> 15) & 1; \
176 SYSTEM_SET_MSR(msr); \
186#define SYSTEM_ENABLE_ISR(ee_enabled) \
189 SYSTEM_GET_MSR(msr); \
191 SYSTEM_SET_MSR(msr); \
199#define SYSTEM_SYNC() \
200 __asm__ __volatile__( \
209#define SYSTEM_ISYNC() \
210 __asm__ __volatile__( \
221 SYSCALL_ASSERT("ASSERTION FAILED", __LINE__, __FILE__); \
233#define ASSERT_OUT_OF_MEMORY(x) \
235 SYSCALL_ASSERT("OUT OF MEMORY", __LINE__, __FILE__); \
243#define ALIGN(x) __attribute__((aligned(x)))
251#define SYSTEM_SWITCH_SP(x) \
252 __asm__ __volatile__ ( \
253 "lis r3, pxCurrentTCB@ha\n\t" \
254 "lwz r4, pxCurrentTCB@l(r3)\n\t" \
256 "stw r5, 0(r4)\n\t" \
259 "bl vTaskSwitchContext\n\t" \
261 "lis r3, pxCurrentTCB@ha\n\t" \
262 "lwz r4, pxCurrentTCB@l(r3)\n\t" \
263 "lwz r1, 0(r4)\n\t" \
Command line arguments passed to us from launcher.
Definition system.h:89
Handle syscall exceptions.
void system_initialize()
Initializes the system.
Definition system.c:56
void system_invalidate_icache(void *data, uint32_t size)
Invalidates the instruction cache in a range.
uint64_t system_get_time_base_int()
Gets the time base register of the CPU.
void * system_aligned_malloc(uint32_t bytes, uint32_t alignment)
Allocate memory with alignment.
Definition system.c:35
void system_aligned_free(void *ptr)
Free allocated memory with alignment.
Definition system.c:50
void system_get_boot_path(const char *device, char *buffer, size_t length)
Looks in the argv command line for a specific boot path.
Definition system.c:87
void system_invalidate_dcache(void *data, uint32_t size)
Invalidates data cache in a range.
void system_delay_int(uint64_t ticks)
Sleeps for a certain number of ticks.
Definition system.c:29
void system_flush_dcache(const void *data, uint32_t size)
Flushes data cache in a range.