Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hust-x86-simulator
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yizhiran
hust-x86-simulator
Commits
e568ce53
There was an error fetching the commit references. Please try again later.
Verified
Commit
e568ce53
authored
5 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
another trial
parent
5b11c6b8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nemu/src/memory/memory.cc
+10
-8
10 additions, 8 deletions
nemu/src/memory/memory.cc
with
10 additions
and
8 deletions
nemu/src/memory/memory.cc
+
10
−
8
View file @
e568ce53
...
...
@@ -12,14 +12,16 @@ uint8_t pmem[PMEM_SIZE];
/* Memory accessing interfaces */
__attribute__
((
hot
))
uint32_t
paddr_read
(
paddr_t
addr
,
int
len
)
{
switch
(
len
)
{
case
4
:
return
pmem_rw
(
addr
,
uint32_t
);
case
2
:
return
pmem_rw
(
addr
,
uint32_t
)
&
0x0000ffff
;
case
1
:
return
pmem_rw
(
addr
,
uint32_t
)
&
0x000000ff
;
case
3
:
return
pmem_rw
(
addr
,
uint32_t
)
&
0x00ffffff
;
case
0
:
return
0
;
}
return
pmem_rw
(
addr
,
uint32_t
)
&
(
~
0u
>>
((
4
-
len
)
<<
3
));
static
const
uint32_t
niddle
[]
=
{
0
,
0xff
,
0xffff
,
0xffffff
,
0xffffffff
};
return
pmem_rw
(
addr
,
uint32_t
)
&
niddle
[
len
];
// switch(len) {
// case 4: return pmem_rw(addr, uint32_t);
// case 2: return pmem_rw(addr, uint32_t) & 0x0000ffff;
// case 1: return pmem_rw(addr, uint32_t) & 0x000000ff;
// case 3: return pmem_rw(addr, uint32_t) & 0x00ffffff;
// case 0: return 0;
// }
// return pmem_rw(addr, uint32_t) & (~0u >> ((4 - len) << 3));
}
void
paddr_write
(
paddr_t
addr
,
uint32_t
data
,
int
len
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment