Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
4fa8614d
Commit
4fa8614d
authored
14 years ago
by
Russ Cox
Browse files
Options
Downloads
Patches
Plain Diff
missing file memide.c
parent
417c3711
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
memide.c
+58
-0
58 additions, 0 deletions
memide.c
with
58 additions
and
0 deletions
memide.c
0 → 100644
+
58
−
0
View file @
4fa8614d
// Fake IDE disk; stores blocks in memory.
// Useful for running kernel without scratch disk.
#include
"types.h"
#include
"defs.h"
#include
"param.h"
#include
"mmu.h"
#include
"proc.h"
#include
"x86.h"
#include
"traps.h"
#include
"spinlock.h"
#include
"buf.h"
extern
uchar
_binary_fs_img_start
[],
_binary_fs_img_size
[];
static
int
disksize
;
static
uchar
*
memdisk
;
void
ideinit
(
void
)
{
memdisk
=
_binary_fs_img_start
;
disksize
=
(
uint
)
_binary_fs_img_size
/
512
;
}
// Interrupt handler.
void
ideintr
(
void
)
{
// no-op
}
// Sync buf with disk.
// If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.
// Else if B_VALID is not set, read buf from disk, set B_VALID.
void
iderw
(
struct
buf
*
b
)
{
uchar
*
p
;
if
(
!
(
b
->
flags
&
B_BUSY
))
panic
(
"iderw: buf not busy"
);
if
((
b
->
flags
&
(
B_VALID
|
B_DIRTY
))
==
B_VALID
)
panic
(
"iderw: nothing to do"
);
if
(
b
->
dev
!=
1
)
panic
(
"iderw: request not for disk 1"
);
if
(
b
->
sector
>=
disksize
)
panic
(
"iderw: sector out of range"
);
p
=
memdisk
+
b
->
sector
*
512
;
if
(
b
->
flags
&
B_DIRTY
){
b
->
flags
&=
~
B_DIRTY
;
memmove
(
p
,
b
->
data
,
512
);
}
else
memmove
(
b
->
data
,
p
,
512
);
b
->
flags
|=
B_VALID
;
}
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