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

Xen support #2

Draft
wants to merge 4 commits into
base: k3_main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .project/cgt/cgt_gcc-aarch64.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const cgt_a53 ={
"-mstrict-align",
"-mfix-cortex-a53-835769",
"-mfix-cortex-a53-843419",
... common.isXenEnabled() ? [
"-DXEN_ENABLED"
] : []
],
},
}
Expand Down
15 changes: 15 additions & 0 deletions .project/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,27 @@ function setInstrumentationMode(mode)
genInstrumentationMode = mode;
}

/* xen is disabled by default */
let xenEnabled = false;

function isXenEnabled()
{
return xenEnabled;
}

function setXenEnabled(enabled)
{
xenEnabled = enabled;
}

module.exports = {
genBuildfiles,
isDevelopmentMode,
setGenBuildFilesMode,
isInstrumentationMode,
setInstrumentationMode,
isXenEnabled,
setXenEnabled,
cleanBuildfiles,
mergeCgtOptions,
convertTemplateToFile,
Expand Down
3 changes: 3 additions & 0 deletions .project/device/project_am62px.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const component_file_list = [
"source/safety_checkers/.project/project.js",
"docs_src/docs/api_guide/doxy_samples/.project/project.js",
"test/unity/.project/project.js",
... common.isXenEnabled() ? [
"source/drivers/xen/.project/project.js",
] : []
];

// List of components where makefile is not generated.
Expand Down
3 changes: 3 additions & 0 deletions .project/device/project_am62x.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const component_file_list = [
"source/safety_checkers/.project/project.js",
"test/unity/.project/project.js",
"docs_src/docs/api_guide/doxy_samples/.project/project.js",
... common.isXenEnabled() ? [
"source/drivers/xen/.project/project.js",
] : []
];

// List of components where makefile is not generated.
Expand Down
1 change: 1 addition & 0 deletions .project/genExampleFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function genExampleFilesDevice(device) {
project: project,
options: template.options,
isInstrumentation: isInstrumentation,
isXenEnabled: common.isXenEnabled,
};

common.convertTemplateToFile(
Expand Down
5 changes: 5 additions & 0 deletions .project/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const argv = yargs
default: "disable",
array: false
})
.option('enable-xen', {
description: 'L1 Hypervisor',
type: 'boolean',
})
.help()
.alias('help', 'h')
.argv;
Expand All @@ -41,6 +45,7 @@ if(argv.target == "clean") {
else {
common.setGenBuildFilesMode(argv.target);
common.setInstrumentationMode(argv.instrumentation);
common.setXenEnabled(!!argv.enableXen);
for(device of argv.device) {
console.log(`Generating build files for ${device} in ${argv.target} mode ...`);
common.genBuildfiles(device);
Expand Down
13 changes: 11 additions & 2 deletions .project/templates/am62x/common/linker_a53.cmd.xdt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
let addrBaseDdr = 0x80000000;
let codeDataSizeDdr = 0x1000000;

let shmOrigin = 0x82000000;
let scratchBufOrigin = 0x82000080;

if(args.isXenEnabled()) {
addrBaseDdr = 0x40000000;
shmOrigin = 0x42000000;
scratchBufOrigin = 0x42000080;
}

/* if no options given use defaults */
if(options && options.stackSize)
stackSize = options.stackSize;
Expand Down Expand Up @@ -90,7 +99,7 @@ MEMORY {
/* On A53,
* - make sure there is a MMU entry which maps below regions as non-cache
*/
USER_SHM_MEM : ORIGIN = 0x82000000, LENGTH = 0x80
USER_SHM_MEM : ORIGIN = 0x`(shmOrigin).toString(16).toUpperCase()`, LENGTH = 0x80
% if(args.project.isLogSHM === true){
LOG_SHM_MEM : ORIGIN = 0xA1000000, LENGTH = 0x40000
%}
Expand All @@ -99,7 +108,7 @@ MEMORY {
%}
% if(globalScratchBuf == "true") {
/* global scratch buffer region in DDR (32 MB) */
GLOBAL_SCRATCH_BUFF (RWIX): ORIGIN = 0x82000080 LENGTH = 0x02000000
GLOBAL_SCRATCH_BUFF (RWIX): ORIGIN = 0x`(scratchBufOrigin).toString(16).toUpperCase()` LENGTH = 0x02000000
% }
}

Expand Down
4 changes: 4 additions & 0 deletions .project/templates/am62x/nortos/main_nortos.c.xdt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ int main()
{
int32_t status = SystemP_SUCCESS;

% if(!args.isXenEnabled()) {
System_init();
% }
Board_init();

/* Open drivers */
Expand All @@ -67,7 +69,9 @@ int main()
Drivers_close();

Board_deinit();
% if(!args.isXenEnabled()) {
System_deinit();
% }

return 0;
}
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ docs-clean:
$(MAKE) -C docs_src/docs/api_guide clean DEVICE=$(DEVICE) DOC_COMBO=$(DOC_COMBO)

gen-buildfiles:
$(NODE) ./.project/project.js --device $(DEVICE) --target $(GEN_BUILDFILES_TARGET) --instrumentation $(INSTRUMENTATION_MODE)
$(NODE) ./.project/project.js --device $(DEVICE) --target $(GEN_BUILDFILES_TARGET) --instrumentation $(INSTRUMENTATION_MODE) $(if $(ENABLE_XEN),--enable-xen)

gen-buildfiles-clean:
$(NODE) ./.project/project.js --device $(DEVICE) --target clean
Expand Down
3 changes: 3 additions & 0 deletions source/drivers/.meta/system/system_config.c.xdt
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ void System_init(void)
`system.getTemplate(sciclientInitTemplate)()`
% }

#ifndef XEN_ENABLED
`system.getTemplate("/kernel/dpl/pmu_init.c.xdt")()`

PowerClock_init();
/* Now we can do pinmux */
Pinmux_init();
/* finally we initialize all peripheral drivers */
#endif

% let driverOrder = system.getScript('/common').getDriverOpenOrder();
% let orderedTemplates = [];
% let otherTemplates = [];
Expand Down
55 changes: 55 additions & 0 deletions source/drivers/xen/.project/project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
let path = require('path');

const files = {
common: [
"xen_console.c",
"xen_events.c",
"xen_hvm.c",
],
};

const asmfiles = {
common: [
"xen_hypercall.S",
],
};

const filedirs = {
common: [
".",
],
};


function getComponentProperty(device) {
const buildOptionCombos = [
{ device: device, cpu: "a53", cgt: "gcc-aarch64", os: "nortos" },
{ device: device, cpu: "a53", cgt: "gcc-aarch64", os: "freertos" },
];
let property = {};

property.dirPath = path.resolve(__dirname, "..");
property.type = "library";
property.name = "xen";
property.isInternal = false;
property.buildOptionCombos = buildOptionCombos;

return property;
}

function getComponentBuildProperty(buildOption) {
let build_property = {};

if(buildOption.cpu.match(/a53*/)){
build_property.files = files;
build_property.asmfiles = asmfiles;
build_property.filedirs = filedirs;
}

return build_property;
}

module.exports = {
getComponentProperty,
getComponentBuildProperty,
};
115 changes: 115 additions & 0 deletions source/drivers/xen/makefile.am62ax.a53.gcc-aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#
# Auto generated makefile
#

export MCU_PLUS_SDK_PATH?=$(abspath ../../..)
include $(MCU_PLUS_SDK_PATH)/imports.mak

CG_TOOL_ROOT=$(CGT_GCC_AARCH64_PATH)

CC=$(CGT_GCC_AARCH64_PATH)/bin/aarch64-none-elf-gcc
AR=$(CGT_GCC_AARCH64_PATH)/bin/aarch64-none-elf-gcc-ar

PROFILE?=release
ConfigName:=$(PROFILE)

LIBNAME:=xen.am62ax.a53.gcc-aarch64.$(PROFILE).lib

FILES_common := \
xen_console.c \
xen_events.c \
xen_hvm.c \

ASMFILES_common := \
xen_hypercall.S \

FILES_PATH_common = \
. \

INCLUDES_common := \
-I${MCU_PLUS_SDK_PATH}/source \

DEFINES_common := \
-DSOC_AM62X \

CFLAGS_common := \
-mcpu=cortex-a53+fp+simd \
-mabi=lp64 \
-mcmodel=large \
-mstrict-align \
-mfix-cortex-a53-835769 \
-mfix-cortex-a53-843419 \
-DXEN_ENABLED \
-Wall \
-Werror \
-g \
-Wno-int-to-pointer-cast \
-Wno-pointer-to-int-cast \
-Wno-unused-but-set-variable \
-fdata-sections \
-ffunction-sections \

CFLAGS_debug := \
-D_DEBUG_=1 \

CFLAGS_release := \
-O2 \

ARFLAGS_common := \
cr \

FILES := $(FILES_common) $(FILES_$(PROFILE))
ASMFILES := $(ASMFILES_common) $(ASMFILES_$(PROFILE))
FILES_PATH := $(FILES_PATH_common) $(FILES_PATH_$(PROFILE))
CFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE))
ASMFLAGS := $(CFLAGS_common) $(CFLAGS_$(PROFILE))
ifeq ($(CPLUSPLUS_BUILD), yes)
CFLAGS += $(CFLAGS_cpp_common)
endif
DEFINES := $(DEFINES_common) $(DEFINES_$(PROFILE))
INCLUDES := $(INCLUDES_common) $(INCLUDE_$(PROFILE))
ARFLAGS := $(ARFLAGS_common) $(ARFLAGS_$(PROFILE))

LIBDIR := lib
OBJDIR := obj/am62ax/gcc-aarch64/$(PROFILE)/a53/xen/
OBJS := $(FILES:%.c=%.obj)
OBJS += $(ASMFILES:%.S=%.obj)
DEPS := $(FILES:%.c=%.d)

vpath %.obj $(OBJDIR)
vpath %.c $(FILES_PATH)
vpath %.S $(FILES_PATH)

$(OBJDIR)/%.obj %.obj: %.c
@echo Compiling: $(LIBNAME): $<
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) -MMD -MT $@ -o $(OBJDIR)/$@ $<

$(OBJDIR)/%.obj %.obj: %.S
@echo Compiling: $(LIBNAME): $<
$(CC) -c -x assembler-with-cpp $(CFLAGS) $(INCLUDES) $(DEFINES) -o $(OBJDIR)$@ $<

all: $(LIBDIR)/$(LIBNAME)

$(LIBDIR)/$(LIBNAME): $(OBJS) | $(LIBDIR)
@echo .
@echo Archiving: $(LIBNAME) to $@ ...
$(AR) $(ARFLAGS) $@ $(addprefix $(OBJDIR), $(OBJS))
@echo Archiving: $(LIBNAME) Done !!!
@echo .

clean:
@echo Cleaning: $(LIBNAME) ...
$(RMDIR) $(OBJDIR)
$(RM) $(LIBDIR)/$(LIBNAME)

scrub:
@echo Scrubing: $(LIBNAME) ...
-$(RMDIR) obj/
-$(RMDIR) lib/

$(OBJS): | $(OBJDIR)

$(LIBDIR) $(OBJDIR):
$(MKDIR) $@

-include $(addprefix $(OBJDIR)/, $(DEPS))
Loading