16#ifndef _PICO_PLATFORM_H
17#define _PICO_PLATFORM_H
20#error pico/platform.h should not be included directly; include pico.h instead
23#include "pico/platform/compiler.h"
24#include "pico/platform/sections.h"
25#include "pico/platform/panic.h"
26#include "hardware/regs/addressmap.h"
27#include "hardware/regs/sio.h"
29#include "hardware/regs/rvcsr.h"
35#ifndef PICO_STACK_SIZE
36#define PICO_STACK_SIZE _u(0x800)
41#define PICO_HEAP_SIZE _u(0x800)
45#ifndef PICO_NO_RAM_VECTOR_TABLE
46#define PICO_NO_RAM_VECTOR_TABLE 0
49#ifndef PICO_RAM_VECTOR_TABLE_SIZE
50#define PICO_RAM_VECTOR_TABLE_SIZE (VTABLE_FIRST_IRQ + NUM_IRQS)
54#ifndef PICO_USE_STACK_GUARDS
55#define PICO_USE_STACK_GUARDS 0
84 pico_default_asm_volatile (
98 :
"+r" (minimum_cycles) : :
"cc",
"memory"
103#ifndef PICO_NO_FPGA_CHECK
105#define PICO_NO_FPGA_CHECK 1
110#ifndef PICO_NO_SIM_CHECK
111#define PICO_NO_SIM_CHECK 1
114#if PICO_NO_FPGA_CHECK
115static inline bool running_on_fpga(
void) {
return false;}
117bool running_on_fpga(
void);
120static inline bool running_in_sim(
void) {
return false;}
122bool running_in_sim(
void);
132 pico_default_asm_volatile (
"bkpt #0" : : :
"memory");
142 return (*(uint32_t *) (SIO_BASE + SIO_CPUID_OFFSET));
161 pico_default_asm_volatile (
163 :
"=r" (meicontext) :
"i" (RVCSR_MEICONTEXT_OFFSET)
165 if (meicontext & RVCSR_MEICONTEXT_NOIRQ_BITS) {
168 return VTABLE_FIRST_IRQ + (
169 (meicontext & RVCSR_MEICONTEXT_IRQ_BITS) >> RVCSR_MEICONTEXT_IRQ_LSB
174 pico_default_asm_volatile (
194 pico_default_asm_volatile (
199 return !(tt & (1u << 22));
209#define host_safe_hw_ptr(x) ((uintptr_t)(x))
210#define native_safe_hw_ptr(x) host_safe_hw_ptr(x)
231 GCC_Pragma(
"GCC diagnostic push")
232 GCC_Pragma(
"GCC diagnostic ignored \"-Warray-bounds\"")
233 return *(uint8_t*)0x13;
234 GCC_Pragma(
"GCC diagnostic pop")
249 __asm (
"mul %0, %0, %1" :
"+l" (a) :
"l" (b) : );
251 pico_default_asm (
"muls %0, %1" :
"+l" (a) :
"l" (b) :
"cc");
269#define __fast_mul(a, b) __builtin_choose_expr(__builtin_constant_p(b) && !__builtin_constant_p(a), \
270 (__builtin_popcount(b) >= 2 ? __mul_instruction(a,b) : (a)*(b)), \