Skip to content

Commit

Permalink
<RP2040> Add arch & plat support
Browse files Browse the repository at this point in the history
Issue: #87
  • Loading branch information
akashkollipara committed Nov 22, 2023
1 parent c20e044 commit 93ace41
Show file tree
Hide file tree
Showing 33 changed files with 405 additions and 237 deletions.
7 changes: 4 additions & 3 deletions mk/tc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

include mk/path.mk

ifeq ($(findstring arm-v7,$(ARCH)),arm)
ifeq ($(findstring arm,$(ARCH)),arm)
TC ?= $(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi
TI := $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/include
TL := $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/lib
TI := $(TOOLS_ROOT)/arm-toolchain/lib/gcc/arm-none-eabi/$(TC_VER)/include-fixed/
TI += $(TOOLS_ROOT)/arm-toolchain/arm-none-eabi/include/
TL := $(TOOLS_ROOT)/arm-toolchain/lib/gcc/arm-none-eabi/$(TC_VER)/$(TL_TYPE)/
endif

ifeq ($(findstring riscv,$(ARCH)),riscv)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
#include <assert.h>
#include <status.h>
#include <syslog.h>
#include <plat_arch.h>
#include <mmio.h>
#include <arch.h>
#include <terravisor/workers.h>

static void arch_mcall_handler()
static void arch_ecall_handler()
{
context_frame_t *frame = get_context_frame();
mret_t mres;
Expand Down Expand Up @@ -71,17 +70,6 @@ _WEAK unsigned int arch_core_index()
return 0;
}

/**
* arch_wfi - wait for interrupt
*
* @brief This function should be called when the program needs to
* wait for interrupt. This also ensures low power consumption when compared to busy wait.
*/
void arch_wfi()
{
asm volatile("wfi");
}

void _NORETURN arch_panic_handler_callback()
{
context_frame_t *frame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
*/

#include <status.h>
#include <stdint.h>

extern uint8_t _start_start;
extern void _stack_start();
extern void init(void);
#define proto_irq_func(x) extern void int_##x(void)
proto_irq_func(1);
Expand All @@ -37,8 +38,8 @@ proto_irq_func(14);
* deref based on irq id and call respective handler.
*/

const void (*arch_vectors[N_IRQ+1](void)) _SECTION(".archvectors") =
[
void (*arch_vectors[N_IRQ+1])(void) _SECTION(".archvectors") =
{
&_stack_start, // Stack start value has higher address of stack
// with as assumption that stack grows towards
// lower address
Expand All @@ -58,4 +59,4 @@ const void (*arch_vectors[N_IRQ+1](void)) _SECTION(".archvectors") =
&int_12, // IRQ 12 -> N/A
&int_13, // IRQ 13 -> PendSV
&int_14, // IRQ 14 -> SysTick
];
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*
/*
* CYANCORE LICENSE
* Copyrights (C) 2022, Cyancore Team
* Copyrights (C) 2022-2023, Cyancore Team
*
* File Name : asm.S
* Description : This file consists of all the function written in asm
Expand All @@ -10,47 +10,15 @@
*/

#include <asm.inc>
#include <plat_arch.h>

/**
* PROLOGUE - A macro that defines context save operation. Saving only argument registers (r0 - r7)
**/

.macro PROLOGUE
push r0
push r1
MRS r1, APSR
push r1
push r2
push r3
push r4
push r5
push r6
push r7
.endm

/**
* EPILOGUE - A macro that defines context restore operation
**/
.altmacro
.macro INT id

.macro EPILOGUE
pop r7
pop r6
pop r5
pop r4
pop r3
pop r2
pop r1
MSR APSR, r1
pop r1
pop r0
.endm


function int_ /id
push r0
mov r0, #/id
function int_\id
push {r0}
mov r0, #\id
b isr
.endm

/**
* isr - interrupt service routine function
Expand All @@ -59,23 +27,27 @@ function int_ /id
* calling the interrupt handler function.
*/

.weak isr
function isr
PROLOGUE
MRS r1, MPS
add r1, #1
push {r1-r7, lr}
mrs r1, msp
bl exception_handler
EPILOGUE
pop r0
pop {r1-r7}
pop {r0}
mov lr, r0
pop {r0}
mov pc, lr

/**
* Interrupt Router Declaration Table
* 1-15 Interrupt routers are define as of now. If possible more can
* 1-14 Interrupt routers are define as of now. If possible more can
* be added. But during compile time only necessary interrupt router
* functions will be retained and others are cleaned up.
*/
/*==========< Interrupt router functions >==========*/
.set i, 1
.rept 15
.rept 14
INT %i
.set i, i+1
.endr

16 changes: 16 additions & 0 deletions src/arch/arm-m/32/common_v6_v7/supervisor/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : build.mk
# Description : Build script for this directory.
# Primary Authod : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

ARM32_M_S_ARCH_DIR := $(GET_PATH)

$(eval $(call add_include,$(ARM32_M_S_ARCH_DIR)/include/))

DIR := $(ARM32_M_S_ARCH_DIR)
include mk/obj.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
#pragma once
#define _ARCH_H_

#include <plat_arch.h>
#include <arm.h>
#include <mmio.h>
#include <resource.h>
#include <machine_call.h>

/**
Expand Down Expand Up @@ -47,34 +44,17 @@ void arch_panic_handler();
void arch_register_interrupt_handler(unsigned int, void(*)(void));

/**
* arch_core_index - Returns code index
*/
static inline unsigned int arch_core_index()
{
unsigned int id;
status_t status;
status = platform_sio_read(0x000 , &id);
if (status == success)
return id;
else
return 0;

}

unsigned int arch_core_index();

/**
* arch_machine_call - perform machine call
* @brief This function performs environment call
* arch_super_call - perform machine call
* @brief This function performs svc call
*
* @param[in] code: machine call code
* @param[in] code: universal call code
* @param[in] r0: first argument
* @param[in] r1: second argument
* @param[in] r2: third argument
* @param[in] *ret: return struct
*/

static inline void arch_machine_call(unsigned int code, unsigned int arg0, unsigned int arg1, unsigned int arg2, mret_t *ret)
#define arch_machine_call arch_super_call
static inline void arch_super_call(unsigned int code, unsigned int arg0, unsigned int arg1, unsigned int arg2, mret_t *ret)
{
if(ret == NULL)
return;
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions src/arch/arm-m/32/m0p/supervisor/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2023, Cyancore Team
#
# File Name : build.mk
# Description : Build script for this directory.
# Primary Authod : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

ARM32_M0P_T_ARCH_DIR := $(GET_PATH)

include $(ARM32_M0P_T_ARCH_DIR)/../../common_v6_v7/supervisor/build.mk

DIR := $(ARM32_M0P_T_ARCH_DIR)
include mk/obj.mk
File renamed without changes.
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions src/driver/console/con_serial_rpi/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
#
# File Name : build.mk
# Description : This file accumulates sources of console serial
# Primary Author : Akash Kollipara [[email protected]]
# Organisation : Cyancore Core-Team
#

DIR := $(GET_PATH)

EARLYCON_SERIAL ?= 0
CONSOLE_SERIAL ?= 0

$(eval $(call add_define,EARLYCON_SERIAL))
$(eval $(call add_define,CONSOLE_SERIAL))

ifeq ($(filter $(CONSOLE_SERIAL) $(EARLYCON_SERIAL),1),1)
include mk/obj.mk
endif
113 changes: 0 additions & 113 deletions src/platform/pico/common/sections.ld.sx

This file was deleted.

Loading

0 comments on commit 93ace41

Please sign in to comment.