Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SteveOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Stephen D
SteveOS
Commits
62abcdcd
Commit
62abcdcd
authored
6 years ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
Floppy drive can be used from any thread!
parent
9be7baaa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
drivers/floppy.c
+32
-25
32 additions, 25 deletions
drivers/floppy.c
drivers/floppy.h
+2
-2
2 additions, 2 deletions
drivers/floppy.h
util/commands.c
+11
-3
11 additions, 3 deletions
util/commands.c
with
45 additions
and
30 deletions
drivers/floppy.c
+
32
−
25
View file @
62abcdcd
...
...
@@ -47,7 +47,8 @@ u32 fl_tick = 0;
s8
floppy_ready
=
1
;
s8
floppy_queue
=
0
;
//0 -> None, 1-> Read, 2-> Write
unsigned
cyl_queue
=
0
;
void
(
callback_queue
)(
char
,
int
);
char
*
data_queue
=
0
;
void
(
*
callback_queue
)(
int
);
//Reserve some memory for when we read data
//Can't cross a 64k boundary ):
...
...
@@ -281,27 +282,34 @@ void floppy_loop() //Runs every 50 ms
void
flp_main_func
()
//Has to be executed as a 'main' process, not by interrupts
{
if
(
floppy_
queue
==
1
)
if
(
!
floppy_
ready
)
{
//READ
//todo: memory copy needed?
int
code
=
flp_do_track
(
cyl_queue
,
flp_dir_read
);
if
(
code
==
0
)
if
(
floppy_queue
==
1
)
{
callback_queue
(
0
,
flp_dmabuf
);
//READ
//todo: memory copy needed?
int
code
=
flp_do_track
(
cyl_queue
,
flp_dir_read
);
if
(
code
==
0
)
{
memory_copy
((
unsigned
char
*
)
&
flp_dmabuf
,
(
unsigned
char
*
)
data_queue
,
0x4800
);
callback_queue
(
0
);
}
else
{
callback_queue
(
code
);
}
data_queue
=
0
;
//Clear pointer
floppy_ready
=
1
;
floppy_queue
=
0
;
}
else
else
if
(
floppy_queue
==
2
)
{
callback_queue
(
code
,
NULL
);
//WRITE
callback_queue
(
flp_do_track
(
cyl_queue
,
flp_dir_write
));
floppy_ready
=
1
;
floppy_queue
=
0
;
}
}
else
if
(
floppy_queue
==
2
)
{
//WRITE
callback_queue
(
flp_do_track
(
cyl_queue
,
flp_dir_write
),
NULL
);
floppy_ready
=
1
;
floppy_queue
=
2
;
}
}
int
init_floppy
()
...
...
@@ -520,21 +528,20 @@ int flp_do_track(unsigned cyl, floppy_dir dir)
}
int
floppy_read_track
(
unsigned
cyl
,
char
*
data
)
//TODO: should call callback func
int
floppy_read_track
(
unsigned
cyl
,
char
*
data
,
void
(
*
callback
)(
int
response
)
)
//TODO: should call callback func
{
if
(
floppy_ready
)
{
int
code
=
flp_do_track
(
cyl
,
flp_dir_read
);
if
(
code
==
0
)
{
memory_copy
((
unsigned
char
*
)
&
flp_dmabuf
,
(
unsigned
char
*
)
data
,
0x4800
);
}
return
code
;
floppy_ready
=
0
;
floppy_queue
=
1
;
cyl_queue
=
cyl
;
callback_queue
=
callback
;
data_queue
=
data
;
}
return
27
;
//Data transfer already in progress
}
int
floppy_write_track
(
unsigned
cyl
,
char
*
data
,
void
(
callback
)(
int
response
,
char
data
))
//TODO: should call callback func
int
floppy_write_track
(
unsigned
cyl
,
char
*
data
,
void
(
*
callback
)(
int
response
))
{
if
(
floppy_ready
)
{
...
...
@@ -543,7 +550,7 @@ int floppy_write_track(unsigned cyl, char *data, void (callback)(int response, c
floppy_queue
=
2
;
cyl_queue
=
cyl
;
callback_queue
=
callback
;
return
0
;
//flp_do_track(cyl, flp_dir_write);
return
0
;
}
return
27
;
//Data transfer already in progress
}
This diff is collapsed.
Click to expand it.
drivers/floppy.h
+
2
−
2
View file @
62abcdcd
...
...
@@ -16,8 +16,8 @@
int
floppy_detect_drives
();
int
init_floppy
();
int
floppy_read_track
(
unsigned
cyl
,
char
*
data
);
int
floppy_write_track
(
unsigned
cyl
,
char
*
data
,
void
(
callback
)(
int
,
char
));
int
floppy_read_track
(
unsigned
cyl
,
char
*
data
,
void
(
*
callback
)(
int
)
);
int
floppy_write_track
(
unsigned
cyl
,
char
*
data
,
void
(
*
callback
)(
int
));
void
flp_main_func
();
...
...
This diff is collapsed.
Click to expand it.
util/commands.c
+
11
−
3
View file @
62abcdcd
...
...
@@ -101,12 +101,20 @@ void video_debug(char *args)
}
}*/
char
buffer
[
0x4800
];
void
read_callback
(
int
p
)
{
println
(
&
buffer
[
0x3c47
]);
println
(
"done"
);
UNUSED
(
p
);
}
void
read_disk
(
char
*
args
)
{
UNUSED
(
args
);
char
buffer
[
0x4800
];
floppy_read_track
(
3
,
buffer
);
println
(
buffer
);
floppy_read_track
(
1
,
buffer
,
read_callback
);
}
void
register_commands
()
...
...
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