Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gr712rc port #300

Merged
merged 3 commits into from
Nov 15, 2023
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
9 changes: 0 additions & 9 deletions devices/ram-stm32/Makefile

This file was deleted.

9 changes: 9 additions & 0 deletions devices/ram-storage/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Makefile for ram-storage
#
# Copyright 2022 Phoenix Systems
#
# %LICENSE%
#

OBJS += $(addprefix $(PREFIX_O)devices/ram-storage/, ramdrv.o)
6 changes: 5 additions & 1 deletion devices/ram-stm32/ramdrv.c → devices/ram-storage/ramdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* plo - operating system loader
*
* STM32 RAM driver - based on the flash driver implementation
* RAM driver - based on the flash driver implementation
*
* Copyright 2020, 2022 Phoenix Systems
* Author: Aleksander Kaminski, Damian Loewnau
Expand Down Expand Up @@ -67,6 +67,10 @@ static ssize_t ramdrv_read(unsigned int minor, addr_t offs, void *buff, size_t l

static ssize_t ramdrv_write(unsigned int minor, addr_t offs, const void *buff, size_t len)
{
if (ramdrv_isValidMinor(minor) == 0) {
return -EINVAL;
}

/* Not supported. TODO? */
return -ENOSYS;
}
Expand Down
8 changes: 6 additions & 2 deletions devices/uart-grlib/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ static int uart_done(unsigned int minor)
*(uart->base + uart_scaler) = 0;
hal_cpuDataStoreBarrier();

#ifdef __CPU_GR716
_gr716_cguClkDisable(cgu_primary, cgudev_apbuart0 + minor);
#endif

hal_interruptsSet(uart->irq, NULL, NULL);

Expand Down Expand Up @@ -290,16 +292,18 @@ static int uart_init(unsigned int minor)

uart_done(minor);

#ifdef __CPU_GR716
_gr716_cguClkEnable(cgu_primary, cgudev_apbuart0 + minor);
#endif

cfg.opt = 0x1;
cfg.pullup = 0;
cfg.pulldn = 0;
cfg.pin = info[minor].txPin;
_gr716_iomuxCfg(&cfg);
gaisler_iomuxCfg(&cfg);

cfg.pin = info[minor].rxPin;
_gr716_iomuxCfg(&cfg);
gaisler_iomuxCfg(&cfg);

lib_cbufInit(&uart->cbuffRx, uart->dataRx, BUFFER_SIZE);

Expand Down
2 changes: 1 addition & 1 deletion hal/armv7m/stm32/l4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ PLO_COMMANDS := alias app bankswitch call console copy dump echo go help kerneli

include devices/uart-stm32l4x6/Makefile
include devices/flash-stm32/Makefile
include devices/ram-stm32/Makefile
include devices/ram-storage/Makefile

OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/stm32/l4/, _init.o stm32l4.o timer.o console.o)
6 changes: 2 additions & 4 deletions hal/sparcv8leon3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# %LICENSE%
#

include hal/sparcv8leon3/$(TARGET_SUBFAMILY)/Makefile
include hal/sparcv8leon3/gaisler/Makefile

CFLAGS += -Ihal/sparcv8leon3/$(TARGET_SUBFAMILY)

OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/, cpu.o string.o interrupts.o exceptions.o _init.o _interrupts.o _traps.o)
OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/, string.o interrupts.o exceptions.o _interrupts.o _traps.o)
11 changes: 11 additions & 0 deletions hal/sparcv8leon3/_interrupts.S
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <config.h>
#include "cpu.h"
#include "gaisler/grlib-tn-0018.h"

.section ".text"
.align 4
Expand Down Expand Up @@ -99,7 +100,11 @@ wovfl_done:
mov %l3, %o0

/* Disable traps, we can't let a trap use the free stack space */
#ifndef __CPU_GR712RC
pwr 0, %psr
#else
wr %l0, %psr
#endif
nop
nop
nop
Expand Down Expand Up @@ -163,11 +168,17 @@ cwp_done:
save

wufl_done:

TN_0018_WAIT_ICACHE(%l3, %l4)

/* restore %psr */
wr %l0, %psr
nop
nop
nop

TN_0018_FIX(%l3, %l4)

jmp %l1
rett %l2

Expand Down
37 changes: 35 additions & 2 deletions hal/sparcv8leon3/_traps.S
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <config.h>
#include "cpu.h"
#include "gaisler/grlib-tn-0018.h"


#define BAD_TRAP \
Expand Down Expand Up @@ -118,7 +119,11 @@ _start:
BAD_TRAP
BAD_TRAP
BAD_TRAP /* 0x2a - division by zero */
BAD_TRAP /* 0x2b - data store error */
#ifdef __CPU_GR716
BAD_TRAP
#else
TRAP(_traps_stErrHandler) /* 0x2b - data store error */
#endif
BAD_TRAP
BAD_TRAP
BAD_TRAP
Expand Down Expand Up @@ -156,6 +161,32 @@ _start:
.section ".text"
.align 4

#ifndef __CPU_GR716

/* Data store error handler */

.type _traps_stErrHandler, #function
_traps_stErrHandler:
sta %g0, [%g0] ASI_CCTRL

TN_0018_WAIT_ICACHE(%l3, %l4)

/* restore %psr */
wr %l0, %psr
nop
nop
nop

TN_0018_FIX(%l3, %l4)

jmp %l1
rett %l2
.size _traps_stErrHandler, . - _traps_stErrHandler

#endif

/* Underflow/overflow traps never return directly to 'jmpl' instruction - no TN-0018 fix needed */

/* Window underflow handler
* on entry:
* %psr in %l0, PC in %l1, nPC in %l2
Expand Down Expand Up @@ -236,6 +267,7 @@ _traps_setPil:
nop
nop
nop
/* TN-0018 fix done after 'ta' instruction */
jmp %l2
rett %l2 + 4
.size _traps_setPil, . - _traps_setPil
Expand Down Expand Up @@ -307,7 +339,8 @@ _exceptions_dispatch:
nop

/* trap type */
and %g1, TBR_TT_MSK, %o0
set TBR_TT_MSK, %g2
and %g1, %g2, %o0
srl %o0, TBR_TT_SHIFT, %o0

/* void exceptions_dispatch(unsigned int n, exc_context_t *ctx) */
Expand Down
40 changes: 0 additions & 40 deletions hal/sparcv8leon3/cpu.c

This file was deleted.

13 changes: 6 additions & 7 deletions hal/sparcv8leon3/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@
#include <peripherals.h>


static inline void hal_cpuHalt(void)
{
/* must be performed in supervisor mode with int enabled */
__asm__ volatile("wr %g0, %asr19");
}


static inline void hal_cpuDataStoreBarrier(void)
{
__asm__ volatile("stbar");
Expand All @@ -72,6 +65,12 @@ static inline void hal_cpuInstrBarrier(void)
}


void hal_cpuFlushDCache(void);


void hal_cpuFlushICache(void);


#endif /* __ASSEMBLY__ */


Expand Down
19 changes: 19 additions & 0 deletions hal/sparcv8leon3/gaisler/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Makefile for Phoenix-RTOS loader (SPARCV8 LEON3 HAL)
#
# Copyright 2023 Phoenix Systems
#
# %LICENSE%
#

CFLAGS += -Ihal/sparcv8leon3/gaisler/ -Ihal/sparcv8leon3/gaisler/$(TARGET_SUBFAMILY)

include hal/sparcv8leon3/gaisler/$(TARGET_SUBFAMILY)/Makefile

OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/gaisler/, console.o timer.o)

ifeq ($(TARGET_SUBFAMILY), gr712rc)
OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/gaisler/, irqmp.o)
else ifeq ($(TARGET_SUBFAMILY), gr716)
OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/gaisler/, irqamp.o)
endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
*/

#include <hal/hal.h>
#include <devices/gpio-gr716/gpio.h>


/* UART control bits */
#define TX_EN (1 << 1)
#define TX_FIFO_FULL (1 << 9)

#define CONCAT_(a, b) a##b
#define CONCAT(a, b) CONCAT_(a, b)

/* Console config */
#define UART_CONSOLE_RX UART2_RX
#define UART_CONSOLE_TX UART2_TX
#define UART_CONSOLE_BASE UART2_BASE
#define UART_CONSOLE_CGU cgudev_apbuart2
#define UART_CONSOLE_RX CONCAT(UART, CONCAT(UART_CONSOLE_PLO, _RX))
#define UART_CONSOLE_TX CONCAT(UART, CONCAT(UART_CONSOLE_PLO, _TX))
#define UART_CONSOLE_BASE CONCAT(UART, CONCAT(UART_CONSOLE_PLO, _BASE))
#define UART_CONSOLE_CGU CONCAT(cgudev_apbuart, UART_CONSOLE_PLO)


enum {
Expand Down Expand Up @@ -68,12 +69,15 @@ void console_init(void)
cfg.pullup = 0;
cfg.pulldn = 0;
cfg.pin = UART_CONSOLE_TX;
_gr716_iomuxCfg(&cfg);
gaisler_iomuxCfg(&cfg);

cfg.pin = UART_CONSOLE_RX;
_gr716_iomuxCfg(&cfg);
gaisler_iomuxCfg(&cfg);

#ifdef __CPU_GR716
_gr716_cguClkEnable(cgu_primary, UART_CONSOLE_CGU);
#endif

halconsole_common.uart = UART_CONSOLE_BASE;
*(halconsole_common.uart + uart_ctrl) = TX_EN;
*(halconsole_common.uart + uart_scaler) = console_calcScaler(UART_BAUDRATE);
Expand Down
34 changes: 34 additions & 0 deletions hal/sparcv8leon3/gaisler/gaisler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Phoenix-RTOS
*
* Operating system loader
*
* Gaisler CPU specific functions
*
* Copyright 2023 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _GAISLER_H_
#define _GAISLER_H_


#include "types.h"


typedef struct {
u8 pin;
u8 opt;
u8 pullup;
u8 pulldn;
} iomux_cfg_t;


int gaisler_iomuxCfg(iomux_cfg_t *ioCfg);


#endif
16 changes: 16 additions & 0 deletions hal/sparcv8leon3/gaisler/gr712rc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Makefile for Phoenix-RTOS loader (SPARCV8 LEON3 GR712RC HAL)
#
# Copyright 2023 Phoenix Systems
#
# %LICENSE%
#

CFLAGS += -DVADDR_KERNEL_INIT=$(VADDR_KERNEL_INIT)

PLO_COMMANDS := alias app call console copy dump echo go help kernel map mem phfs reboot script wait

include devices/uart-grlib/Makefile
include devices/ram-storage/Makefile

OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/gaisler/$(TARGET_SUBFAMILY)/, _init.o hal.o gr712rc.o)
Loading
Loading