Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
virtual_game_machine
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
adrian.spycher
virtual_game_machine
Commits
8f9642b3
Commit
8f9642b3
authored
6 months ago
by
adrian.spycher
Browse files
Options
Downloads
Patches
Plain Diff
chore: fix state machine value and redo some printf
parent
222cb024
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vmm/operation.c
+12
-12
12 additions, 12 deletions
vmm/operation.c
vmm/operation.h
+3
-3
3 additions, 3 deletions
vmm/operation.h
with
15 additions
and
15 deletions
vmm/operation.c
+
12
−
12
View file @
8f9642b3
...
...
@@ -31,16 +31,16 @@ state_t STATE_GFX_INIT[] = {
state_t
STATE_IDE
[]
=
{
{
OP_READ_INJECT
,
REG_IDE_ST
,
0
,
1
,
op_callback_ide_prepare
},
{
OP_READ_INJECT
,
REG_IDE_ST
,
0
x40
,
1
,
op_callback_ide_prepare
},
{
OP_WRITE_EQUAL
,
REG_IDE_DATA
+
2
,
1
,
1
,
NULL
},
{
OP_WRITE_STORE
,
REG_IDE_DATA
+
3
,
0
,
1
,
op_callback_ide_store_sector_1
},
{
OP_WRITE_STORE
,
REG_IDE_DATA
+
4
,
0
,
1
,
op_callback_ide_store_sector_2
},
{
OP_WRITE_STORE
,
REG_IDE_DATA
+
5
,
0
,
1
,
op_callback_ide_store_sector_3
},
{
OP_WRITE_STORE
,
REG_IDE_DATA
+
6
,
0
,
1
,
op_callback_ide_store_sector_4
},
{
OP_WRITE_EQUAL
,
REG_IDE_CMD
,
0x30
,
1
,
NULL
},
{
OP_READ_INJECT
,
REG_IDE_ST
,
0
,
1
,
NULL
},
{
OP_READ_INJECT
,
REG_IDE_ST
,
0
x40
,
1
,
NULL
},
{
OP_WRITE_STORE_LOOP
,
REG_IDE_DATA
,
0
,
2
,
op_callback_ide_store_data
},
{
OP_EMUL_END
,
0
,
0
,
0
,
op_callback_ide_con
d
lude
},
{
OP_EMUL_END
,
0
,
0
,
0
,
op_callback_ide_con
c
lude
},
};
state_t
*
STATE_ALL_STARTERS
[]
=
{
...
...
@@ -57,7 +57,7 @@ static hyper_init_gfx_params_t param_gfx_init;
static
hyper_ide_params_t
param_ide
;
// store the index of the actual loop
static
uint32_t
loop_ide_data
;
static
uint32_t
loop_ide_data
=
MAX_LOOP_IDE_DATA
;
static
uint16_t
buf_ide_data
[
MAX_LOOP_IDE_DATA
];
// --- STATIC FUNCTION ---
...
...
@@ -70,7 +70,7 @@ void op_callback_console_conclude(void *addr) {
hyper_virtual_console_params_t
*
p_consol
=
(
hyper_virtual_console_params_t
*
)
addr
;
printf
(
"
action
: sending a message...
\n
"
);
printf
(
"
OPERATION
: sending a message...
\n
"
);
printf
(
"%s
\n
"
,
(
char
*
)
p_consol
->
msg
);
}
...
...
@@ -83,7 +83,7 @@ void op_callback_timer_conclude(void *addr) {
hyper_timer_sleep_params_t
*
p_timer
=
(
addr
==
NULL
)
?
&
param_timer
:
(
hyper_timer_sleep_params_t
*
)
addr
;
printf
(
"
action
: setting up a %dus timer...
\n
"
,
p_timer
->
us
);
printf
(
"
OPERATION
: setting up a %dus timer...
\n
"
,
p_timer
->
us
);
usleep
(
p_timer
->
us
);
}
...
...
@@ -101,7 +101,7 @@ void op_callback_gfx_init_conclude(void *addr) {
hyper_init_gfx_params_t
*
p_gfx_init
=
(
addr
==
NULL
)
?
&
param_gfx_init
:
(
hyper_init_gfx_params_t
*
)
addr
;
printf
(
"
action
: initializing gfx %dx%d...
\n
"
,
p_gfx_init
->
width
,
p_gfx_init
->
height
);
printf
(
"
OPERATION
: initializing gfx %dx%d...
\n
"
,
p_gfx_init
->
width
,
p_gfx_init
->
height
);
width_gfx
=
p_gfx_init
->
width
;
height_gfx
=
p_gfx_init
->
height
;
sem_post
(
&
sem_gfx
);
...
...
@@ -133,7 +133,7 @@ void op_callback_ide_store_sector_3(void *addr) {
void
op_callback_ide_store_sector_4
(
void
*
addr
)
{
param_ide
.
sector_idx
|=
((
*
(
uint8_t
*
)
addr
)
&
0x0F
)
<<
24
;
//
TODO
: what to do with the mode ?
//
WARNING
: what to do with the mode ?
}
void
op_callback_ide_store_data
(
void
*
addr
)
{
...
...
@@ -148,10 +148,10 @@ void op_callback_ide_store_data(void *addr) {
}
}
void
op_callback_ide_con
d
lude
(
void
*
addr
)
{
void
op_callback_ide_con
c
lude
(
void
*
addr
)
{
hyper_ide_params_t
*
p_ide
=
(
addr
==
NULL
)
?
&
param_ide
:
(
hyper_ide_params_t
*
)
addr
;
printf
(
"
action
: writing
on 0x%lx
on sector %d
\n
"
,
p_ide
->
data
,
p_ide
->
sector_idx
);
printf
(
"
OPERATION
: writing
data
on sector %d
\n
"
,
p_ide
->
sector_idx
);
// check sector range
if
(
p_ide
->
sector_idx
>
MAX_SECTOR_NUM
)
err
(
1
,
"IDE sector is out of range"
);
...
...
@@ -164,15 +164,15 @@ void op_callback_ide_condlude(void *addr) {
// Seek to the sector position
if
(
fseek
(
disk
,
offset
,
SEEK_SET
)
!=
0
)
{
err
(
1
,
"IDE seek failed"
);
fclose
(
disk
);
err
(
1
,
"IDE seek failed"
);
}
// Write 512 bytes to the specified sector
size_t
bytes_written
=
fwrite
((
void
*
)
p_ide
->
data
,
1
,
SECTOR_SIZE
,
disk
);
if
(
bytes_written
!=
SECTOR_SIZE
)
{
err
(
1
,
"IDE failed to write full sector"
);
fclose
(
disk
);
err
(
1
,
"IDE failed to write full sector"
);
}
fclose
(
disk
);
...
...
This diff is collapsed.
Click to expand it.
vmm/operation.h
+
3
−
3
View file @
8f9642b3
...
...
@@ -10,7 +10,7 @@
// --- DEFINE ---
#define STATE_MACHINE_NUM
2
#define STATE_MACHINE_NUM
3
typedef
enum
{
...
...
@@ -24,7 +24,7 @@ typedef enum {
typedef
struct
{
operation_t
op
;
// the operation to perform
uint
32
_t
addr
;
// the address written to/read from
uint
64
_t
addr
;
// the address written to/read from
uint32_t
value
;
// the expected written value or value to inject
uint8_t
size
;
// the size of the operation (8, 16 or 32 bits)
void
(
*
callback
)(
void
*
addr
);
// custom function that would be executed at the end of the state
...
...
@@ -102,6 +102,6 @@ void op_callback_ide_store_sector_4(void *addr);
void
op_callback_ide_store_data
(
void
*
addr
);
void
op_callback_ide_con
d
lude
(
void
*
addr
);
void
op_callback_ide_con
c
lude
(
void
*
addr
);
#endif // _OPERATION_H_
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