PDA

View Full Version : Changing CPU speed via software



SpidersWeb
April 25th, 2012, 12:57 PM
So I have the APC AT and the Phoenix ROM keeps turning the turbo off on startup. Not a big deal but it got me curious, and gave me an excuse to learn a few things.
I can press CTRL+ALT+MINUS to change the speed and there is no physical jumper or switch. So it's definately achievable via a software call.

I should be able to make an option ROM to re-enable the turbo quite easily once I work the actual program out.

I looked at some Turbo XT BIOS code and references (even though it's an AT, the Turbo XT stuff was all I could actually find in my google searches), and found it was normal to use a couple of bits at Port 61H. But I read port 61H with the turbo on and off, and noticed no change - it's always 30H. I wrote a small assembly program to flick the bits on, and it set Port 61H correctly, but made no difference.

So beyond the Turbo XT clone generation was there a generic port/bit combo that flicked the turbo?

I remember having programs years ago that did this, but I can't for the life of me find one now, "speed.com" sits in my head.

sergey
April 25th, 2012, 01:09 PM
So I have the APC AT and the Phoenix ROM keeps turning the turbo off on startup. Not a big deal but it got me curious, and gave me an excuse to learn a few things.
I can press CTRL+ALT+MINUS to change the speed and there is no physical jumper or switch. So it's definately achievable via a software call.

I should be able to make an option ROM to re-enable the turbo quite easily once I work the actual program out.

I looked at some Turbo XT BIOS code and references (even though it's an AT, the Turbo XT stuff was all I could actually find in my google searches), and found it was normal to use a couple of bits at Port 61H. But I read port 61H with the turbo on and off, and noticed no change - it's always 30H. I wrote a small assembly program to flick the bits on, and it set Port 61H correctly, but made no difference.

So beyond the Turbo XT clone generation was there a generic port/bit combo that flicked the turbo?

I remember having programs years ago that did this, but I can't for the life of me find one now, "speed.com" sits in my head.

Most Turbo XT boards use bit #2 of port 61h to enable Turbo mode. So the algorithm is to read port 61h, set or reset bit #2, and write it back.

Thanks,
Sergey

DOS lives on!!
April 25th, 2012, 01:51 PM
Here ya go.

SpidersWeb
April 25th, 2012, 01:57 PM
Sergey - thanks, but as above, I tried applying the Turbo XT technique to the AT and it had no effect.
I read it mentioned 'bit 2' as well, but every example I found used XOR (or OR) 0000 0110b or 0000 0100b - unless binary is read b7 b6 b5 b4 b3 b2 b1 b0 ?

I also used debug's "i" command to read 61H with the turbo on and off and had no change in value.

DOS - thanks! I'll have a look when I get home!! If it works, I'll unassemble and edumicate my brain.

pearce_jj
April 25th, 2012, 02:01 PM
Bit 2 has a decimal value of 4 and would normally be written 04h. In binary it's 0000 0100.

sergey
April 25th, 2012, 02:15 PM
Bit 2 has a decimal value of 4 and would normally be written 04h. In binary it's 0000 0100.

Right, that is the second bit from the right, counting from zero. Here is the relevant code from my BIOS:

.turbo_off:
in al,port_b_reg
and al,0FBh ; clear bit 2 (turbo enable bit)
out port_b_reg,al
jmp keyboard_int_exit

.turbo_on:
in al,port_b_reg
or al,04h ; set bit 2 (turbo enable bit)
out port_b_reg,al
jmp keyboard_int_exit

Regarding AT boards - at least some of them used keyboard controller to turn Turbo on / off. In this case one of 8042 keyboard controller ports (pins) is connected to the turbo switch circuit. If I recall correctly, some keyboard controllers processed Turbo on/off keyboard sequence and toggled that output pin without CPU involvement. So that it worked even in case where software used its own keyboard interrupt handler (as many games did).
Also this might help (look for word 'turbo'): http://bochs.sourceforge.net/techspec/PORTS.LST

SpidersWeb
April 25th, 2012, 02:33 PM
Thanks for that much appreciated :) Brilliant resource.

I notice the 61h section mentions 8255 and XT only, and later down the list it says:

0068 ---- C&T chipsets, turbo mode control

So I think I'll need to watch 68h between turbo changes, if C&T stands for "Chips and Technologies" then that is the chipest it uses.

Edit: also 60h (Compaq and some AT)