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
222cb024
Commit
222cb024
authored
6 months ago
by
adrian.spycher
Browse files
Options
Downloads
Patches
Plain Diff
chore: rename macro REG for the ide
parent
a77246de
Branches
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
guest/ide/ide_phys.c
+10
-9
10 additions, 9 deletions
guest/ide/ide_phys.c
shared/hypercall_params.h
+0
-4
0 additions, 4 deletions
shared/hypercall_params.h
shared/ide_regs.h
+3
-3
3 additions, 3 deletions
shared/ide_regs.h
with
13 additions
and
16 deletions
guest/ide/ide_phys.c
+
10
−
9
View file @
222cb024
#include
"ide.h"
#include
<stdint.h>
#include
"guest/pmio.h"
#include
"shared/ide_regs.h"
#include
<stdint.h>
// --- DEFINE ---
...
...
@@ -15,7 +15,8 @@
*/
static
void
wait_drive
()
{
while
((
inb
(
IDE_STATUS_REG
)
&
0xC0
)
!=
0x40
);
// 0xC0 = 0b1100'0000, 0x40 = 0b0100'0000
while
((
inb
(
REG_IDE_ST
)
&
0xC0
)
!=
0x40
);
}
/**
...
...
@@ -26,11 +27,11 @@ static void pio_prepare(uint32_t sector) {
wait_drive
();
outb
(
IDE_DATA
_BASE_REG
+
2
,
1
);
// sector count
outb
(
IDE_DATA
_BASE_REG
+
3
,
sector
&
0xff
);
// send bits 0-7 of LBA
outb
(
IDE_DATA
_BASE_REG
+
4
,
(
sector
>>
8
)
&
0xff
);
// send bits 8-15 of LBA
outb
(
IDE_DATA
_BASE_REG
+
5
,
(
sector
>>
16
)
&
0xff
);
// send bits 16-23 of LBA
outb
(
IDE_DATA
_BASE_REG
+
6
,
((
sector
>>
24
)
&
0x0f
)
|
0xe0
);
// send bits 24-27 of LBA + set LBA mode; 0xe0 = 11100000b;
outb
(
REG_
IDE_DATA
+
2
,
1
);
// sector count
outb
(
REG_
IDE_DATA
+
3
,
sector
&
0xff
);
// send bits 0-7 of LBA
outb
(
REG_
IDE_DATA
+
4
,
(
sector
>>
8
)
&
0xff
);
// send bits 8-15 of LBA
outb
(
REG_
IDE_DATA
+
5
,
(
sector
>>
16
)
&
0xff
);
// send bits 16-23 of LBA
outb
(
REG_
IDE_DATA
+
6
,
((
sector
>>
24
)
&
0x0f
)
|
0xe0
);
// send bits 24-27 of LBA + set LBA mode; 0xe0 = 11100000b;
}
// --- FUNCTION ---
...
...
@@ -39,13 +40,13 @@ void ide_phys_write_sector(uint32_t sector, void *data) {
pio_prepare
(
sector
);
outb
(
IDE_CMD
_REG
,
0x30
);
// command port: write with retry
outb
(
REG_
IDE_CMD
,
0x30
);
// command port: write with retry
wait_drive
();
uint16_t
*
d
=
(
uint16_t
*
)
data
;
for
(
int
i
=
0
;
i
<
MAX_LOOP_IDE_DATA
;
i
++
)
{
outw
(
IDE_DATA
_BASE_REG
,
*
d
);
outw
(
REG_
IDE_DATA
,
*
d
);
d
++
;
}
}
...
...
This diff is collapsed.
Click to expand it.
shared/hypercall_params.h
+
0
−
4
View file @
222cb024
...
...
@@ -22,10 +22,6 @@
#define REG_GFX_INIT_CMD 0x4E700100
#define REG_GFX_INIT_DATA 0x4E700200
#define REG_IDE_ST 0x1F7
#define REG_IDE_CMD 0x1F7
#define REG_IDE_DATA 0x1F0
// --- SHARED STRUCT ---
typedef
struct
{
...
...
This diff is collapsed.
Click to expand it.
shared/ide_regs.h
+
3
−
3
View file @
222cb024
#ifndef _IDE_REGS_H_
#define _IDE_REGS_H_
#define IDE_ST
ATUS_REG
0x1F7 // Status register on the primary bus (read-only)
#define IDE_CMD
_REG
0x1F7 // Command register on the primary bus (write-only)
#define IDE_DATA
_BASE_REG
0x1F0 // Base port on primary bus (write-only)
#define
REG_
IDE_ST 0x1F7 // Status register on the primary bus (read-only)
#define
REG_
IDE_CMD 0x1F7 // Command register on the primary bus (write-only)
#define
REG_
IDE_DATA 0x1F0 // Base port on primary bus (write-only)
#define SECTOR_SIZE 512
#define MAX_SECTOR_NUM ((1UL << 28) - 1)
...
...
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