Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
PPSi
Commits
afd96c2e
Commit
afd96c2e
authored
Jan 26, 2013
by
Danilo Sabato
Committed by
Alessandro Rubini
Feb 10, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arch-bare-linux: added set/get_tstamp and adj_freq using syscall
parent
4573b0be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
3 deletions
+57
-3
bare-io.c
arch-bare-linux/bare-io.c
+57
-3
No files found.
arch-bare-linux/bare-io.c
View file @
afd96c2e
...
...
@@ -2,8 +2,11 @@
* Alessandro Rubini for CERN, 2011 -- GPL 2 or later (it includes u-boot code)
*/
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "bare-linux.h"
const
Integer32
PP_ADJ_FREQ_MAX
=
512000
;
void
pp_puts
(
const
char
*
s
)
{
sys_write
(
0
,
s
,
pp_strnlen
(
s
,
300
));
...
...
@@ -28,9 +31,38 @@ void *pp_memcpy(void *dest, const void *src, int count)
return
dest
;
}
void
pp
_get_tstamp
(
TimeInternal
*
t
)
void
bare
_get_tstamp
(
TimeInternal
*
t
)
{
/* FIXME tstamp *sptr = htonl(sys_time(0));*/
struct
bare_timeval
tv
;
if
(
sys_gettimeofday
(
&
tv
,
NULL
)
<
0
)
{
PP_PRINTF
(
"gettimeofday error"
);
sys_exit
(
0
);
}
t
->
seconds
=
tv
.
tv_sec
;
t
->
nanoseconds
=
(
tv
.
tv_usec
%
1000
)
*
1000
;
}
int32_t
bare_set_tstamp
(
TimeInternal
*
t
)
{
struct
bare_timeval
tv_orig
;
struct
bare_timeval
tv
;
if
(
sys_gettimeofday
(
&
tv_orig
,
NULL
)
<
0
)
{
PP_PRINTF
(
"gettimeofday error"
);
sys_exit
(
0
);
}
tv
.
tv_sec
=
t
->
seconds
;
tv
.
tv_usec
=
t
->
nanoseconds
/
1000
;
if
(
sys_settimeofday
(
&
tv
,
NULL
)
<
0
)
{
PP_PRINTF
(
"settimeofday error"
);
sys_exit
(
0
);
}
return
tv
.
tv_sec
-
tv_orig
.
tv_sec
;
}
int
pp_memcmp
(
const
void
*
cs
,
const
void
*
ct
,
int
count
)
...
...
@@ -69,6 +101,28 @@ char *strcpy(char *dest, const char *src)
void
*
memset
(
void
*
s
,
int
c
,
int
count
)
__attribute__
((
alias
(
"pp_memset"
)));
void
*
memcpy
(
void
*
dest
,
const
void
*
src
,
int
count
)
__attribute__
((
alias
(
"pp_memcpy"
)));
int
bare_adj_freq
(
Integer32
adj
)
{
struct
bare_timex
t
;
if
(
adj
>
PP_ADJ_FREQ_MAX
)
adj
=
PP_ADJ_FREQ_MAX
;
else
if
(
adj
<
-
PP_ADJ_FREQ_MAX
)
adj
=
-
PP_ADJ_FREQ_MAX
;
t
.
modes
=
MOD_FREQUENCY
;
t
.
freq
=
adj
*
((
1
<<
16
)
/
1000
);
return
!
sys_adjtimex
(
&
t
);
}
int32_t
pp_set_tstamp
(
TimeInternal
*
t
)
__attribute__
((
alias
(
"bare_set_tstamp"
)));
void
pp_get_tstamp
(
TimeInternal
*
t
)
__attribute__
((
alias
(
"bare_get_tstamp"
)));
int
pp_adj_freq
(
Integer32
adj
)
__attribute__
((
alias
(
"bare_adj_freq"
)));
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