Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dreamcast
DCInfo
Commits
f9139649
Commit
f9139649
authored
Feb 19, 2024
by
Donald Haase
Browse files
Move awesome print out. Update maple to use maple_response_t. Clean up printf debugging.
parent
3652a0cf
Changes
4
Hide whitespace changes
Inline
Side-by-side
DCInfo.c
View file @
f9139649
...
...
@@ -18,6 +18,25 @@ typedef struct info_mod {
} info_mod_t;
*/
/* My patented awesome data output that I did for MapleTest */
void
awesome_data_print
(
unsigned
char
*
data
,
unsigned
int
size
)
{
/* Bytes Per Line */
#define BPL 16
unsigned
int
i
=
0
;
unsigned
int
j
=
0
;
for
(
i
=
0
;
i
<
size
;
i
+=
BPL
)
{
printf
(
"Data+0x%.3x | "
,
i
);
for
(
j
=
0
;
j
<
BPL
;
j
++
)
printf
(
"%.2x "
,
data
[
i
+
j
]);
printf
(
"| "
);
for
(
j
=
0
;
j
<
BPL
;
j
++
)
printf
(
"%c"
,
isprint
(
data
[
i
+
j
])
?
data
[
i
+
j
]
:
' '
);
printf
(
"|
\n
"
);
}
}
int
main
(
void
)
{
...
...
DCInfo.h
View file @
f9139649
void
awesome_data_print
(
unsigned
char
*
data
,
unsigned
int
size
);
/*
Trying to set up a reusable simple way to protect a while loop that has
a risk of stalling. Replace a while(X) with wdt_timeout_while(X, time)
...
...
MapleTest.c
View file @
f9139649
...
...
@@ -11,7 +11,8 @@
*/
#include
<kos.h>
#include
<dc/maple.h>
#include
"DCInfo.h"
#include
"MapleTest.h"
/* The spec size of the maple receive buffer is 1024. A bit is added, just in case */
#define MAPLE_BUFF_SIZE (1024 + 32)
...
...
@@ -50,6 +51,7 @@ static void vbl_send_allinfo(int p, int u)
/* Setup our autodetect frame to probe at a new device */
maple_frame_init
(
&
dev
->
frame
);
dev
->
frame
.
cmd
=
MAPLE_COMMAND_ALLINFO
;
dev
->
frame
.
length
=
0
;
dev
->
frame
.
dst_port
=
p
;
dev
->
frame
.
dst_unit
=
u
;
dev
->
frame
.
callback
=
vbl_allinfo_callback
;
...
...
@@ -74,7 +76,6 @@ void print_devinfo(maple_devinfo_t *info)
fflush
(
stdout
);
}
#define BPL 16
/* Bytes to print per line */
/*
Get and print the data returned by the ALLINFO command,
if extra=0 do not print the Free Data
...
...
@@ -88,18 +89,18 @@ void print_devinfo(maple_devinfo_t *info)
void
print_device_allinfo
(
maple_device_t
*
dev
,
int
extra
)
{
unsigned
int
size
=
0
;
unsigned
int
i
=
0
;
unsigned
int
j
=
0
;
maple_response_t
*
resp
=
(
maple_response_t
*
)
recv_buff
;
if
(
dev
==
NULL
)
return
;
if
(
dev
==
NULL
)
return
;
/* Clear the old buffer */
memset
(
recv_buff
,
0
,
MAPLE_BUFF_SIZE
);
printf
(
"Trying to get the allinfo for device %c%c:
\n
"
,
'A'
+
(
dev
->
port
),
'0'
+
(
dev
->
unit
));
fflush
(
stdout
);
printf
(
"Trying to get the allinfo for device %c%c:
\n
"
,
'A'
+
(
dev
->
port
),
'0'
+
(
dev
->
unit
));
fflush
(
stdout
);
vbl_send_allinfo
((
dev
->
port
),
(
dev
->
unit
));
timer_spin_sleep
(
750
);
size
+=
(
recv_buff
[
3
]
*
4
);
size
=
(
resp
->
data_len
*
4
);
printf
(
"Recieved %d bytes of data. Here it is:
\n
"
,
size
);
fflush
(
stdout
);
print_devinfo
((
maple_devinfo_t
*
)
&
recv_buff
[
4
]);
...
...
@@ -109,16 +110,10 @@ void print_device_allinfo(maple_device_t *dev, int extra)
else
if
(
extra
==
3
)
size
=
MAPLE_BUFF_SIZE
;
/* Grab the max amount */
printf
(
"Extra data:
\n
"
);
/* Really disgusting loop to print out a pretty copy of the data first in hex then ascii (if it is) */
for
(
i
=
4
+
112
;
i
<
size
;
i
+=
BPL
)
{
printf
(
"Extra+0x%.3x | "
,
i
-
(
4
+
112
));
for
(
j
=
0
;
j
<
BPL
;
j
++
)
printf
(
"%.2x "
,
recv_buff
[
i
+
j
]);
printf
(
"| "
);
for
(
j
=
0
;
j
<
BPL
;
j
++
)
printf
(
"%c"
,
isprint
(
recv_buff
[
i
+
j
])
?
recv_buff
[
i
+
j
]
:
' '
);
printf
(
"
\n
"
);
}
/* Really disgusting loop to print out a pretty copy of the data first in hex then ascii (if it is) */
awesome_data_print
(
recv_buff
+
(
4
+
112
),
size
);
printf
(
"End of Extra data
\n\n
"
);
fflush
(
stdout
);
}
...
...
@@ -133,7 +128,7 @@ void print_all_device_allinfo(int extra)
printf
(
"Going to print info on all [%d] devices found:
\n
"
,
num
);
fflush
(
stdout
);
for
(;
i
<
num
;
i
++
)
print_device_allinfo
(
maple_enum_type
(
i
,
0xffffffff
),
extra
);
for
(;
i
<
num
;
i
++
)
print_device_allinfo
(
maple_enum_type
(
i
,
0xffffffff
),
extra
);
printf
(
"That's all the devices attached.
\n
"
);
fflush
(
stdout
);
}
gdinfo.c
View file @
f9139649
...
...
@@ -77,17 +77,14 @@ unsigned int gd_ATA_IDENTIFY_PACKET_DEV(unsigned short* out,unsigned int* out_si
unsigned
int
data_to_Read
;
*
out_size
=
0
;
printf
(
"First in ID PACKET
\n
"
);
//ST_BSY,ST_DRQ -> 0
gd_wait_stat
(
ST_BSY
|
ST_DRQ
,
0
);
printf
(
"2 in ID PACKET
\n
"
);
/* Need to test if this is where it breaks, waiting for the stat here or perhaps after the command is sent */
out8
(
GD_COMMAND_Write
,
ATA_IDENTIFY_PACKET_DEV
);
printf
(
"3 in ID PACKET
\n
"
);
/* Wait until the data bit is ready */
/* Wait until the data bit is ready
. USB-GDROM spins here forever.
*/
gd_wait_stat
(
ST_DRQ
,
ST_DRQ
);
printf
(
"4 in ID PACKET
\n
"
);
/* Check if data was prepared and is ready */
if
((
in8
(
GD_ALTSTAT_Read
)
&
ST_DRQ
)
==
0
)
...
...
@@ -211,27 +208,6 @@ void gd_REQ_MODE(unsigned short* out,unsigned int* out_size)
gd_spi_pio
(
&
cmd
,
out
,
out_size
);
}
/* My patented awesome data output that I did for MapleTest */
void
awesome_data_print
(
unsigned
char
*
data
,
unsigned
int
size
)
{
/* Bytes Per Line */
#define BPL 16
unsigned
int
i
=
0
;
unsigned
int
j
=
0
;
for
(
i
=
0
;
i
<
size
;
i
+=
BPL
)
{
printf
(
"Data+0x%.3x | "
,
i
);
for
(
j
=
0
;
j
<
BPL
;
j
++
)
printf
(
"%.2x "
,
data
[
i
+
j
]);
printf
(
"| "
);
for
(
j
=
0
;
j
<
BPL
;
j
++
)
printf
(
"%c"
,
isprint
(
data
[
i
+
j
])
?
data
[
i
+
j
]
:
' '
);
printf
(
"|
\n
"
);
}
}
void
gdinfo_print
(
void
)
{
...
...
@@ -259,9 +235,6 @@ void gdinfo_print(void)
printf
(
"Got %d bytes of data back
\n
"
,
size
);
awesome_data_print
(
REQMODE
,
size
);
/* Free the allocated memory */
free
(
GD_INFO
);
free
(
REQMODE
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment