dcload-ip with DHCP support!

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
Moopthehedgehog
DCEmu Freak
DCEmu Freak
Posts: 73
Joined: Wed Jan 05, 2011 4:25 pm
Has liked: 3 times
Been liked: 26 times

Re: dcload-ip with DHCP support!

Post by Moopthehedgehog » Wed Dec 04, 2019 11:43 am

Just updating the source. Changed the interface to read_pmctr to use an array passed by reference (I want to minimize 64-bit int usage where possible) and I changed the way the performance counters are read to assembly because I saw GCC putting an unconditional branch between reads of the high and low registers. It's not the delay slot either--it's literally mov.l first part, bra, nop, mov.l second part. :o

Even with that the perfcounters still run fast, although I found that sometimes, randomly, one of my two Dreamcasts will power on and decide to count cycles at 200MHz instead of at 11.96988 x 200MHz, so I really have no idea what's going on here. I haven't tested every last little thing (and I can't test the lan adapter stuff because I don't have one), but otherwise everything seems to be working here.

EDIT 12/5/2019: updated source

--Source removed, see GitHub for latest --
Last edited by Moopthehedgehog on Sat Dec 21, 2019 11:36 pm, edited 1 time in total.
I'm sure Aleron Ives feels weird with his postcount back to <10668
:D
User avatar
Moopthehedgehog
DCEmu Freak
DCEmu Freak
Posts: 73
Joined: Wed Jan 05, 2011 4:25 pm
Has liked: 3 times
Been liked: 26 times

Re: dcload-ip with DHCP support!

Post by Moopthehedgehog » Tue Dec 10, 2019 6:55 pm

On github now (with some updated source):
https://github.com/Moopthehedgehog/dcload-ip

Latest CDIs attached. Each zip file contains a version that uses either performance counter 1 or 2: take your pick. Mainly meant in the event that a dev needs to use one of them, dcload can just use the other. The perf counter is used as a non-invasive timer, so if you exit back to dcload it has a way of keeping track of whether or not the DHCP lease needs to be renewed.

In Discjuggler, I use Mode 2, block: 2048, and CD-DA. Checkboxes RAW Write and "add post-gap to 3rd party images." Also overburn if necessary (not needed here).

-- Removed attachments, GitHub has newer ones that solve the problem --
Last edited by Moopthehedgehog on Sat Dec 21, 2019 11:35 pm, edited 1 time in total.
I'm sure Aleron Ives feels weird with his postcount back to <10668
:D
User avatar
Moopthehedgehog
DCEmu Freak
DCEmu Freak
Posts: 73
Joined: Wed Jan 05, 2011 4:25 pm
Has liked: 3 times
Been liked: 26 times

Re: dcload-ip with DHCP support!

Post by Moopthehedgehog » Wed Dec 11, 2019 5:55 pm

I figured out the perf counter timing!
And I found a manual for them!
https://www.renesas.com/us/en/doc/produ ... sh7750.pdf - SuperH Family E10A-USB Emulator Additional Document for Users Manual (Supplementary Information on Using SH7750)
https://www.renesas.com/us/en/doc/produ ... h7750r.pdf - SuperH Family E10A-USB Emulator Additional Document for Users Manual (Supplementary Information on Using SH7750R)
I haven't tested the extra modes to be sure, but I think that the Dreamcast perf counters have all the modes of the SH7750R rather than the plain SH7750. These manuals come from this page: https://www.renesas.com/us/en/products/ ... #documents

The key is this formula: T= C x B / 24
Where T is time, C is count, and B is the time of one "bus clock" cycle

According to the Linux kernel, the Dreamcast's peripheral clock is 49876504 Hz, not 50MHz on the nose. Guess what? (49876504/50000000)*12 = 11.97.
But the Dreamcast's bus clock is 100 MHz, though if the peripheral clock is internal clock / 4, it would really be double that, so 99753008 Hz.
B is the time of one cycle, so invert that and T = C / (99753008 * 24).

I measured 1 second to be 2393976245 on the raw counter, and 2393976245 / (99753008 * 24) = 0.999599... or 1.000.
Working backwards from one seconds shows C to be 2394072192, which is a mere 0.005% off from my number. That's certainly well within manufacturing tolerances!

According to the documents there's a mode that uses one CPU cycle = 1 count, which would be ideal. I think it's one of the flags of the PMCR register, although when I used PMCR_CLKF it didn't change the countdown timer speed. Maybe it's a typo and sets the wrong bit? -- nope, it was me. Need to clear the bit, not set it. Woot!

In any case, I can stop losing sleep over this now, I think. :grin:
These users liked the author Moopthehedgehog for the post:
BB Hood
I'm sure Aleron Ives feels weird with his postcount back to <10668
:D
User avatar
Moopthehedgehog
DCEmu Freak
DCEmu Freak
Posts: 73
Joined: Wed Jan 05, 2011 4:25 pm
Has liked: 3 times
Been liked: 26 times

Re: dcload-ip with DHCP support!

Post by Moopthehedgehog » Tue Dec 31, 2019 6:36 pm

Just an update: It's DONE!!!
Just in time for New Year's!

See the GitHub page linked in the first post for the latest releases (there's one for each of the two performance counters).
I'm sure Aleron Ives feels weird with his postcount back to <10668
:D
User avatar
Moopthehedgehog
DCEmu Freak
DCEmu Freak
Posts: 73
Joined: Wed Jan 05, 2011 4:25 pm
Has liked: 3 times
Been liked: 26 times

Re: dcload-ip with DHCP support!

Post by Moopthehedgehog » Wed Jan 29, 2020 2:40 pm

Just an update, bumped it to version 1.1.1.

Made some major enhancements to the exception handler (in the event of an exception, dcload sends the regdump that is printed onscreen over the network now, and the exception handler actually works right), fixed video mode setup so that VGA isn't shifted up like crazy anymore and PAL 576i (aka PAL composite/Svideo) is now supported.

A couple of sneaky bugs were also squashed. Functionality-wise, I think at this point I might have fixed everything that was broken with dcload-ip. :o

I recommend everybody using dcload-ip upgrade to this version (as usual, CDIs are available in the "Releases" section of my repository).
These users liked the author Moopthehedgehog for the post:
BB Hood
I'm sure Aleron Ives feels weird with his postcount back to <10668
:D
Post Reply