Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
White Rabbit Switch - Software
Commits
0cc70574
Commit
0cc70574
authored
Nov 20, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/hal: make local functions static; remove unused code
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
8c7317ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
103 deletions
+9
-103
hal_main.c
userspace/wrsw_hal/hal_main.c
+7
-101
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+2
-2
No files found.
userspace/wrsw_hal/hal_main.c
View file @
0cc70574
...
...
@@ -48,100 +48,7 @@ static void call_cleanup_cbs()
cleanup_cb
[
i
]
();
}
/* Determines which FPGA bitstreams shall be loaded */
int
hal_setup_fpga_images
()
{
char
fpga_dir
[
128
];
/* query the path to the firmware directory in the config file */
if
(
hal_config_get_string
(
"global.hal_firmware_path"
,
fpga_dir
,
sizeof
(
fpga_dir
))
<
0
)
return
-
1
;
// shw_set_fpga_firmware_path(fpga_dir);
/* check if the config demands a particular bitstream (otherwise libwr
* will load the default ones) */
/*
if( !hal_config_get_string("global.main_firmware",
fw_name, sizeof(fw_name)))
shw_request_fpga_firmware(FPGA_ID_MAIN, fw_name);
if( !hal_config_get_string("global.clkb_firmware",
fw_name, sizeof(fw_name)))
shw_request_fpga_firmware(FPGA_ID_CLKB, fw_name);
*/
return
0
;
}
/* loads (load = 1) or unloads (load = 0) a WR kernel module (name). */
static
int
load_unload_kmod
(
const
char
*
name
,
int
load
)
{
static
char
modules_path
[
128
];
static
int
modules_path_valid
=
0
;
char
cmd
[
256
];
if
(
!
modules_path_valid
)
{
if
(
hal_config_get_string
(
"global.hal_modules_path"
,
modules_path
,
sizeof
(
modules_path
))
<
0
)
{
TRACE
(
TRACE_ERROR
,
"Unable to locate kernel "
"modules directory!"
);
return
-
1
;
}
modules_path_valid
=
1
;
}
TRACE
(
TRACE_INFO
,
"%s kernel module '%s'"
,
load
?
"Loading"
:
"Unloading"
,
name
);
snprintf
(
cmd
,
sizeof
(
cmd
),
"%s %s/%s"
,
load
?
"/sbin/insmod"
:
"/sbin/rmmod"
,
modules_path
,
name
);
system
(
cmd
);
return
0
;
}
/* Unloads all WR kernel modules during the shutdown */
static
void
unload_kernel_modules
()
{
char
module_name
[
80
];
int
index
=
0
;
for
(;;)
{
if
(
!
hal_config_iterate
(
"global.modules"
,
index
++
,
module_name
,
sizeof
(
module_name
)))
break
;
load_unload_kmod
(
module_name
,
0
);
}
}
/* Loads all WR kernel modules specified in the HAL config file */
int
hal_load_kernel_modules
()
{
char
module_name
[
80
];
int
index
=
0
;
TRACE
(
TRACE_INFO
,
"Loading kernel modules..."
);
for
(;;)
{
if
(
!
hal_config_iterate
(
"global.modules"
,
index
++
,
module_name
,
sizeof
(
module_name
)))
break
;
assert_init
(
load_unload_kmod
(
module_name
,
1
));
}
hal_add_cleanup_callback
(
unload_kernel_modules
);
return
0
;
}
void
sighandler
(
int
sig
)
static
void
sighandler
(
int
sig
)
{
TRACE
(
TRACE_ERROR
,
"signal caught (%d)!"
,
sig
);
...
...
@@ -153,16 +60,16 @@ void sighandler(int sig)
exit
(
0
);
}
int
hal_shutdown
()
static
int
hal_shutdown
()
{
call_cleanup_cbs
();
return
0
;
}
void
hal_deamonize
();
static
void
hal_deamonize
();
/* Main initialization function */
int
hal_init
()
static
int
hal_init
()
{
char
sfp_db_path
[
1024
];
...
...
@@ -183,7 +90,6 @@ int hal_init()
/* parse the config file and choose the bitstreams to load */
assert_init
(
hal_parse_config
());
// assert_init(hal_setup_fpga_images());
if
(
!
hal_config_get_string
(
"global.sfp_database_path"
,
sfp_db_path
,
sizeof
(
sfp_db_path
)))
{
...
...
@@ -219,7 +125,7 @@ int hal_init()
/* Main loop update - polls for WRIPC requests and rolls the port
* state machines */
void
hal_update
()
static
void
hal_update
()
{
hal_update_wripc
();
hal_update_ports
();
...
...
@@ -228,7 +134,7 @@ void hal_update()
}
/* Turns a nice and well-behaving HAL into an evil servant of satan. */
void
hal_deamonize
()
static
void
hal_deamonize
()
{
pid_t
pid
,
sid
;
...
...
@@ -280,7 +186,7 @@ Usage: wrsw_hal [options], where [options] can be:\n\
-c [file]: specify your own config file
\n\n
"
);
}
void
hal_parse_cmdline
(
int
argc
,
char
*
argv
[])
static
void
hal_parse_cmdline
(
int
argc
,
char
*
argv
[])
{
int
opt
;
...
...
userspace/wrsw_hal/hal_ports.c
View file @
0cc70574
...
...
@@ -193,7 +193,7 @@ static void enable_port(int port, int enable)
/* Port initialization. Assigns the MAC address, WR timing mode, reads
* parameters from the config file. */
int
hal_init_port
(
const
char
*
name
,
int
index
)
static
int
hal_init_port
(
const
char
*
name
,
int
index
)
{
char
key_name
[
128
];
char
val
[
128
];
...
...
@@ -355,7 +355,7 @@ static void poll_rts_state()
}
}
uint32_t
pcs_readl
(
hal_port_state_t
*
p
,
int
reg
)
static
uint32_t
pcs_readl
(
hal_port_state_t
*
p
,
int
reg
)
{
struct
ifreq
ifr
;
uint32_t
rv
;
...
...
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