Initial Release
This commit is contained in:
25
src/host/pico_platform/CMakeLists.txt
Normal file
25
src/host/pico_platform/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
if (NOT TARGET pico_platform_headers)
|
||||
add_library(pico_platform_headers INTERFACE)
|
||||
|
||||
target_compile_definitions(pico_platform_headers INTERFACE
|
||||
PICO_NO_HARDWARE=1
|
||||
PICO_ON_DEVICE=0
|
||||
PICO_BUILD=1
|
||||
)
|
||||
|
||||
target_include_directories(pico_platform_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET pico_platform)
|
||||
add_library(pico_platform INTERFACE)
|
||||
|
||||
target_sources(pico_platform INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/platform_base.c
|
||||
)
|
||||
|
||||
target_link_libraries(pico_platform INTERFACE pico_platform_headers pico_bit_ops ${PICO_PLATFORM_EXTRA_LIBRARIES})
|
||||
endif()
|
||||
|
||||
function(pico_add_platform_library TARGET)
|
||||
target_link_libraries(pico_platform INTERFACE ${TARGET})
|
||||
endfunction()
|
24
src/host/pico_platform/include/hardware/platform_defs.h
Normal file
24
src/host/pico_platform/include/hardware/platform_defs.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _HARDWARE_PLATFORM_DEFS_H
|
||||
#define _HARDWARE_PLATFORM_DEFS_H
|
||||
|
||||
#define NUM_CORES 2u
|
||||
|
||||
#define NUM_DMA_CHANNELS 12u
|
||||
|
||||
#define NUM_TIMERS 4u
|
||||
|
||||
#define NUM_IRQS 32u
|
||||
|
||||
#define NUM_SPIN_LOCKS 32u
|
||||
|
||||
#define XOSC_MHZ 12
|
||||
|
||||
#define NUM_SPIN_LOCKS 32u
|
||||
|
||||
#endif
|
137
src/host/pico_platform/include/pico/platform.h
Normal file
137
src/host/pico_platform/include/pico/platform.h
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _PICO_PLATFORM_H_
|
||||
#define _PICO_PLATFORM_H_
|
||||
|
||||
#include "hardware/platform_defs.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __unix__
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define __not_in_flash(grup)
|
||||
#define __not_in_flash_func(func) func
|
||||
#define __no_inline_not_in_flash_func(func)
|
||||
#define __in_flash(group)
|
||||
#define __scratch_x(group)
|
||||
#define __scratch_y(group)
|
||||
|
||||
#define __packed_aligned
|
||||
#define __packed
|
||||
|
||||
#define __time_critical_func(x) x
|
||||
#define __after_data(group)
|
||||
|
||||
//int running_on_fpga() { return false; }
|
||||
extern void tight_loop_contents();
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#ifndef __noreturn
|
||||
#define __noreturn __attribute((noreturn))
|
||||
#endif
|
||||
|
||||
#ifndef __unused
|
||||
#define __unused __attribute__((unused))
|
||||
#endif
|
||||
|
||||
#ifndef __noinline
|
||||
#define __noinline __attribute__((noinline))
|
||||
#endif
|
||||
|
||||
#ifndef __aligned
|
||||
#define __aligned(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
|
||||
#define PICO_WEAK_FUNCTION_DEF(x) _Pragma(__STRING(weak x))
|
||||
#define PICO_WEAK_FUNCTION_IMPL_NAME(x) x
|
||||
|
||||
#else
|
||||
#ifndef __noreturn
|
||||
#define __noreturn __declspec(noreturn)
|
||||
#endif
|
||||
|
||||
#ifndef __unused
|
||||
#define __unused
|
||||
#endif
|
||||
|
||||
#ifndef __noinline
|
||||
#define __noinline __declspec(noinline)
|
||||
#endif
|
||||
|
||||
#ifndef __aligned
|
||||
#define __aligned(x) __declspec(align(x))
|
||||
#endif
|
||||
|
||||
#ifndef __CONCAT
|
||||
#define __CONCAT(x,y) x ## y
|
||||
#endif
|
||||
|
||||
#ifndef __STRING
|
||||
#define __STRING(x) #x
|
||||
#endif()
|
||||
|
||||
#define __thread __declspec( thread )
|
||||
|
||||
#define PICO_WEAK_FUNCTION_DEF(x) __pragma(comment(linker, __STRING(/alternatename:_##x=_##x##__weak)));
|
||||
#define PICO_WEAK_FUNCTION_IMPL_NAME(x) x ## __weak
|
||||
|
||||
static __noreturn void __builtin_unreachable() {
|
||||
}
|
||||
|
||||
#include <intrin.h>
|
||||
#define __builtin_clz __lzcnt
|
||||
#endif
|
||||
|
||||
#ifndef count_of
|
||||
#define count_of(a) (sizeof(a)/sizeof((a)[0]))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a)>(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((b)>(a)?(a):(b))
|
||||
#endif
|
||||
|
||||
// abort in our case
|
||||
void __noreturn __breakpoint();
|
||||
|
||||
void __noreturn panic_unsupported();
|
||||
|
||||
void __noreturn panic(const char *fmt, ...);
|
||||
|
||||
// arggggghhhh there is a weak function called sem_init used by SDL
|
||||
#define sem_init sem_init_alternative
|
||||
|
||||
extern uint32_t host_safe_hw_ptr_impl(uintptr_t x);
|
||||
// return a 32 bit handle for a raw ptr; DMA chaining for example embeds pointers in 32 bit values
|
||||
// which of course does not work if we're running the code natively on a 64 bit platforms. Therefore
|
||||
// we provide this macro which allows that code to provide a 64->32 bit mapping in host mode
|
||||
#define host_safe_hw_ptr(x) host_safe_hw_ptr_impl((uintptr_t)(x))
|
||||
void *decode_host_safe_hw_ptr(uint32_t ptr);
|
||||
|
||||
#define __fast_mul(a,b) ((a)*(b))
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
inline static int32_t __mul_instruction(int32_t a,int32_t b)
|
||||
{
|
||||
return a*b;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
46
src/host/pico_platform/platform_base.c
Normal file
46
src/host/pico_platform/platform_base.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pico.h"
|
||||
|
||||
PICO_WEAK_FUNCTION_DEF(tight_loop_contents)
|
||||
|
||||
void PICO_WEAK_FUNCTION_IMPL_NAME(tight_loop_contents)() {
|
||||
|
||||
}
|
||||
|
||||
void __noreturn panic_unsupported() {
|
||||
panic("not supported");
|
||||
}
|
||||
|
||||
void hard_assertion_failure(void) {
|
||||
panic("Hard assert");
|
||||
}
|
||||
|
||||
void panic(const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
puts("*** PANIC ***\n");
|
||||
if (fmt) {
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
puts("\n");
|
||||
|
||||
__breakpoint();
|
||||
}
|
||||
|
||||
void __breakpoint() {
|
||||
#ifdef _MSC_VER
|
||||
__debugbreak();
|
||||
#else
|
||||
__builtin_trap();
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user