Browse Source

add dspkit/linkcmd.xdt

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 6 years ago
parent
commit
66ab5332a5
  1. 1
      packages/vsky/dspkit/driver/cpu.c
  2. 18
      packages/vsky/dspkit/driver/driver.c
  3. 111
      packages/vsky/dspkit/linkcmd.xdt
  4. 2
      packages/vsky/dspkit/package.bld
  5. 15
      packages/vsky/dspkit/package.xs
  6. 1
      packages/vsky/dspkit/private/driver.h
  7. 9
      packages/vsky/dspkit/sections.xdt
  8. 8
      packages/vsky/lua/lualib/repl.c
  9. 1
      packages/vsky/lua/lualib/script.h

1
packages/vsky/dspkit/driver/cpu.c

@ -27,3 +27,4 @@ struct driver __cpu = {
0, 0,
}; };
//#pragma DATA_SECTION(__c66x_driver_cpu, DRIVER_SECTION);

18
packages/vsky/dspkit/driver/driver.c

@ -4,22 +4,34 @@
#include "driver.h" #include "driver.h"
#include "driver_private.h" #include "driver_private.h"
struct driver * __drivers[] = { struct driver * __builtins[] = {
&__cpu, &__cpu,
NULL NULL
}; };
extern struct driver __c66x_drivers_begin[], __c66x_drivers_end[];
struct driver *driver_find(const char *name) struct driver *driver_find(const char *name)
{ {
int i = 0; int i = 0;
struct driver *dp; struct driver *dp;
while (__drivers[i]) { dp = __builtins[i];
dp = __drivers[i]; while (dp) {
if (strcmp(dp->name, name) == 0) { if (strcmp(dp->name, name) == 0) {
return dp; return dp;
} }
++i; ++i;
dp = __builtins[i];
}
i = 0;
dp = &__c66x_drivers_begin[i];
while (dp < __c66x_drivers_end) {
if (strcmp(dp->name, name) == 0) {
return dp;
}
++i;
dp = &__c66x_drivers_begin[i];
} }
return NULL; return NULL;
} }

111
packages/vsky/dspkit/linkcmd.xdt

@ -0,0 +1,111 @@
%%{
/*
* Copyright (c) 2008 Texas Instruments and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Texas Instruments - initial implementation
*
* */
%%}
%/*
% * ======== linkcmd.xdt ========
% * This is template file is used to generate a linker command file for
% * executables. It provides a single place where we can embed information
% * necessary to load/run executables.
% *
% * This template is expanded after the configuration script runs and the
% * results placed in a file (with extension .xdl) associated with the
% * executable.
% *
% * Linker templates are passed the following arguments:
% * $out - an open file stream for the generated linker
% * command file
% * $args[] - an array of zero or more libraries that should be linked
% * with (in the order they appear in the argument list)
% *
% * In addition to these arguments, there is a global variable named
% * 'this' that is set as follows:
% * this - the program object
% */
%var _utils = xdc.loadCapsule("ti/targets/linkUtils.xs");
%var prog = this; /* meaningful alias for this (== xdc.cfg.Program) */
/*
* Do not modify this file; it is automatically generated from the template
* linkcmd.xdt in the ti.targets.elf package and will be overwritten.
*/
/*
* put '"'s around paths because, without this, the linker
* considers '-' as minus operator, not a file name character.
*/
--diag_suppress=10068
%for (var i = 0; i < prog.$$asmvec.length; i++) {
"`prog.$$asmvec[i]`"
%}
%for (var i = 0; i < $args.length; i++) {
-l"`$args[i]`"
%}
--retain="*(xdc.meta)"
--retain="*(.c66x_driver)"
%if (prog.$$isasm) {
% return;
%}
--args `utils.toHex(prog.argSize)`
-heap `utils.toHex(prog.heap)`
-stack `utils.toHex(prog.stack)`
%if (prog.build.target.isa[0] == "5" && prog.build.target.isa[1] != '4') {
-sysstack `utils.toHex(prog.sysStack)`
%}
MEMORY
{
%for (var i = 0; i < prog.cpu.memoryMap.length; i++) {
%var mem = prog.cpu.memoryMap[i];
%var page = (mem.page != null) ? ("PAGE " + mem.page + ": ") : "";
%var org = utils.toHex(mem.base);
%var len = utils.toHex(mem.len);
%var access = (mem.access != null) ? (" (" + mem.access + ")") : "";
`page``mem.name``access` : org = `org`, len = `len`
%}
}
/*
* Linker command file contributions from all loaded packages:
*/
`_utils.genContributions($args)`
/*
* symbolic aliases for static instance objects
*/
%for (var sym in Program.symbol) {
%var inst = Program.symbol[sym];
%if (typeof(inst) == 'number') {
`this.build.target.asmName(sym)` = `inst`;
%}
%else {
%var objTab = inst.$module.$name.replace(/\./g, '_') + '_Object__table__V';
%var off = Program.$capsule.instSize(inst) * inst.$index;
`this.build.target.asmName(sym)` = `this.build.target.asmName(objTab)` + `off`;
%}
%}
SECTIONS
{
`xdc.loadCapsule("ti/targets/elf/linkUtils.xs").genElfSections(prog)`
}
%%{
/*
* @(#) ti.targets.elf; 1, 0, 0,373; 11-4-2012 21:21:33; /db/ztree/library/trees/xdctargets/xdctargets-f40x/src/ xlibrary
*/
%%}

2
packages/vsky/dspkit/package.bld

@ -44,7 +44,7 @@ var objFiles = drvFiles.concat(libfdtFiles).concat(elfFiles);
for (var i = 0; i < Build.targets.length; i++) { for (var i = 0; i < Build.targets.length; i++) {
var targ = Build.targets[i]; var targ = Build.targets[i];
var libName = "dspkit-v2"; var libName = "dspkit_v2";
var libOptions = { var libOptions = {
incs: libdspPathInclude, incs: libdspPathInclude,

15
packages/vsky/dspkit/package.xs

@ -6,16 +6,7 @@ function close()
return; return;
var Program = xdc.useModule("xdc.cfg.Program"); var Program = xdc.useModule("xdc.cfg.Program");
Program.linkTemplate = "vsky/dspkit/linkcmd.xdt";
Program = xdc.useModule('xdc.cfg.Program'); Program.sectionsTemplate = "vsky/dspkit/sections.xdt";
Program.sectMap[".qmss"] = sectName; Program.sectionsExclude = "^\.c66x_driver$";
Program.sectMap[".cppi"] = sectName;;
Program.sectMap[".nimu_eth_ll2"] = sectName;
Program.sectMap[".srioSharedMem"] = sectName;
Program.sectMap[".far:taskStackSection"] = sectName;
Program.sectMap[".resmgr_memregion"] = {loadSegment: sectName, loadAlign: 128}; /* QMSS descriptors region */
Program.sectMap[".resmgr_handles"] = {loadSegment: sectName, loadAlign: 16}; /* CPPI/QMSS/PA Handles */
Program.sectMap[".resmgr_pa"] = {loadSegment: sectName, loadAlign: 8}; /* PA Memory */
Program.sectMap[".far:NDK_OBJMEM"] = {loadSegment: sectName, loadAlign: 8};
Program.sectMap[".far:NDK_PACKETMEM"] = {loadSegment: sectName, loadAlign: 128};
} }

1
packages/vsky/dspkit/private/driver.h

@ -54,6 +54,7 @@ static int inline driver_active(struct device *dev)
return -2; return -2;
} }
#define DRIVER_SECTION ".c66x_driver"
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

9
packages/vsky/dspkit/sections.xdt

@ -0,0 +1,9 @@
% // this = Program, args[0] = sectMap
%var sectMap = $args[0];
%var stack = sectMap[".stack"];
`$args[1]`
.c66x_drivers: fill=0x0, align = 0x4 {
__c66x_drivers_begin = .;
*(.c66x_driver)
__c66x_drivers_end = .;
} > `stack.loadSegment`

8
packages/vsky/lua/lualib/repl.c

@ -59,8 +59,14 @@ static int pushline(lua_State *L, int firstline, struct repl_object *ro)
return 0; /* no input (prompt will be popped by caller) */ return 0; /* no input (prompt will be popped by caller) */
__puts(ro, "\n"); __puts(ro, "\n");
lua_pop(L, 1); /* remove prompt */
l = strlen(b); l = strlen(b);
if (ro->hook) {
if (ro->hook(ro, b, l)) {
readstatus = 0;
return 0;
}
}
lua_pop(L, 1); /* remove prompt */
if (l > 0 && b[l - 1] == '\n') /* line ends with newline? */ if (l > 0 && b[l - 1] == '\n') /* line ends with newline? */
b[--l] = '\0'; /* remove it */ b[--l] = '\0'; /* remove it */
if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */ if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */

1
packages/vsky/lua/lualib/script.h

@ -10,6 +10,7 @@ struct repl_object {
int (*bye)(struct repl_object *); int (*bye)(struct repl_object *);
void (*puts)(struct repl_object *, const char *s); void (*puts)(struct repl_object *, const char *s);
int (*gets)(struct repl_object *, char *buf, int len); int (*gets)(struct repl_object *, char *buf, int len);
int (*hook)(struct repl_object *, char *s, int len);
void *user_data; void *user_data;
}; };

Loading…
Cancel
Save