Skip to content

Commit

Permalink
add sparcv8leon3-generic target
Browse files Browse the repository at this point in the history
JIRA: RTOS-887
  • Loading branch information
lukileczo committed Aug 26, 2024
1 parent 06da962 commit 8242f70
Show file tree
Hide file tree
Showing 10 changed files with 502 additions and 7 deletions.
2 changes: 2 additions & 0 deletions hal/sparcv8leon3/gaisler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ 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)
else ifeq ($(TARGET_SUBFAMILY), generic)
OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/gaisler/, irqmp.o)
endif
15 changes: 15 additions & 0 deletions hal/sparcv8leon3/gaisler/generic/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Makefile for Phoenix-RTOS loader (SPARCV8 LEON3 Generic HAL)
#
# Copyright 2024 Phoenix Systems
#
# %LICENSE%
#

CFLAGS += -DVADDR_KERNEL_INIT=$(VADDR_KERNEL_INIT)

PLO_COMMANDS ?= alias app blob call console copy dump echo go help jffs2 kernel map mem phfs reboot script stop wait test-dev

PLO_ALLDEVICES := uart-grlib ram-storage

OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/gaisler/$(TARGET_SUBFAMILY)/, _init.o hal.o generic.o)
80 changes: 80 additions & 0 deletions hal/sparcv8leon3/gaisler/generic/_init.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Phoenix-RTOS
*
* Operating system loader
*
* Low level initialization
*
* Copyright 2024 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#define __ASSEMBLY__

#include "config.h"
#include "../../cpu.h"


.extern syspage_common


.section ".init", "ax"
.align 4
.global _init
.type _init, #function
_init:
wr %g0, %wim
nop
nop
nop

wr %g0, PSR_S, %psr

/* Get CPU ID */
rd %asr17, %g1
srl %g1, 28, %g1
cmp %g1, %g0
bnz jmp_core
nop

/* Set up trap table */
sethi %hi(_trap_table), %g1
wr %g1, %tbr

wr %g0, 0x2, %wim

flush
set 0x81000f, %g1
sta %g1, [%g0] ASI_CCTRL

clr %fp

/* Stack pointer */
set _stack, %sp
sub %sp, 0x60, %sp

/* Set PSR to supervisor, enable traps, disable irq */
wr %g0, (PSR_ET | PSR_S | PSR_PIL), %psr
nop
nop
nop

wr %g0, 0x2, %wim

sethi %hi(_startc), %g1
jmpl %g1 + %lo(_startc), %g0
clr %g1

jmp_core:
set syspage_common, %g1
ld [%g1], %g1 /* syspage_common->syspage */
ld [%g1 + 8], %g1 /* syspage->pkernel */

/* Jump to kernel */
jmp %g1
nop
.size _init, . - _init
42 changes: 42 additions & 0 deletions hal/sparcv8leon3/gaisler/generic/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Phoenix-RTOS
*
* Operating system loader
*
* Platform configuration
*
* Copyright 2024 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _CONFIG_H_
#define _CONFIG_H_


#ifndef __ASSEMBLY__

#include "generic.h"
#include "peripherals.h"
#include "hal/sparcv8leon3/gaisler/gaisler.h"
#include "hal/sparcv8leon3/gaisler/types.h"
#include "hal/sparcv8leon3/cpu.h"

#include <phoenix/arch/sparcv8leon3/syspage.h>
#include <phoenix/syspage.h>

#define PATH_KERNEL "phoenix-sparcv8leon3-generic.elf"

#endif /* __ASSEMBLY__ */


#define NWINDOWS 8

/* Import platform specific definitions */
#include "ld/sparcv8leon3-generic.ldt"


#endif
25 changes: 25 additions & 0 deletions hal/sparcv8leon3/gaisler/generic/generic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Phoenix-RTOS
*
* Operating system loader
*
* LEON3 Generic specific functions
*
* Copyright 2024 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include "generic.h"
#include "hal/sparcv8leon3/gaisler/gaisler.h"


int gaisler_iomuxCfg(iomux_cfg_t *ioCfg)
{
(void)ioCfg;

return 0;
}
30 changes: 30 additions & 0 deletions hal/sparcv8leon3/gaisler/generic/generic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Phoenix-RTOS
*
* Operating system loader
*
* LEON3 Generic specific functions
*
* Copyright 2024 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _GENERIC_H_
#define _GENERIC_H_

#include "../types.h"


static inline void hal_cpuHalt(void)
{
/* clang-format off */
__asm__ volatile ("wr %g0, %asr19");
/* clang-format on */
}


#endif
Loading

0 comments on commit 8242f70

Please sign in to comment.