Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
75f0a853
Commit
75f0a853
authored
Feb 17, 2021
by
Adam Wujek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell: add shell commands at compile time
This saves 600B Signed-off-by:
Adam Wujek
<
adam.wujek@creotech.pl
>
parent
754f4fd3
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
61 deletions
+32
-61
ram.ld.S
arch/lm32/ram.ld.S
+6
-0
temperature.c
dev/temperature.c
+3
-2
w1-shell.c
dev/w1-shell.c
+9
-1
shell.h
include/shell.h
+4
-3
cmd_refresh.c
shell/cmd_refresh.c
+3
-0
cmd_uptime.c
shell/cmd_uptime.c
+3
-0
shell.c
shell/shell.c
+4
-54
wrc_main.c
wrc_main.c
+0
-1
No files found.
arch/lm32/ram.ld.S
View file @
75f0a853
...
...
@@ -45,6 +45,12 @@ SECTIONS
.text : { *(.text .text.*) } > ram =0
.cmd : {
__cmd_begin = .;
KEEP(*(.cmd))
__cmd_end = .;
} > ram
.rodata : { *(.rodata .rodata.*) } > ram
.data : {
...
...
dev/temperature.c
View file @
75f0a853
...
...
@@ -125,9 +125,10 @@ static int cmd_temp(const char *args[])
return
0
;
}
/* This command was not registered before */
/*
DEFINE_WRC_COMMAND(temp) = {
.name = "temp",
.exec = cmd_temp,
};
*/
dev/w1-shell.c
View file @
75f0a853
...
...
@@ -27,10 +27,13 @@ static int cmd_w1_w(const char *args[])
return
i
==
blen
?
0
:
-
1
;
}
/* This command was not registered before */
/*
DEFINE_WRC_COMMAND(w1w) = {
.name = "w1w",
.exec = cmd_w1_w,
};
*/
/* A shell command, for testing read: "w1r <offset> <len> */
static
int
cmd_w1_r
(
const
char
*
args
[])
...
...
@@ -54,10 +57,13 @@ static int cmd_w1_r(const char *args[])
return
i
==
blen
?
0
:
-
1
;
}
/* This command was not registered before */
/*
DEFINE_WRC_COMMAND(w1r) = {
.name = "w1r",
.exec = cmd_w1_r,
};
*/
/* A shell command, for checking */
static
int
cmd_w1
(
const
char
*
args
[])
...
...
@@ -80,8 +86,10 @@ static int cmd_w1(const char *args[])
return
0
;
}
/* This command was not registered before */
/*
DEFINE_WRC_COMMAND(w1) = {
.name = "w1",
.exec = cmd_w1,
};
*/
include/shell.h
View file @
75f0a853
...
...
@@ -25,9 +25,12 @@ struct wrc_shell_cmd {
int
(
*
exec
)
(
const
char
*
args
[]);
};
extern
struct
wrc_shell_cmd
__cmd_begin
[],
__cmd_end
[];
/* Put the structures in their own section */
#define DEFINE_WRC_COMMAND(_name) \
const struct wrc_shell_cmd __wrc_cmd_ ## _name
static struct wrc_shell_cmd __wrc_cmd_ ## _name \
__attribute__((section(".cmd"), __used__))
char
*
env_get
(
const
char
*
var
);
int
env_set
(
const
char
*
var
,
const
char
*
value
);
...
...
@@ -39,9 +42,7 @@ extern int shell_is_interacting;
void
shell_boot_script
(
void
);
void
shell_show_build_init
(
void
);
void
shell_register_command
(
struct
wrc_shell_cmd
*
cmd
);
void
shell_list_cmds
(
void
);
void
shell_register_commands
(
void
);
void
shell_activate_ui_command
(
int
(
*
callback
)(
void
)
);
#endif
shell/cmd_refresh.c
View file @
75f0a853
...
...
@@ -31,7 +31,10 @@ static int cmd_refresh(const char *args[])
return
0
;
}
/* This command was not registered before */
/*
DEFINE_WRC_COMMAND(refresh) = {
.name = "refresh",
.exec = cmd_refresh,
};
*/
shell/cmd_uptime.c
View file @
75f0a853
...
...
@@ -9,7 +9,10 @@ static int cmd_uptime(const char *args[])
return
0
;
}
/* This command was not registered before */
/*
DEFINE_WRC_COMMAND(uptime) = {
.name = "uptime",
.exec = cmd_uptime,
};
*/
shell/shell.c
View file @
75f0a853
...
...
@@ -65,9 +65,6 @@ static int cmd_pos = 0, cmd_len = 0;
static
int
state
=
SH_PROMPT
;
static
int
current_key
=
0
;
static
struct
wrc_shell_cmd
*
cmds
[
SHELL_MAX_COMMANDS
];
static
int
n_cmds
=
0
;
int
shell_is_interacting
;
int
(
*
shell_ui_callback
)(
void
);
...
...
@@ -130,9 +127,8 @@ static int _shell_exec(void)
if
(
*
tokptr
[
0
]
==
'#'
)
return
0
;
for
(
i
=
0
;
i
<
n_cmds
;
i
++
)
for
(
p
=
__cmd_begin
;
p
<
__cmd_end
;
p
++
)
{
p
=
cmds
[
i
];
if
(
!
strcasecmp
(
p
->
name
,
tokptr
[
0
]))
{
rv
=
p
->
exec
((
const
char
**
)(
tokptr
+
1
));
if
(
rv
<
0
)
...
...
@@ -342,25 +338,13 @@ void shell_show_build_init(void)
pp_printf
(
"(empty)
\n
"
);
}
void
shell_register_command
(
struct
wrc_shell_cmd
*
cmd
)
{
if
(
n_cmds
>=
SHELL_MAX_COMMANDS
)
{
pp_printf
(
"can't register shell command '%s', increase SHELL_MAX_COMMANDS
\n
"
,
cmd
->
name
);
return
;
}
cmds
[
n_cmds
]
=
cmd
;
n_cmds
++
;
}
void
shell_list_cmds
()
{
int
i
;
struct
wrc_shell_cmd
*
p
;
for
(
i
=
0
;
i
<
n_cmds
;
i
++
)
for
(
p
=
__cmd_begin
;
p
<
__cmd_end
;
p
++
)
{
pp_printf
(
"
%s
\n
"
,
cmds
[
i
]
->
name
);
pp_printf
(
"
%s
\n
"
,
p
->
name
);
}
}
...
...
@@ -372,37 +356,3 @@ void shell_activate_ui_command( int (*callback)(void) )
term_clear
();
cmd_len
=
0
;
}
#define REGISTER_WRC_COMMAND(_name) \
{ extern struct wrc_shell_cmd __wrc_cmd_ ## _name; shell_register_command( &__wrc_cmd_ ## _name ); }
void
shell_register_commands
(
void
)
{
REGISTER_WRC_COMMAND
(
gui
);
REGISTER_WRC_COMMAND
(
ps
);
REGISTER_WRC_COMMAND
(
pll
);
REGISTER_WRC_COMMAND
(
ptp
);
REGISTER_WRC_COMMAND
(
verbose
);
REGISTER_WRC_COMMAND
(
mode
);
REGISTER_WRC_COMMAND
(
mac
);
REGISTER_WRC_COMMAND
(
sdb
);
REGISTER_WRC_COMMAND
(
calibration
);
REGISTER_WRC_COMMAND
(
help
);
REGISTER_WRC_COMMAND
(
diag
);
REGISTER_WRC_COMMAND
(
init
);
REGISTER_WRC_COMMAND
(
sfp
);
REGISTER_WRC_COMMAND
(
stat
);
REGISTER_WRC_COMMAND
(
ver
);
REGISTER_WRC_COMMAND
(
ptrack
);
REGISTER_WRC_COMMAND
(
time
);
if
(
HAS_IP
)
REGISTER_WRC_COMMAND
(
ip
);
if
(
HAS_VLANS
)
REGISTER_WRC_COMMAND
(
vlan
);
if
(
HAS_CMD_PPS
)
REGISTER_WRC_COMMAND
(
pps
);
if
(
HAS_CMD_LEAPSEC
)
REGISTER_WRC_COMMAND
(
leapsec
);
if
(
HAS_CMD_NETCONSOLE
)
REGISTER_WRC_COMMAND
(
netconsole
);
}
wrc_main.c
View file @
75f0a853
...
...
@@ -108,7 +108,6 @@ static void wrc_initialize(void)
/* try reading t24 phase transition from EEPROM */
calib_t24p
(
WRC_MODE_MASTER
,
&
cal_phase_transition
);
shell_init
();
shell_register_commands
();
_endram
=
ENDRAM_MAGIC
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment