Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ASA
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASE-2021
ASA
Commits
28e4d289
Commit
28e4d289
authored
4 years ago
by
Thierno souleymane Bah
Browse files
Options
Downloads
Patches
Plain Diff
feat(format sector programm added)
parent
abbb0b82
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
tpfs/Makefile
+2
-1
2 additions, 1 deletion
tpfs/Makefile
tpfs/display_sector.c
+1
-1
1 addition, 1 deletion
tpfs/display_sector.c
tpfs/drive.c
+4
-4
4 additions, 4 deletions
tpfs/drive.c
tpfs/drive.h
+2
-2
2 additions, 2 deletions
tpfs/drive.h
tpfs/format_sector.c
+74
-0
74 additions, 0 deletions
tpfs/format_sector.c
with
83 additions
and
8 deletions
tpfs/Makefile
+
2
−
1
View file @
28e4d289
...
@@ -13,7 +13,7 @@ LIBS = -L$(LIBDIR) -lhardware
...
@@ -13,7 +13,7 @@ LIBS = -L$(LIBDIR) -lhardware
###------------------------------
###------------------------------
### Main targets
### Main targets
###------------------------------------------------------------
###------------------------------------------------------------
BINARIES
=
mkhd display_sector
BINARIES
=
mkhd display_sector
format_sector
all
:
$(BINARIES) $(OBJECTS)
all
:
$(BINARIES) $(OBJECTS)
...
@@ -29,6 +29,7 @@ all: $(BINARIES) $(OBJECTS)
...
@@ -29,6 +29,7 @@ all: $(BINARIES) $(OBJECTS)
mkhd
:
mkhd.o
mkhd
:
mkhd.o
display_sector
:
display_sector.o drive.o
display_sector
:
display_sector.o drive.o
format_sector
:
format_sector.o drive.o
###------------------------------
###------------------------------
### Misc.
### Misc.
...
...
This diff is collapsed.
Click to expand it.
tpfs/display_sector.c
+
1
−
1
View file @
28e4d289
...
@@ -52,7 +52,7 @@ int main(int argc, char const *argv[])
...
@@ -52,7 +52,7 @@ int main(int argc, char const *argv[])
_mask
(
1
);
_mask
(
1
);
read_sector
(
buffer
,
atoi
(
argv
[
1
]),
atoi
(
argv
[
2
]));
read_sector
(
buffer
,
atoi
(
argv
[
1
]),
atoi
(
argv
[
2
]));
dump
(
buffer
,
HDA_SECTORSIZE
,
1
,
0
);
dump
(
buffer
,
HDA_SECTORSIZE
,
0
,
1
);
/* and exit! */
/* and exit! */
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
...
...
This diff is collapsed.
Click to expand it.
tpfs/drive.c
+
4
−
4
View file @
28e4d289
...
@@ -47,10 +47,10 @@ void dump(unsigned char *buffer,
...
@@ -47,10 +47,10 @@ void dump(unsigned char *buffer,
void
seek
(
int
cylinder
,
int
sector
)
void
seek
(
int
cylinder
,
int
sector
)
{
{
_out
(
HDA_DATAREGS
,
(
cylinder
>>
8
)
&
25
6
);
_out
(
HDA_DATAREGS
,
(
cylinder
>>
8
)
&
25
5
);
_out
(
HDA_DATAREGS
+
1
,
cylinder
&
25
6
);
_out
(
HDA_DATAREGS
+
1
,
cylinder
&
25
5
);
_out
(
HDA_DATAREGS
+
2
,
(
sector
>>
8
)
&
25
6
);
_out
(
HDA_DATAREGS
+
2
,
(
sector
>>
8
)
&
25
5
);
_out
(
HDA_DATAREGS
+
3
,
sector
&
25
6
);
_out
(
HDA_DATAREGS
+
3
,
sector
&
25
5
);
_out
(
HDA_CMDREG
,
CMD_SEEK
);
_out
(
HDA_CMDREG
,
CMD_SEEK
);
_sleep
(
HDA_IRQ
);
_sleep
(
HDA_IRQ
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tpfs/drive.h
+
2
−
2
View file @
28e4d289
...
@@ -6,9 +6,9 @@
...
@@ -6,9 +6,9 @@
#define HDA_CMDREG 0x3F6
/* registre de commande du disque maitre */
#define HDA_CMDREG 0x3F6
/* registre de commande du disque maitre */
#define HDA_DATAREGS 0x110
/* base des registres de données (r,r+1...r+15) */
#define HDA_DATAREGS 0x110
/* base des registres de données (r,r+1...r+15) */
#define HDA_IRQ 14
/* Interruption du disque */
#define HDA_IRQ 14
/* Interruption du disque */
#define CMD_SEEK 0x02
#define CMD_READ 0x04
#define HDA_SECTORSIZE 256
#define HDA_SECTORSIZE 256
#define HDA_MAXCYLINDER 16
/* Nombre de pistes du disque ma�tre */
#define HDA_MAXSECTOR 16
/* Nombre de secteurs du disque ma�tre */
void
dump
(
unsigned
char
*
buffer
,
void
dump
(
unsigned
char
*
buffer
,
unsigned
int
buffer_size
,
unsigned
int
buffer_size
,
...
...
This diff is collapsed.
Click to expand it.
tpfs/format_sector.c
0 → 100644
+
74
−
0
View file @
28e4d289
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
"hardware.h"
#include
"drive.h"
static
void
empty_it
()
{
return
;
}
void
format_sector
(
int
cylinder
,
int
sector
)
{
seek
(
cylinder
,
sector
);
_out
(
HDA_DATAREGS
,
0x0
);
_out
(
HDA_DATAREGS
+
1
,
1
);
_out
(
HDA_DATAREGS
+
2
,
0xFF
);
_out
(
HDA_DATAREGS
+
3
,
0x00
);
_out
(
HDA_DATAREGS
+
4
,
0xFF
);
_out
(
HDA_DATAREGS
+
5
,
0x00
);
_out
(
HDA_CMDREG
,
CMD_FORMAT
);
_sleep
(
HDA_IRQ
);
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
unsigned
int
i
;
int
cylinder
,
sector
;
/* init hardware */
if
(
init_hardware
(
"hwconfig.ini"
)
==
0
)
{
fprintf
(
stderr
,
"Error in hardware initialization
\n
"
);
exit
(
EXIT_FAILURE
);
}
/* Interreupt handlers */
for
(
i
=
0
;
i
<
16
;
i
++
)
IRQVECTOR
[
i
]
=
empty_it
;
/* Allows all IT */
_mask
(
1
);
if
(
argc
==
1
)
{
for
(
cylinder
=
0
;
cylinder
<
HDA_MAXCYLINDER
;
cylinder
++
)
{
for
(
sector
=
0
;
sector
<
HDA_MAXSECTOR
;
sector
++
)
format_sector
(
cylinder
,
sector
);
}
}
else
if
(
argc
==
2
&&
(
!
strcmp
(
argv
[
1
],
"-r"
)))
{
for
(
cylinder
=
HDA_MAXCYLINDER
-
1
;
cylinder
>
-
1
;
cylinder
--
)
{
for
(
sector
=
HDA_MAXSECTOR
-
1
;
sector
>
-
1
;
sector
--
)
format_sector
(
cylinder
,
sector
);
}
}
else
if
(
argc
==
3
)
{
format_sector
(
atoi
(
argv
[
1
]),
atoi
(
argv
[
2
]));
}
else
{
fprintf
(
stderr
,
"Usage: %s <cylinder> <sector>
\n
"
,
argv
[
0
]);
exit
(
EXIT_FAILURE
);
}
/* and exit! */
exit
(
EXIT_SUCCESS
);
}
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