Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codespell_ignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ hart
SME
spOffs
DED
inout
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ on:
push:
branches:
- master
- 'feature/*'
- 'bpaczek/*'
pull_request:
branches:
- master
- 'feature/*'
- 'bpaczek/*'


jobs:
call-ci:
uses: phoenix-rtos/phoenix-rtos-project/.github/workflows/ci-submodule.yml@master
uses: bartekpaczek/phoenix-rtos-project-fork/.github/workflows/ci-submodule.yml@bpaczek/misra-ci
secrets: inherit
with:
build_params: all tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ CMakeLists.txt
.idea/
cmake-build-debug/
.vscode/*
.cpptest
10 changes: 5 additions & 5 deletions hal/aarch64/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
#include "hal/types.h"
#include "config.h"

#define SIZE_PAGE 0x1000uL
#define SIZE_PAGE 0x1000UL
#define SIZE_PDIR SIZE_PAGE

#define SIZE_INITIAL_KSTACK (2 * SIZE_PAGE) /* Must be multiple of page size */
#define SIZE_INITIAL_KSTACK (2U * SIZE_PAGE) /* Must be multiple of page size */

#ifndef SIZE_KSTACK
#define SIZE_KSTACK (2 * SIZE_PAGE)
#define SIZE_KSTACK (2U * SIZE_PAGE)
#endif

#ifndef SIZE_USTACK
#define SIZE_USTACK (8 * SIZE_PAGE)
#define SIZE_USTACK (8U * SIZE_PAGE)
#endif

#define MODE_nAARCH64 0x10
Expand Down Expand Up @@ -215,7 +215,7 @@ static inline void hal_cpuAtomicInc(volatile u32 *dst)
}


extern unsigned int hal_cpuGetCount(void);
unsigned int hal_cpuGetCount(void);


#endif
Expand Down
2 changes: 1 addition & 1 deletion hal/aarch64/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define CONST_STR_SIZE(x) x, (sizeof(x) - 1)

/* Function creates new cpu context on top of given thread kernel stack */
int hal_cpuCreateContext(cpu_context_t **nctx, void *start, void *kstack, size_t kstacksz, void *ustack, void *arg, hal_tls_t *tls)
int hal_cpuCreateContext(cpu_context_t **nctx, void (*start)(void *harg), void *kstack, size_t kstacksz, void *ustack, void *arg, hal_tls_t *tls)
{
cpu_context_t *ctx;
int i;
Expand Down
4 changes: 2 additions & 2 deletions hal/aarch64/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void exceptions_trampoline(unsigned int n, exc_context_t *ctx)
}


static const char *exceptionClassStr(int excClass)
static const char *exceptionClassStr(unsigned int excClass)
{
switch (excClass) {
case 0b000000:
Expand Down Expand Up @@ -127,7 +127,7 @@ static const char *exceptionClassStr(int excClass)
}


void hal_exceptionsDumpContext(char *buff, exc_context_t *ctx, int n)
void hal_exceptionsDumpContext(char *buff, exc_context_t *ctx, unsigned int n)
{
size_t i = 0, j;
const char *toAdd;
Expand Down
1 change: 0 additions & 1 deletion hal/aarch64/hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ u64 relOffs;
u32 schedulerLocked = 0;


extern void _hal_platformInit(void);
extern void _hal_cpuInit(void);


Expand Down
2 changes: 1 addition & 1 deletion hal/aarch64/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ char *hal_strncpy(char *dest, const char *src, size_t n)
}


unsigned long hal_i2s(const char *prefix, char *s, unsigned long i, unsigned char b, char zero)
unsigned long hal_i2s(const char *prefix, char *s, unsigned long i, u8 b, u8 zero)
{
static const char digits[] = "0123456789abcdef";
char c;
Expand Down
13 changes: 7 additions & 6 deletions hal/aarch64/zynqmp/zynqmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include "hal/cpu.h"
#include "hal/hal.h"
#include "hal/aarch64/aarch64.h"
#include "hal/aarch64/interrupts_gicv2.h"
#include "hal/spinlock.h"
Expand Down Expand Up @@ -136,7 +137,7 @@ int _zynqmp_getDevClock(int dev, char *src, char *div0, char *div1, char *active
}


static void _zynqmp_setMIOMuxing(unsigned pin, char l0, char l1, char l2, char l3)
static void _zynqmp_setMIOMuxing(unsigned pin, u8 l0, u8 l1, u8 l2, u8 l3)
{
u32 val = ((l0 & 0x1) << 1) | ((l1 & 0x1) << 2) | ((l2 & 0x3) << 3) | ((l3 & 0x7) << 5);
*(zynq_common.iou_slcr + iou_slcr_mio_pin_0 + pin) = (*(zynq_common.iou_slcr + iou_slcr_mio_pin_0 + pin) & ~0xff) | val;
Expand Down Expand Up @@ -180,7 +181,7 @@ static void _zynqmp_setMIOControl(unsigned pin, char config)
}


int _zynqmp_setMIO(unsigned pin, char l0, char l1, char l2, char l3, char config)
int _zynqmp_setMIO(unsigned pin, u8 l0, u8 l1, u8 l2, u8 l3, u8 config)
{
if (pin > 77) {
return -1;
Expand All @@ -194,7 +195,7 @@ int _zynqmp_setMIO(unsigned pin, char l0, char l1, char l2, char l3, char config
}


static void _zynqmp_getMIOMuxing(unsigned pin, char *l0, char *l1, char *l2, char *l3)
static void _zynqmp_getMIOMuxing(unsigned pin, u8 *l0, u8 *l1, u8 *l2, u8 *l3)
{
u32 val = *(zynq_common.iou_slcr + iou_slcr_mio_pin_0 + pin) & 0xff;
*l0 = (val >> 1) & 0x1;
Expand All @@ -204,7 +205,7 @@ static void _zynqmp_getMIOMuxing(unsigned pin, char *l0, char *l1, char *l2, cha
}


static void _zynqmp_getMIOTristate(unsigned pin, char *config)
static void _zynqmp_getMIOTristate(unsigned pin, u8 *config)
{
u32 reg = pin / 32 + iou_slcr_mio_mst_tri0;
u32 bit = pin % 32;
Expand All @@ -213,7 +214,7 @@ static void _zynqmp_getMIOTristate(unsigned pin, char *config)
}
}

static void _zynqmp_getMIOControl(unsigned pin, char *config)
static void _zynqmp_getMIOControl(unsigned pin, u8 *config)
{
u32 reg = (pin / 26) * (iou_slcr_bank1_ctrl0 - iou_slcr_bank0_ctrl0) + iou_slcr_bank0_ctrl0;
u32 bit = pin % 26;
Expand All @@ -233,7 +234,7 @@ static void _zynqmp_getMIOControl(unsigned pin, char *config)
}


static int _zynqmp_getMIO(unsigned pin, char *l0, char *l1, char *l2, char *l3, char *config)
static int _zynqmp_getMIO(unsigned pin, u8 *l0, u8 *l1, u8 *l2, u8 *l3, u8 *config)
{
if (pin > 77) {
return -1;
Expand Down
2 changes: 1 addition & 1 deletion hal/aarch64/zynqmp/zynqmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "include/arch/aarch64/zynqmp/zynqmp.h"


extern int _zynqmp_setMIO(unsigned pin, char l0, char l1, char l2, char l3, char config);
extern int _zynqmp_setMIO(unsigned pin, u8 l0, u8 l1, u8 l2, u8 l3, u8 config);


extern int _zynq_setDevRst(int dev, unsigned int state);
Expand Down
4 changes: 2 additions & 2 deletions hal/armv7a/_armv7a.S
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ _hal_cpuSetKernelStack:
.type hal_jmp, %function
hal_jmp:
cpsid if
/* ustack != NULL means that the jump is to user */
cmp r2, #NULL
/* ustack != 0 means that the jump is to user */
cmp r2, #0
bne 2f
/* kargs are passed on the stack */
ldr r5, [sp]
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7a/_interrupts.S
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ hal_cpuReschedule:

mrs r4, cpsr

cmp r0, #NULL
cmp r0, #0
beq 1f

add r0, #12
Expand Down
22 changes: 11 additions & 11 deletions hal/armv7a/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
#include "hal/types.h"
#include "config.h"

#define SIZE_PAGE 0x1000
#define SIZE_PDIR 0x2000
#define SIZE_PAGE 0x1000U
#define SIZE_PDIR 0x2000U

#ifndef SIZE_KSTACK
#define SIZE_KSTACK (8 * 1024)
#define SIZE_KSTACK (8U * 1024U)
#endif

#ifndef SIZE_USTACK
#define SIZE_USTACK (8 * SIZE_PAGE)
#define SIZE_USTACK (8U * SIZE_PAGE)
#endif

#define USR_MODE 0x10
Expand Down Expand Up @@ -93,19 +93,19 @@ typedef struct _cpu_context_t {

static inline void hal_cpuDisableInterrupts(void)
{
__asm__ volatile ("cpsid if");
__asm__ volatile("cpsid if");
}


static inline void hal_cpuEnableInterrupts(void)
{
__asm__ volatile ("cpsie aif");
__asm__ volatile("cpsie aif");
}


static inline void hal_cpuHalt(void)
{
__asm__ volatile ("wfi");
__asm__ volatile("wfi");
}


Expand All @@ -118,7 +118,7 @@ static inline unsigned int hal_cpuGetLastBit(unsigned long v)
{
int pos;

__asm__ volatile ("clz %0, %1" : "=r" (pos) : "r" (v));
__asm__ volatile("clz %0, %1" : "=r"(pos) : "r"(v));

return 31 - pos;
}
Expand All @@ -128,9 +128,9 @@ static inline unsigned int hal_cpuGetFirstBit(unsigned long v)
{
unsigned pos;

__asm__ volatile ("\
__asm__ volatile("\
rbit %0, %1; \
clz %0, %0;" : "=r" (pos) : "r" (v));
clz %0, %0;" : "=r"(pos) : "r"(v));

return pos;
}
Expand Down Expand Up @@ -244,7 +244,7 @@ static inline void hal_cpuAtomicInc(volatile u32 *dst)
}


extern unsigned int hal_cpuGetCount(void);
unsigned int hal_cpuGetCount(void);


#endif
Expand Down
30 changes: 15 additions & 15 deletions hal/armv7a/arch/pmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#include "hal/types.h"

/* Predefined virtual adresses */
#define VADDR_KERNEL 0xc0000000 /* base virtual address of kernel space */
#define VADDR_MIN 0x00000000
#define VADDR_MAX 0xffffffff
#define VADDR_USR_MAX 0x80000000
#define VADDR_KERNEL 0xc0000000 /* base virtual address of kernel space */
#define VADDR_MIN 0x00000000
#define VADDR_MAX 0xffffffff
#define VADDR_USR_MAX 0x80000000

/* (MOD) */
#define VADDR_SCRATCHPAD_TTL 0xfff00000
Expand All @@ -40,18 +40,18 @@


/* Page flags */
#define PAGE_FREE 0x00000001
#define PAGE_FREE 0x00000001

#define PAGE_OWNER_BOOT (0 << 1)
#define PAGE_OWNER_KERNEL (1 << 1)
#define PAGE_OWNER_APP (2 << 1)
#define PAGE_OWNER_BOOT (0 << 1)
#define PAGE_OWNER_KERNEL (1 << 1)
#define PAGE_OWNER_APP (2 << 1)

#define PAGE_KERNEL_SYSPAGE (1 << 4)
#define PAGE_KERNEL_CPU (2 << 4)
#define PAGE_KERNEL_PTABLE (3 << 4)
#define PAGE_KERNEL_PMAP (4 << 4)
#define PAGE_KERNEL_STACK (5 << 4)
#define PAGE_KERNEL_HEAP (6 << 4)
#define PAGE_KERNEL_SYSPAGE (1 << 4)
#define PAGE_KERNEL_CPU (2 << 4)
#define PAGE_KERNEL_PTABLE (3 << 4)
#define PAGE_KERNEL_PMAP (4 << 4)
#define PAGE_KERNEL_STACK (5 << 4)
#define PAGE_KERNEL_HEAP (6 << 4)

#ifndef __ASSEMBLY__

Expand All @@ -68,7 +68,7 @@ typedef struct _page_t {
typedef struct _pmap_t {
u8 asid_ix;
u32 *pdir;
addr_t addr; /* physical address of pdir */
addr_t addr; /* physical address of pdir */
void *start;
void *end;
void *pmapv;
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7a/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/* Function creates new cpu context on top of given thread kernel stack */
int hal_cpuCreateContext(cpu_context_t **nctx, void *start, void *kstack, size_t kstacksz, void *ustack, void *arg, hal_tls_t *tls)
int hal_cpuCreateContext(cpu_context_t **nctx, void (*start)(void *harg), void *kstack, size_t kstacksz, void *ustack, void *arg, hal_tls_t *tls)
{
cpu_context_t *ctx;
int i;
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7a/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct {
enum { exc_reset = 0, exc_undef, exc_svc, exc_prefetch, exc_abort };


void hal_exceptionsDumpContext(char *buff, exc_context_t *ctx, int n)
void hal_exceptionsDumpContext(char *buff, exc_context_t *ctx, unsigned int n)
{
static const char *const mnemonics[] = {
"0 #Reset", "1 #Undef", "2 #Syscall", "3 #Prefetch",
Expand Down
3 changes: 1 addition & 2 deletions hal/armv7a/hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ unsigned int relOffs;
u32 schedulerLocked = 0;


extern void _hal_platformInit(void);
extern void _hal_cpuInit(void);


Expand Down Expand Up @@ -81,7 +80,7 @@ void hal_lockScheduler(void)
}


__attribute__ ((section (".init"))) void _hal_init(void)
__attribute__((section(".init"))) void _hal_init(void)
{
schedulerLocked = 0;
_hal_spinlockInit();
Expand Down
4 changes: 2 additions & 2 deletions hal/armv7a/imx6ull/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#ifndef _HAL_CONFIG_H_
#define _HAL_CONFIG_H_

#define ADDR_DDR 0x80000000
#define SIZE_DDR 0x7ffffff
#define ADDR_DDR 0x80000000
#define SIZE_DDR 0x7ffffff

#define NUM_CPUS 1

Expand Down
2 changes: 1 addition & 1 deletion hal/armv7a/pmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ addr_t pmap_destroy(pmap_t *pmap, int *i)
hal_spinlockClear(&pmap_common.lock, &sc);

while (*i < max) {
if (pmap->pdir[*i] != NULL) {
if (pmap->pdir[*i] != 0) {
*i += 4;
return pmap->pdir[*i - 4] & ~0xfff;
}
Expand Down
2 changes: 1 addition & 1 deletion hal/armv7a/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ char *hal_strncpy(char *dest, const char *src, size_t n)
}


unsigned long hal_i2s(const char *prefix, char *s, unsigned long i, unsigned char b, char zero)
unsigned long hal_i2s(const char *prefix, char *s, unsigned long i, u8 b, u8 zero)
{
static const char digits[] = "0123456789abcdef";
char c;
Expand Down
Loading
Loading