Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
SDB - Self-describing Bus
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
SDB - Self-describing Bus
Commits
d195ab25
Commit
d195ab25
authored
Sep 17, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdbfs/lib: fix glue.c to support strange-endian stuff
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
7acbfd79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
glue.c
sdbfs/lib/glue.c
+31
-10
libsdbfs.h
sdbfs/lib/libsdbfs.h
+1
-0
No files found.
sdbfs/lib/glue.c
View file @
d195ab25
/*
/*
* Copyright (C) 2012 CERN (www.cern.ch)
* Copyright (C) 2012
,2014
CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
* Author: Alessandro Rubini <rubini@gnudd.com>
*
*
* Released according to the GNU GPL, version 2 or any later version.
* Released according to the GNU GPL, version 2 or any later version.
...
@@ -23,13 +23,18 @@ int sdbfs_dev_create(struct sdbfs *fs, int verbose)
...
@@ -23,13 +23,18 @@ int sdbfs_dev_create(struct sdbfs *fs, int verbose)
magic
=
*
(
unsigned
int
*
)(
fs
->
data
+
fs
->
entrypoint
);
magic
=
*
(
unsigned
int
*
)(
fs
->
data
+
fs
->
entrypoint
);
else
else
fs
->
read
(
fs
,
fs
->
entrypoint
,
&
magic
,
sizeof
(
magic
));
fs
->
read
(
fs
,
fs
->
entrypoint
,
&
magic
,
sizeof
(
magic
));
if
(
htonl
(
magic
)
!=
SDB_MAGIC
)
if
(
magic
==
SDB_MAGIC
)
{
/* Uh! If we are little-endian, we must convert */
if
(
ntohl
(
1
)
!=
1
)
fs
->
flags
|=
SDBFS_F_CONVERT32
;
}
else
if
(
htonl
(
magic
)
==
SDB_MAGIC
)
{
/* ok, don't convert */
}
else
{
return
-
ENOTDIR
;
return
-
ENOTDIR
;
}
if
(
verbose
)
if
(
verbose
)
fs
->
flags
|=
SDBFS_F_VERBOSE
;
fs
->
flags
|=
SDBFS_F_VERBOSE
;
fs
->
next
=
sdbfs_list
;
fs
->
next
=
sdbfs_list
;
sdbfs_list
=
fs
;
sdbfs_list
=
fs
;
...
@@ -70,13 +75,29 @@ static struct sdb_device *sdbfs_readentry(struct sdbfs *fs,
...
@@ -70,13 +75,29 @@ static struct sdb_device *sdbfs_readentry(struct sdbfs *fs,
/*
/*
* This function reads an entry from a known good offset. It
* This function reads an entry from a known good offset. It
* returns the pointer to the entry, which may be stored in
* returns the pointer to the entry, which may be stored in
* the fs structure itself. Only touches fs->current_record
* the fs structure itself. Only touches fs->current_record
.
*/
*/
if
(
fs
->
data
)
if
(
fs
->
data
)
{
return
(
struct
sdb_device
*
)(
fs
->
data
+
offset
);
if
(
!
(
fs
->
flags
&
SDBFS_F_CONVERT32
))
if
(
!
fs
->
read
)
return
(
struct
sdb_device
*
)(
fs
->
data
+
offset
);
return
NULL
;
/* copy to local storage for conversion */
fs
->
read
(
fs
,
offset
,
&
fs
->
current_record
,
sizeof
(
fs
->
current_record
));
memcpy
(
&
fs
->
current_record
,
fs
->
data
+
offset
,
sizeof
(
fs
->
current_record
));
}
else
{
if
(
!
fs
->
read
)
return
NULL
;
fs
->
read
(
fs
,
offset
,
&
fs
->
current_record
,
sizeof
(
fs
->
current_record
));
}
if
(
fs
->
flags
&
SDBFS_F_CONVERT32
)
{
uint32_t
*
p
=
(
void
*
)
&
fs
->
current_record
;
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
fs
->
current_record
)
/
sizeof
(
*
p
);
i
++
)
p
[
i
]
=
ntohl
(
p
[
i
]);
}
return
&
fs
->
current_record
;
return
&
fs
->
current_record
;
}
}
...
...
sdbfs/lib/libsdbfs.h
View file @
d195ab25
...
@@ -51,6 +51,7 @@ struct sdbfs {
...
@@ -51,6 +51,7 @@ struct sdbfs {
};
};
#define SDBFS_F_VERBOSE 0x0001
#define SDBFS_F_VERBOSE 0x0001
#define SDBFS_F_CONVERT32 0x0002
/* swap SDB words as they are read */
/* Defined in glue.c */
/* Defined in glue.c */
...
...
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