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
5a350ead
Commit
5a350ead
authored
6 years ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
THIS CODE DOES NOT WORK, just committing it
parent
b54472f8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
drivers/floppy.c
+64
-23
64 additions, 23 deletions
drivers/floppy.c
drivers/floppy.h
+2
-5
2 additions, 5 deletions
drivers/floppy.h
kernel/kernel.c
+9
-5
9 additions, 5 deletions
kernel/kernel.c
util/commands.c
+3
-3
3 additions, 3 deletions
util/commands.c
with
78 additions
and
36 deletions
drivers/floppy.c
+
64
−
23
View file @
5a350ead
...
...
@@ -34,11 +34,28 @@ enum floppy_commands {
CMD_SEEK
=
15
,
// SEEK
};
typedef
enum
{
flp_dir_read
=
1
,
flp_dir_write
=
2
}
floppy_dir
;
s8
motor_tick
=
-
1
;
//Decrements once every 50ms. If it's 40, it'll take 2s to reach 0.
s8
motor
=
0
;
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
);
//Reserve some memory for when we read data
//Can't cross a 64k boundary ):
#define flp_dmalen 0x4800
static
const
char
flp_dmabuf
[
flp_dmalen
]
__attribute__
((
aligned
(
0x8000
)));
int
flp_do_track
(
unsigned
cyl
,
floppy_dir
dir
);
int
floppy_detect_drives
()
{
...
...
@@ -55,8 +72,7 @@ void lba_2_chs(u32 lba, u16* cyl, u16* head, u16* sector)
*
sector
=
((
lba
%
(
2
*
SECTORS_PER_TRACK
))
%
SECTORS_PER_TRACK
+
1
);
}
//u8 motor_countdown = 3; //Time until motor is ready
//u8 motor_running = 0;
void
motor_on
(
int
drive
)
//0 to 3
{
motor_tick
=
0
;
...
...
@@ -68,9 +84,6 @@ void motor_on(int drive) //0 to 3
//Wait
fl_delay
(
3
);
//motor_countdown = 3;
//motor_running = 1;
}
...
...
@@ -229,11 +242,6 @@ int flp_seek(s32 cyli, s8 head)
return
-
1
;
}
typedef
enum
{
flp_dir_read
=
1
,
flp_dir_write
=
2
}
floppy_dir
;
u8
flp_int
=
0
;
void
floppy_int_callback
(
registers_t
regs
)
...
...
@@ -270,6 +278,32 @@ 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
)
{
//READ
//todo: memory copy needed?
int
code
=
flp_do_track
(
cyl_queue
,
flp_dir_read
);
if
(
code
==
0
)
{
callback_queue
(
0
,
flp_dmabuf
);
}
else
{
callback_queue
(
code
,
NULL
);
}
}
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
()
{
...
...
@@ -288,11 +322,6 @@ int init_floppy()
return
1
;
}
//Reserve some memory for when we read data
//Can't cross a 64k boundary ):
#define flp_dmalen 0x4800
static
const
char
flp_dmabuf
[
flp_dmalen
]
__attribute__
((
aligned
(
0x8000
)));
static
void
flp_dma_init
(
floppy_dir
dir
)
{
union
...
...
@@ -491,18 +520,30 @@ int flp_do_track(unsigned cyl, floppy_dir dir)
}
int
floppy_read_track
(
unsigned
cyl
,
char
*
data
)
int
floppy_read_track
(
unsigned
cyl
,
char
*
data
)
//TODO: should call callback func
{
int
code
=
flp_do_track
(
cyl
,
flp_dir_read
);
if
(
code
==
0
)
if
(
floppy_ready
)
{
memory_copy
((
unsigned
char
*
)
&
flp_dmabuf
,
(
unsigned
char
*
)
data
,
0x4800
);
int
code
=
flp_do_track
(
cyl
,
flp_dir_read
);
if
(
code
==
0
)
{
memory_copy
((
unsigned
char
*
)
&
flp_dmabuf
,
(
unsigned
char
*
)
data
,
0x4800
);
}
return
code
;
}
return
code
;
return
27
;
//Data transfer already in progress
}
int
floppy_write_track
(
unsigned
cyl
,
char
*
data
)
int
floppy_write_track
(
unsigned
cyl
,
char
*
data
,
void
(
callback
)(
int
response
,
char
data
))
//TODO: should call callback func
{
memory_copy
((
unsigned
char
*
)
data
,
(
unsigned
char
*
)
&
flp_dmabuf
,
0x4800
);
return
flp_do_track
(
cyl
,
flp_dir_write
);
if
(
floppy_ready
)
{
memory_copy
((
unsigned
char
*
)
data
,
(
unsigned
char
*
)
&
flp_dmabuf
,
0x4800
);
floppy_ready
=
0
;
floppy_queue
=
2
;
cyl_queue
=
cyl
;
callback_queue
=
callback
;
return
0
;
//flp_do_track(cyl, flp_dir_write);
}
return
27
;
//Data transfer already in progress
}
This diff is collapsed.
Click to expand it.
drivers/floppy.h
+
2
−
5
View file @
5a350ead
...
...
@@ -17,11 +17,8 @@ int floppy_detect_drives();
int
init_floppy
();
int
floppy_read_track
(
unsigned
cyl
,
char
*
data
);
int
floppy_write_track
(
unsigned
cyl
,
char
*
data
);
//Temporary, for debugging
void
motor_on
(
int
drive
);
void
motor_off
();
int
floppy_write_track
(
unsigned
cyl
,
char
*
data
,
void
(
callback
)(
int
,
char
));
void
flp_main_func
();
#endif
This diff is collapsed.
Click to expand it.
kernel/kernel.c
+
9
−
5
View file @
5a350ead
...
...
@@ -50,13 +50,17 @@ void main() {
register_commands
();
char
buffer
[
0x4800
];
//char str[] = ;
strcpy
(
buffer
,
"writing this to the floppy drive"
);
//(unsigned char*)str);
/*char buffer[0x4800];
strcpy(buffer, "writing this to the floppy drive");
floppy_write_track(4, buffer);
println
(
buffer
);
println(buffer);
*/
/*register_loop(loop, 1000);*/
//Used when debugging loop
while
(
1
)
{
//Runs everything that needs it
flp_main_func
();
}
}
//Mandelbrot Generator
...
...
This diff is collapsed.
Click to expand it.
util/commands.c
+
3
−
3
View file @
5a350ead
...
...
@@ -89,7 +89,7 @@ void video_debug(char *args)
}
//DEBUGGING ONLY
void
motor_control
(
char
*
args
)
/*
void motor_control(char *args)
{
if(args[0] == '0')
{
...
...
@@ -99,7 +99,7 @@ void motor_control(char *args)
{
motor_on(0);
}
}
}*/
void
read_disk
(
char
*
args
)
{
...
...
@@ -118,6 +118,6 @@ void register_commands()
register_command
(
"halt"
,
halt_cpu
);
register_command
(
"vinfo"
,
video_debug
);
register_command
(
"edit"
,
editor
);
register_command
(
"fm"
,
motor_control
);
/*
register_command("fm", motor_control);
*/
register_command
(
"rd"
,
read_disk
);
}
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