diff mbox

[RFC,v4,03/25] m68k/atari: Move Atari-specific code out of drivers/char/nvram.c

Message ID 20150712102528.107134628@telegraphics.com.au (mailing list archive)
State Superseded
Headers show

Commit Message

Finn Thain July 12, 2015, 10:25 a.m. UTC
Move the m68k-specific code elsewhere to make the driver generic.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---

BTW, I didn't change the SCSI ID location in NVRAM. This code says 16
whereas atari_scsi says 14. Which one is correct?

Changes since v3:
- Move the vmode fix to a separate patch as requested by Geert.

---
 arch/m68k/atari/Makefile |    2 
 arch/m68k/atari/nvram.c  |  255 ++++++++++++++++++++++++++++++++++++++++++
 drivers/char/nvram.c     |  280 +++++------------------------------------------
 3 files changed, 292 insertions(+), 245 deletions(-)

Comments

Andreas Schwab July 13, 2015, 6:13 p.m. UTC | #1
Finn Thain <fthain@telegraphics.com.au> writes:

> BTW, I didn't change the SCSI ID location in NVRAM. This code says 16
> whereas atari_scsi says 14. Which one is correct?

I think atari_scsi is wrong.  The best source I could find
(http://www.gratifiant.com/nvram-falcon-t561185) places it after the
video mode byte, thus at byte 16.

Andreas.
Finn Thain July 14, 2015, 8:17 a.m. UTC | #2
On Mon, 13 Jul 2015, Andreas Schwab wrote:

> Finn Thain <fthain@telegraphics.com.au> writes:
> 
> > BTW, I didn't change the SCSI ID location in NVRAM. This code says 16 
> > whereas atari_scsi says 14. Which one is correct?
> 
> I think atari_scsi is wrong.  The best source I could find 
> (http://www.gratifiant.com/nvram-falcon-t561185) places it after the 
> video mode byte, thus at byte 16.

Thanks for that. BTW, I googled a phrase from that page and found this one
  http://toshyp.atari.org/en/004009.html
which may be closer to the source.

I'll send a patch if someone can offer to test such a change to atari_scsi 
(or merely confirm that the SCSI ID setting in TOS does not match this_id 
given in dmesg).
Geert Uytterhoeven July 14, 2015, 8:23 a.m. UTC | #3
On Tue, Jul 14, 2015 at 10:17 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> On Mon, 13 Jul 2015, Andreas Schwab wrote:
>> Finn Thain <fthain@telegraphics.com.au> writes:
>> > BTW, I didn't change the SCSI ID location in NVRAM. This code says 16
>> > whereas atari_scsi says 14. Which one is correct?
>>
>> I think atari_scsi is wrong.  The best source I could find
>> (http://www.gratifiant.com/nvram-falcon-t561185) places it after the
>> video mode byte, thus at byte 16.
>
> Thanks for that. BTW, I googled a phrase from that page and found this one
>   http://toshyp.atari.org/en/004009.html
> which may be closer to the source.

Hence "int" is 16-bits in all those references?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Andreas Schwab July 14, 2015, 8:33 a.m. UTC | #4
Geert Uytterhoeven <geert@linux-m68k.org> writes:

> On Tue, Jul 14, 2015 at 10:17 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
>> On Mon, 13 Jul 2015, Andreas Schwab wrote:
>>> Finn Thain <fthain@telegraphics.com.au> writes:
>>> > BTW, I didn't change the SCSI ID location in NVRAM. This code says 16
>>> > whereas atari_scsi says 14. Which one is correct?
>>>
>>> I think atari_scsi is wrong.  The best source I could find
>>> (http://www.gratifiant.com/nvram-falcon-t561185) places it after the
>>> video mode byte, thus at byte 16.
>>
>> Thanks for that. BTW, I googled a phrase from that page and found this one
>>   http://toshyp.atari.org/en/004009.html
>> which may be closer to the source.
>
> Hence "int" is 16-bits in all those references?

Yes, TOS uses 16-bit ints throughout.

Andreas.
Michael Schmitz July 22, 2015, 3:52 a.m. UTC | #5
Hi Finn,

I'm afraid I cannot test anything on Atari hardware at present - my 
Falcon ate it's IDE disk partition table with all the fun that entails. 
Haven't even begun to try and recover that yet.

If you send a patch I could build a kernel and send that to Christian 
for testing (if he's got his Falcon up and running - might be a tad warm 
in the attic for that, in fact).

Cheers,

     Michael


Am 14.07.15 um 20:17 schrieb Finn Thain:
> On Mon, 13 Jul 2015, Andreas Schwab wrote:
>
>> Finn Thain <fthain@telegraphics.com.au> writes:
>>
>>> BTW, I didn't change the SCSI ID location in NVRAM. This code says 16
>>> whereas atari_scsi says 14. Which one is correct?
>> I think atari_scsi is wrong.  The best source I could find
>> (http://www.gratifiant.com/nvram-falcon-t561185) places it after the
>> video mode byte, thus at byte 16.
> Thanks for that. BTW, I googled a phrase from that page and found this one
>    http://toshyp.atari.org/en/004009.html
> which may be closer to the source.
>
> I'll send a patch if someone can offer to test such a change to atari_scsi
> (or merely confirm that the SCSI ID setting in TOS does not match this_id
> given in dmesg).
>
Finn Thain July 22, 2015, 4:22 a.m. UTC | #6
On Wed, 22 Jul 2015, Michael Schmitz wrote:

> Hi Finn,
> 
> I'm afraid I cannot test anything on Atari hardware at present - my 
> Falcon ate it's IDE disk partition table with all the fun that entails. 

That doesn't sound good.

> Haven't even begun to try and recover that yet.
> 
> If you send a patch I could build a kernel and send that to Christian 
> for testing (if he's got his Falcon up and running - might be a tad warm 
> in the attic for that, in fact).

Anyone with a suitable Atari, i.e. ATARIHW_PRESENT(TT_CLK), who can boot 
both TOS and Linux could resolve the question. (Perhaps with an emulator?)

Any old kernel binary would do, since atari_scsi should print either 
"HOSTID=n" or "this_id n" at startup.

If n doesn't agree with what TOS says about the host's SCSI ID, then I 
think a trivial patch is safe enough. Especially if cat /proc/driver/nvram 
produces a "SCSI host ID : m" that does agree with TOS.

Regards,
Finn

> 
> Cheers,
> 
>     Michael
> 
> 
> Am 14.07.15 um 20:17 schrieb Finn Thain:
> > On Mon, 13 Jul 2015, Andreas Schwab wrote:
> >
> > > Finn Thain <fthain@telegraphics.com.au> writes:
> > >
> > > > BTW, I didn't change the SCSI ID location in NVRAM. This code says 16
> > > > whereas atari_scsi says 14. Which one is correct?
> > > I think atari_scsi is wrong.  The best source I could find
> > > (http://www.gratifiant.com/nvram-falcon-t561185) places it after the
> > > video mode byte, thus at byte 16.
> > Thanks for that. BTW, I googled a phrase from that page and found this one
> >    http://toshyp.atari.org/en/004009.html
> > which may be closer to the source.
> >
> > I'll send a patch if someone can offer to test such a change to atari_scsi
> > (or merely confirm that the SCSI ID setting in TOS does not match this_id
> > given in dmesg).
> >
>
Christian T. Steigies July 22, 2015, 2:32 p.m. UTC | #7
On Wed, Jul 22, 2015 at 02:22:21PM +1000, Finn Thain wrote:
> 
> On Wed, 22 Jul 2015, Michael Schmitz wrote:
> 
> > Hi Finn,
> > 
> > I'm afraid I cannot test anything on Atari hardware at present - my 
> > Falcon ate it's IDE disk partition table with all the fun that entails. 
> 
> That doesn't sound good.
> 
> > Haven't even begun to try and recover that yet.
> > 
> > If you send a patch I could build a kernel and send that to Christian 
> > for testing (if he's got his Falcon up and running - might be a tad warm 
> > in the attic for that, in fact).
> 
> Anyone with a suitable Atari, i.e. ATARIHW_PRESENT(TT_CLK), who can boot 
> both TOS and Linux could resolve the question. (Perhaps with an emulator?)

The Falcon is not powered on currently but it should still work. What should
I test?

> Any old kernel binary would do, since atari_scsi should print either 
> "HOSTID=n" or "this_id n" at startup.
> 
> If n doesn't agree with what TOS says about the host's SCSI ID, then I 
> think a trivial patch is safe enough. Especially if cat /proc/driver/nvram 
> produces a "SCSI host ID : m" that does agree with TOS.

Christian
Michael Schmitz July 22, 2015, 11:46 p.m. UTC | #8
Hi Christian,

if I understand Finn right, he needs the SCSI host ID reported for the
Falcon SCSI chip, as found in this kernel log line:

scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq
15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { },
options { REAL_DMA SUPPORT_TAGS }

(see this_id; output from one of my ARAnyM instances, kernel 3.19rc6).
Also, the SCSI host ID reported by cat /proc/drivers/nvram (also 7, in
my case)

TOS reports the SCSI host ID during boot (when scannig for bootable
disks) IIRC. There may be some control panel to view the NVRAM
settings as well (stuff like default video mode was accessible from
the CT60 control panel so the SCSI host ID might be there as well).

Cheers,

  Michael



On Thu, Jul 23, 2015 at 2:32 AM, Christian T. Steigies <cts@debian.org> wrote:
> On Wed, Jul 22, 2015 at 02:22:21PM +1000, Finn Thain wrote:
>>
>> On Wed, 22 Jul 2015, Michael Schmitz wrote:
>>
>> > Hi Finn,
>> >
>> > I'm afraid I cannot test anything on Atari hardware at present - my
>> > Falcon ate it's IDE disk partition table with all the fun that entails.
>>
>> That doesn't sound good.
>>
>> > Haven't even begun to try and recover that yet.
>> >
>> > If you send a patch I could build a kernel and send that to Christian
>> > for testing (if he's got his Falcon up and running - might be a tad warm
>> > in the attic for that, in fact).
>>
>> Anyone with a suitable Atari, i.e. ATARIHW_PRESENT(TT_CLK), who can boot
>> both TOS and Linux could resolve the question. (Perhaps with an emulator?)
>
> The Falcon is not powered on currently but it should still work. What should
> I test?
>
>> Any old kernel binary would do, since atari_scsi should print either
>> "HOSTID=n" or "this_id n" at startup.
>>
>> If n doesn't agree with what TOS says about the host's SCSI ID, then I
>> think a trivial patch is safe enough. Especially if cat /proc/driver/nvram
>> produces a "SCSI host ID : m" that does agree with TOS.
>
> Christian
Finn Thain July 23, 2015, 12:49 a.m. UTC | #9
On Thu, 23 Jul 2015, Michael Schmitz wrote:

> Hi Christian,
> 
> if I understand Finn right, he needs the SCSI host ID reported for the 
> Falcon SCSI chip, as found in this kernel log line:

What I'd really like is a regression test for this patch series. The SCSI 
host ID issue is a separate one; these patches won't fix that bug.

> 
> scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 
> 15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, 
> options { REAL_DMA SUPPORT_TAGS }
> 
> (see this_id; output from one of my ARAnyM instances, kernel 3.19rc6). 
> Also, the SCSI host ID reported by cat /proc/drivers/nvram (also 7, in 
> my case)

This seems inconclusive to me. Perhaps if you were to change a setting in 
TOS such that the two values became unequal...

> 
> TOS reports the SCSI host ID during boot (when scannig for bootable 
> disks) IIRC. There may be some control panel to view the NVRAM settings 
> as well (stuff like default video mode was accessible from the CT60 
> control panel so the SCSI host ID might be there as well).

Can that be done in Aranym also?
Christian T. Steigies July 23, 2015, 9:21 a.m. UTC | #10
On Wed, Jul 22, 2015 at 02:22:21PM +1000, Finn Thain wrote:
> 
> Anyone with a suitable Atari, i.e. ATARIHW_PRESENT(TT_CLK), who can boot 
> both TOS and Linux could resolve the question. (Perhaps with an emulator?)
> 
> Any old kernel binary would do, since atari_scsi should print either 
> "HOSTID=n" or "this_id n" at startup.
> 
> If n doesn't agree with what TOS says about the host's SCSI ID, then I 
> think a trivial patch is safe enough. Especially if cat /proc/driver/nvram 
> produces a "SCSI host ID : m" that does agree with TOS.

root@garkin:~>cat /proc/hardware 
Model:          Atari Falcon
System Memory:  522752K
        510 MB at 0x01000000 (alternate RAM)
Detected hardware:
        Falcon Shifter
        Programmable Sound Generator
        PCM 8 Bit Sound
        CODEC Sound
        SCSI Controller NCR5380 (Falcon style)
        IDE Interface
        8/16 Mhz Switch for FDC
        Multi Function Peripheral MFP 68901
        Serial Communications Controller SCC 8530
        Paddle Interface
        DMA Controller for SCC
        Clock Chip MC146818A
        Blitter
        DSP56001 processor

root@garkin:~>dmesg |grep SCSI
[    0.000000] Atari hardware found: VIDEL STDMA-SCSI ST_MFP YM2149 PCM CODEC DSP56K SCC_DMA SCC ANALOG_JOY BLITTER IDE TT_CLK FDC_SPEED 
[    0.410000] SCSI subsystem initialized
[    0.850000] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    4.230000] Atari SCSI: resetting the SCSI bus... done
[    6.750000] scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, options { REAL_DMA SUPPORT_TAGS } 

root@garkin:~>cat /proc/driver/nvram
Checksum status  : not valid
Boot preference  : 0xff (undefined)
SCSI arbitration : on
SCSI host ID     : 7
OS language      : 255 (undefined)
Keyboard language: 255 (undefined)
Date format      : 7 (undefined), 24h clock
Boot delay       : 255s
Video mode       : 4 colors, 40 columns, TV NTSC monitor
                   no overscan, compat. mode off


Let me know if you need more info.

Christian
Michael Schmitz July 24, 2015, 2:56 a.m. UTC | #11
Hi Christian,

here's what Finn asked me to run as tests:

# dmesg | grep this_id > nvram.out
# cat /proc/driver/nvram >> nvram.out
# hexdump -C /dev/nvram >> nvram.out
# cp /dev/nvram /tmp/nvram
# cp /tmp/nvram /dev/nvram
# md5sum /dev/nvram /tmp/nvram >> nvram.out

What you sent so far looks OK. I've tested the change of SCSI ID
(using EmuTOS) along with a trivial patch to atari_scsi.c (replace
offset 14 by 16) and the driver now uses the stored ID properly. I'll
sent kernels to test Finn's NVRAM patch for regression ASAP.

Thanks for your offer of help!

Cheers,

  Michael


On Thu, Jul 23, 2015 at 9:21 PM, Christian T. Steigies <cts@debian.org> wrote:
> On Wed, Jul 22, 2015 at 02:22:21PM +1000, Finn Thain wrote:
>>
>> Anyone with a suitable Atari, i.e. ATARIHW_PRESENT(TT_CLK), who can boot
>> both TOS and Linux could resolve the question. (Perhaps with an emulator?)
>>
>> Any old kernel binary would do, since atari_scsi should print either
>> "HOSTID=n" or "this_id n" at startup.
>>
>> If n doesn't agree with what TOS says about the host's SCSI ID, then I
>> think a trivial patch is safe enough. Especially if cat /proc/driver/nvram
>> produces a "SCSI host ID : m" that does agree with TOS.
>
> root@garkin:~>cat /proc/hardware
> Model:          Atari Falcon
> System Memory:  522752K
>         510 MB at 0x01000000 (alternate RAM)
> Detected hardware:
>         Falcon Shifter
>         Programmable Sound Generator
>         PCM 8 Bit Sound
>         CODEC Sound
>         SCSI Controller NCR5380 (Falcon style)
>         IDE Interface
>         8/16 Mhz Switch for FDC
>         Multi Function Peripheral MFP 68901
>         Serial Communications Controller SCC 8530
>         Paddle Interface
>         DMA Controller for SCC
>         Clock Chip MC146818A
>         Blitter
>         DSP56001 processor
>
> root@garkin:~>dmesg |grep SCSI
> [    0.000000] Atari hardware found: VIDEL STDMA-SCSI ST_MFP YM2149 PCM CODEC DSP56K SCC_DMA SCC ANALOG_JOY BLITTER IDE TT_CLK FDC_SPEED
> [    0.410000] SCSI subsystem initialized
> [    0.850000] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
> [    4.230000] Atari SCSI: resetting the SCSI bus... done
> [    6.750000] scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, options { REAL_DMA SUPPORT_TAGS }
>
> root@garkin:~>cat /proc/driver/nvram
> Checksum status  : not valid
> Boot preference  : 0xff (undefined)
> SCSI arbitration : on
> SCSI host ID     : 7
> OS language      : 255 (undefined)
> Keyboard language: 255 (undefined)
> Date format      : 7 (undefined), 24h clock
> Boot delay       : 255s
> Video mode       : 4 colors, 40 columns, TV NTSC monitor
>                    no overscan, compat. mode off
>
>
> Let me know if you need more info.
>
> Christian
Christian T. Steigies July 24, 2015, 7:07 p.m. UTC | #12
Moin,
On Fri, Jul 24, 2015 at 02:56:26PM +1200, Michael Schmitz wrote:
> 
> here's what Finn asked me to run as tests:
> 
> # dmesg | grep this_id > nvram.out
> # cat /proc/driver/nvram >> nvram.out
> # hexdump -C /dev/nvram >> nvram.out
> # cp /dev/nvram /tmp/nvram
> # cp /tmp/nvram /dev/nvram
> # md5sum /dev/nvram /tmp/nvram >> nvram.out

It seems I could successfully reset the nvram under TOS with bootconf.
Here is nvram.out, using the new kernel you sent me:

root@garkin:~>uname -a
Linux garkin 4.2.0-rc2-atari-269994-gc1e9d12 #327 Fri Jul 24 19:34:44 NZST 2015 m68k GNU/Linux

PS it seems LVM is working with this kernel as well!

Christian


[    7.000000] scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, options { REAL_DMA SUPPORT_TAGS } 
Checksum status  : valid
Boot preference  : unspecified
SCSI arbitration : on
SCSI host ID     : 7
OS language      : English (US)
Keyboard language: English (UK)
Date format      : YYÿDDÿMM, 24h clock
Boot delay       : 10s
Video mode       : ?? colors, 80 columns, VGA PAL monitor
                   overscan, compat. mode off, line doubling
00000000  00 00 ff ff ff ff 00 03  13 ff 0a ff ff ff 01 7f  |................|
00000010  87 ff 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  e1 1e                                             |..|
00000032
3b5801864975cf23bcacb52f648e74cc  /dev/nvram
3b5801864975cf23bcacb52f648e74cc  /tmp/nvram
Finn Thain July 25, 2015, 12:35 a.m. UTC | #13
On Fri, 24 Jul 2015, Christian T. Steigies wrote:

> Moin,
> On Fri, Jul 24, 2015 at 02:56:26PM +1200, Michael Schmitz wrote:
> > 
> > here's what Finn asked me to run as tests:
> > 
> > # dmesg | grep this_id > nvram.out
> > # cat /proc/driver/nvram >> nvram.out
> > # hexdump -C /dev/nvram >> nvram.out
> > # cp /dev/nvram /tmp/nvram
> > # cp /tmp/nvram /dev/nvram
> > # md5sum /dev/nvram /tmp/nvram >> nvram.out
> 
> It seems I could successfully reset the nvram under TOS with bootconf.
> Here is nvram.out, using the new kernel you sent me:
> 
> root@garkin:~>uname -a
> Linux garkin 4.2.0-rc2-atari-269994-gc1e9d12 #327 Fri Jul 24 19:34:44 NZST 2015 m68k GNU/Linux
> 
> PS it seems LVM is working with this kernel as well!
> 
> Christian
> 
> 
> [    7.000000] scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, options { REAL_DMA SUPPORT_TAGS } 
> Checksum status  : valid
> Boot preference  : unspecified
> SCSI arbitration : on
> SCSI host ID     : 7
> OS language      : English (US)
> Keyboard language: English (UK)
> Date format      : YY?DD?MM, 24h clock
> Boot delay       : 10s
> Video mode       : ?? colors, 80 columns, VGA PAL monitor
>                    overscan, compat. mode off, line doubling
> 00000000  00 00 ff ff ff ff 00 03  13 ff 0a ff ff ff 01 7f  |................|
> 00000010  87 ff 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 00000030  e1 1e                                             |..|
> 00000032
> 3b5801864975cf23bcacb52f648e74cc  /dev/nvram
> 3b5801864975cf23bcacb52f648e74cc  /tmp/nvram


Thanks for helping with this, Christian. I'll add your name in "Tested-by" 
tags on the relevant patches. These are rudimentary tests but combined 
with my own testing on m68k, ppc32 and x86, coverage is quite good. Some 
testing on ppc64 is still lacking though.
Michael Schmitz July 25, 2015, 12:51 a.m. UTC | #14
Hi Christian,

good to know this worked - for the record (Finn), this is the kernel 
with Finn's patch applied.

I'll build the missing LVM module so Christian can run the tests on the 
unpatched kernel as well.

Thanks for testing!

     Michael


Am 25.07.15 um 07:07 schrieb Christian T. Steigies:
> Moin,
> On Fri, Jul 24, 2015 at 02:56:26PM +1200, Michael Schmitz wrote:
>> here's what Finn asked me to run as tests:
>>
>> # dmesg | grep this_id > nvram.out
>> # cat /proc/driver/nvram >> nvram.out
>> # hexdump -C /dev/nvram >> nvram.out
>> # cp /dev/nvram /tmp/nvram
>> # cp /tmp/nvram /dev/nvram
>> # md5sum /dev/nvram /tmp/nvram >> nvram.out
> It seems I could successfully reset the nvram under TOS with bootconf.
> Here is nvram.out, using the new kernel you sent me:
>
> root@garkin:~>uname -a
> Linux garkin 4.2.0-rc2-atari-269994-gc1e9d12 #327 Fri Jul 24 19:34:44 NZST 2015 m68k GNU/Linux
>
> PS it seems LVM is working with this kernel as well!
>
> Christian
>
>
> [    7.000000] scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, options { REAL_DMA SUPPORT_TAGS }
> Checksum status  : valid
> Boot preference  : unspecified
> SCSI arbitration : on
> SCSI host ID     : 7
> OS language      : English (US)
> Keyboard language: English (UK)
> Date format      : YYÿDDÿMM, 24h clock
> Boot delay       : 10s
> Video mode       : ?? colors, 80 columns, VGA PAL monitor
>                     overscan, compat. mode off, line doubling
> 00000000  00 00 ff ff ff ff 00 03  13 ff 0a ff ff ff 01 7f  |................|
> 00000010  87 ff 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 00000030  e1 1e                                             |..|
> 00000032
> 3b5801864975cf23bcacb52f648e74cc  /dev/nvram
> 3b5801864975cf23bcacb52f648e74cc  /tmp/nvram
Michael Ellerman July 25, 2015, 1 a.m. UTC | #15
On Sat, 2015-07-25 at 10:35 +1000, Finn Thain wrote:
> On Fri, 24 Jul 2015, Christian T. Steigies wrote:
> > 3b5801864975cf23bcacb52f648e74cc  /dev/nvram
> > 3b5801864975cf23bcacb52f648e74cc  /tmp/nvram
> 
> Thanks for helping with this, Christian. I'll add your name in "Tested-by" 
> tags on the relevant patches. These are rudimentary tests but combined 
> with my own testing on m68k, ppc32 and x86, coverage is quite good. Some 
> testing on ppc64 is still lacking though.

*Blush*

I'll try and get to it next week promise!

cheers
Finn Thain July 25, 2015, 7:27 a.m. UTC | #16
On Sat, 25 Jul 2015, Michael Schmitz wrote:

> Hi Christian,
> 
> good to know this worked - for the record (Finn), this is the kernel 
> with Finn's patch applied.

That was v5 of this patch series. I will send that out to the lists now. 
It has some minor changes that relate to powerpc.

Thanks for your help with this, Michael.

Finn

> 
> I'll build the missing LVM module so Christian can run the tests on the 
> unpatched kernel as well.
> 
> Thanks for testing!
> 
>     Michael
> 
>
Finn Thain July 25, 2015, 7:38 a.m. UTC | #17
On Sat, 25 Jul 2015, Michael Ellerman wrote:

> On Sat, 2015-07-25 at 10:35 +1000, Finn Thain wrote:
> > 
> > Thanks for helping with this, Christian. I'll add your name in 
> > "Tested-by" tags on the relevant patches. These are rudimentary tests 
> > but combined with my own testing on m68k, ppc32 and x86, coverage is 
> > quite good. Some testing on ppc64 is still lacking though.
> 
> *Blush*
> 
> I'll try and get to it next week promise!

That would be a great help. Unfortunately I don't have any ppc64 hardware. 
I wish ;-)
Michael Schmitz July 26, 2015, 1:02 a.m. UTC | #18
Hi Finn,

For the sake of completeness: further testing on ARAnyM shows no 
difference between original and patched kernel in the NVRAM proc and 
diff outputs:

scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 
15, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, 
options { REAL_DMA SUPPORT_TAGS }
Checksum status  : valid
Boot preference  : unspecified
SCSI arbitration : on
SCSI host ID     : 7
OS language      : English (US)
Keyboard language: English (US)
Date format      : DD.MM.YY, 24h clock
Boot delay       : 32s
Video mode       : 4 colors, 40 columns, TV NTSC monitor
                    no overscan, compat. mode off
00000000  00 00 00 00 00 00 00 00  11 2e 20 01 ff 00 00 3b |.......... 
....;|
00000010  87 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 
|................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 
|................|
00000030  de 21                                             |.!|
00000032
d640bf7d535b54e39582fabdc016d7ca  /dev/nvram
d640bf7d535b54e39582fabdc016d7ca  /tmp/nvram

Happy to help ...

Cheers,

     Michael

> On Sat, 25 Jul 2015, Michael Schmitz wrote:
>
>> Hi Christian,
>>
>> good to know this worked - for the record (Finn), this is the kernel
>> with Finn's patch applied.
> That was v5 of this patch series. I will send that out to the lists now.
> It has some minor changes that relate to powerpc.
>
> Thanks for your help with this, Michael.
>
> Finn
>
>> I'll build the missing LVM module so Christian can run the tests on the
>> unpatched kernel as well.
>>
>> Thanks for testing!
>>
>>      Michael
>>
>>
Finn Thain July 26, 2015, 1:19 a.m. UTC | #19
On Sun, 26 Jul 2015, Michael Schmitz wrote:

> Hi Finn,
> 
> For the sake of completeness: further testing on ARAnyM shows no difference
> between original and patched kernel in the NVRAM proc and diff outputs:
> 
> scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 15,
> can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, flags { }, options {
> REAL_DMA SUPPORT_TAGS }
> Checksum status  : valid
> Boot preference  : unspecified
> SCSI arbitration : on
> SCSI host ID     : 7
> OS language      : English (US)
> Keyboard language: English (US)
> Date format      : DD.MM.YY, 24h clock
> Boot delay       : 32s
> Video mode       : 4 colors, 40 columns, TV NTSC monitor
>                    no overscan, compat. mode off
> 00000000  00 00 00 00 00 00 00 00  11 2e 20 01 ff 00 00 3b |.......... ....;|
> 00000010  87 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
> 00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
> 00000030  de 21                                            |.!|
> 00000032

I'd expect to see a change in the Video mode above, because of patch 2.

With 0x3B in byte 15, I'd expect the patched kernel to produce something 
similar to Christian's /proc/driver/nvram results.
Finn Thain July 26, 2015, 1:37 a.m. UTC | #20
On Sat, 25 Jul 2015, Michael Ellerman wrote:

> On Sat, 2015-07-25 at 10:35 +1000, Finn Thain wrote:
> > 
> > ... These are rudimentary tests but combined with my own testing on 
> > m68k, ppc32 and x86, coverage is quite good. Some testing on ppc64 is 
> > still lacking though.

Here's some code I wrote some time ago to help me test these patches, 
maybe it will help others (though independent results may be more 
valuable...)


-- -- 8< -- -- 


#!/bin/sh
set -e -u -x
temp=`mktemp /root/nvram.XXXX`
test -f "$temp"
cat /proc/version
if ! test -e /dev/nvram ; then
    mknod /dev/nvram c 10 144
fi
ls -l /dev/nvram
if test -c /dev/nvram ; then
    cp /dev/nvram "$temp"
    hexdump -C "$temp"
    cp /dev/zero /dev/nvram || true
    hexdump -C /dev/nvram
    cp "$temp" /dev/nvram
    hexdump -C /dev/nvram
fi


-- -- 8< -- -- 


#include <stdio.h>
#include <sys/ioctl.h>
#include <errno.h>

#if defined(__powerpc__)
#include <asm/nvram.h>
#elif defined(__i386__) || defined(__mc68020__)
#include <linux/nvram.h>
#endif

int main(void) {
        int result, i;
        FILE *f;

        f = fopen("/dev/nvram", "r+");
        if (!f) {
                perror("fopen");
                return 1;
        }

#if defined(__powerpc__)
        result = ioctl(fileno(f), IOC_NVRAM_SYNC);
	fprintf(stderr, "ioctl IOC_NVRAM_SYNC: result %d, errno %m\n", result);

        for (i = 0; i <= 8; ++i) {
                int arg = i;

                result = ioctl(fileno(f), IOC_NVRAM_GET_OFFSET, (long)&arg);
		fprintf(stderr, "ioctl IOC_NVRAM_GET_OFFSET: i %d, result %d, offset %d, errno %m\n", i, result, arg);
        }
#elif defined(__i386__) || defined(__mc68020__)
        result = ioctl(fileno(f), NVRAM_INIT);
	fprintf(stderr, "ioctl NVRAM_INIT: result %d, errno %m\n", result);

        result = ioctl(fileno(f), NVRAM_SETCKS);
	fprintf(stderr, "ioctl NVRAM_SETCKS: result %d, errno %m\n", result);
#endif

        return 0;
}
diff mbox

Patch

Index: linux/arch/m68k/atari/nvram.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux/arch/m68k/atari/nvram.c	2015-07-12 20:24:56.000000000 +1000
@@ -0,0 +1,255 @@ 
+/*
+ * CMOS/NV-RAM driver for Atari. Adapted from drivers/char/nvram.c.
+ * Copyright (C) 1997 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
+ * idea by and with help from Richard Jelinek <rj@suse.de>
+ * Portions copyright (c) 2001,2002 Sun Microsystems (thockin@sun.com)
+ * Further contributions from Cesar Barros, Erik Gilling, Tim Hockin and
+ * Wim Van Sebroeck.
+ */
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/mc146818rtc.h>
+#include <linux/module.h>
+#include <linux/nvram.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+#include <asm/atarihw.h>
+#include <asm/atariints.h>
+
+#define NVRAM_BYTES		50
+
+/* It is worth noting that these functions all access bytes of general
+ * purpose memory in the NVRAM - that is to say, they all add the
+ * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not
+ * know about the RTC cruft.
+ */
+
+/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with
+ * rtc_lock held. Due to the index-port/data-port design of the RTC, we
+ * don't want two different things trying to get to it at once. (e.g. the
+ * periodic 11 min sync from kernel/time/ntp.c vs. this driver.)
+ */
+
+unsigned char __nvram_read_byte(int i)
+{
+	return CMOS_READ(NVRAM_FIRST_BYTE + i);
+}
+
+unsigned char nvram_read_byte(int i)
+{
+	unsigned long flags;
+	unsigned char c;
+
+	spin_lock_irqsave(&rtc_lock, flags);
+	c = __nvram_read_byte(i);
+	spin_unlock_irqrestore(&rtc_lock, flags);
+	return c;
+}
+EXPORT_SYMBOL(nvram_read_byte);
+
+/* This races nicely with trying to read with checksum checking */
+void __nvram_write_byte(unsigned char c, int i)
+{
+	CMOS_WRITE(c, NVRAM_FIRST_BYTE + i);
+}
+
+void nvram_write_byte(unsigned char c, int i)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&rtc_lock, flags);
+	__nvram_write_byte(c, i);
+	spin_unlock_irqrestore(&rtc_lock, flags);
+}
+
+/* On Ataris, the checksum is over all bytes except the checksum bytes
+ * themselves; these are at the very end.
+ */
+#define ATARI_CKS_RANGE_START	0
+#define ATARI_CKS_RANGE_END	47
+#define ATARI_CKS_LOC		48
+
+int __nvram_check_checksum(void)
+{
+	int i;
+	unsigned char sum = 0;
+
+	for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
+		sum += __nvram_read_byte(i);
+	return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) &&
+	       (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff));
+}
+
+int nvram_check_checksum(void)
+{
+	unsigned long flags;
+	int rv;
+
+	spin_lock_irqsave(&rtc_lock, flags);
+	rv = __nvram_check_checksum();
+	spin_unlock_irqrestore(&rtc_lock, flags);
+	return rv;
+}
+EXPORT_SYMBOL(nvram_check_checksum);
+
+static void __nvram_set_checksum(void)
+{
+	int i;
+	unsigned char sum = 0;
+
+	for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
+		sum += __nvram_read_byte(i);
+	__nvram_write_byte(~sum, ATARI_CKS_LOC);
+	__nvram_write_byte(sum, ATARI_CKS_LOC + 1);
+}
+
+#ifdef CONFIG_PROC_FS
+static struct {
+	unsigned char val;
+	char *name;
+} boot_prefs[] = {
+	{ 0x80, "TOS" },
+	{ 0x40, "ASV" },
+	{ 0x20, "NetBSD (?)" },
+	{ 0x10, "Linux" },
+	{ 0x00, "unspecified" },
+};
+
+static char *languages[] = {
+	"English (US)",
+	"German",
+	"French",
+	"English (UK)",
+	"Spanish",
+	"Italian",
+	"6 (undefined)",
+	"Swiss (French)",
+	"Swiss (German)",
+};
+
+static char *dateformat[] = {
+	"MM%cDD%cYY",
+	"DD%cMM%cYY",
+	"YY%cMM%cDD",
+	"YY%cDD%cMM",
+	"4 (undefined)",
+	"5 (undefined)",
+	"6 (undefined)",
+	"7 (undefined)",
+};
+
+static char *colors[] = {
+	"2", "4", "16", "256", "65536", "??", "??", "??"
+};
+
+static void atari_nvram_proc_read(unsigned char *nvram, struct seq_file *seq,
+                                  void *offset)
+{
+	int checksum;
+	int i;
+	unsigned vmode;
+
+	spin_lock_irq(&rtc_lock);
+	checksum = __nvram_check_checksum();
+	spin_unlock_irq(&rtc_lock);
+
+	seq_printf(seq, "Checksum status  : %svalid\n", checksum ? "" : "not ");
+
+	seq_puts(seq, "Boot preference  : ");
+	for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i)
+		if (nvram[1] == boot_prefs[i].val) {
+			seq_printf(seq, "%s\n", boot_prefs[i].name);
+			break;
+		}
+	if (i < 0)
+		seq_printf(seq, "0x%02x (undefined)\n", nvram[1]);
+
+	seq_printf(seq, "SCSI arbitration : %s\n",
+	           (nvram[16] & 0x80) ? "on" : "off");
+	seq_puts(seq, "SCSI host ID     : ");
+	if (nvram[16] & 0x80)
+		seq_printf(seq, "%d\n", nvram[16] & 7);
+	else
+		seq_puts(seq, "n/a\n");
+
+	if (!MACH_IS_FALCON)
+		return;
+
+	seq_puts(seq, "OS language      : ");
+	if (nvram[6] < ARRAY_SIZE(languages))
+		seq_printf(seq, "%s\n", languages[nvram[6]]);
+	else
+		seq_printf(seq, "%u (undefined)\n", nvram[6]);
+	seq_puts(seq, "Keyboard language: ");
+	if (nvram[7] < ARRAY_SIZE(languages))
+		seq_printf(seq, "%s\n", languages[nvram[7]]);
+	else
+		seq_printf(seq, "%u (undefined)\n", nvram[7]);
+	seq_puts(seq, "Date format      : ");
+	seq_printf(seq, dateformat[nvram[8] & 7],
+	           nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/');
+	seq_printf(seq, ", %dh clock\n", nvram[8] & 16 ? 24 : 12);
+	seq_puts(seq, "Boot delay       : ");
+	if (nvram[10] == 0)
+		seq_puts(seq, "default");
+	else
+		seq_printf(seq, "%ds%s\n", nvram[10],
+		           nvram[10] < 8 ? ", no memory test" : "");
+
+	vmode = (nvram[14] << 8) | nvram[15];
+	seq_printf(seq,
+	           "Video mode       : %s colors, %d columns, %s %s monitor\n",
+	           colors[vmode & 7], vmode & 8 ? 80 : 40,
+	           vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC");
+	seq_printf(seq,
+	           "                   %soverscan, compat. mode %s%s\n",
+	           vmode & 64 ? "" : "no ", vmode & 128 ? "on" : "off",
+	           vmode & 256 ?
+	           (vmode & 16 ? ", line doubling" : ", half screen") : "");
+}
+
+static int nvram_proc_read(struct seq_file *seq, void *offset)
+{
+	unsigned char contents[NVRAM_BYTES];
+	int i;
+
+	spin_lock_irq(&rtc_lock);
+	for (i = 0; i < NVRAM_BYTES; ++i)
+		contents[i] = __nvram_read_byte(i);
+	spin_unlock_irq(&rtc_lock);
+
+	atari_nvram_proc_read(contents, seq, offset);
+
+	return 0;
+}
+
+static int nvram_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, nvram_proc_read, NULL);
+}
+
+static const struct file_operations nvram_proc_fops = {
+	.owner		= THIS_MODULE,
+	.open		= nvram_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int __init atari_nvram_init(void)
+{
+	if (!(MACH_IS_ATARI && ATARIHW_PRESENT(TT_CLK)))
+		return -ENODEV;
+
+	if (!proc_create("driver/nvram", 0, NULL, &nvram_proc_fops)) {
+		pr_err("nvram: can't create /proc/driver/nvram\n");
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+device_initcall(atari_nvram_init);
+#endif /* CONFIG_PROC_FS */
Index: linux/arch/m68k/atari/Makefile
===================================================================
--- linux.orig/arch/m68k/atari/Makefile	2015-07-12 20:24:54.000000000 +1000
+++ linux/arch/m68k/atari/Makefile	2015-07-12 20:24:56.000000000 +1000
@@ -6,3 +6,5 @@  obj-y		:= config.o time.o debug.o ataint
 			atasound.o stram.o
 
 obj-$(CONFIG_ATARI_KBD_CORE)	+= atakeyb.o
+
+obj-$(CONFIG_NVRAM:m=y)		+= nvram.o
Index: linux/drivers/char/nvram.c
===================================================================
--- linux.orig/drivers/char/nvram.c	2015-07-12 20:24:55.000000000 +1000
+++ linux/drivers/char/nvram.c	2015-07-12 20:24:56.000000000 +1000
@@ -21,13 +21,6 @@ 
  * ioctl(NVRAM_SETCKS) (doesn't change contents, just makes checksum valid
  * again; use with care!)
  *
- * This file also provides some functions for other parts of the kernel that
- * want to access the NVRAM: nvram_{read,write,check_checksum,set_checksum}.
- * Obviously this can be used only if this driver is always configured into
- * the kernel and is not a module. Since the functions are used by some Atari
- * drivers, this is the case on the Atari.
- *
- *
  * 	1.1	Cesar Barros: SMP locking fixes
  * 		added changelog
  * 	1.2	Erik Gilling: Cobalt Networks support
@@ -39,64 +32,6 @@ 
 
 #include <linux/module.h>
 #include <linux/nvram.h>
-
-#define PC		1
-#define ATARI		2
-
-/* select machine configuration */
-#if defined(CONFIG_ATARI)
-#  define MACH ATARI
-#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__)  /* and ?? */
-#  define MACH PC
-#else
-#  error Cannot build nvram driver for this machine configuration.
-#endif
-
-#if MACH == PC
-
-/* RTC in a PC */
-#define CHECK_DRIVER_INIT()	1
-
-/* On PCs, the checksum is built only over bytes 2..31 */
-#define PC_CKS_RANGE_START	2
-#define PC_CKS_RANGE_END	31
-#define PC_CKS_LOC		32
-#define NVRAM_BYTES		(128-NVRAM_FIRST_BYTE)
-
-#define mach_check_checksum	pc_check_checksum
-#define mach_set_checksum	pc_set_checksum
-#define mach_proc_infos		pc_proc_infos
-
-#endif
-
-#if MACH == ATARI
-
-/* Special parameters for RTC in Atari machines */
-#include <asm/atarihw.h>
-#include <asm/atariints.h>
-#define RTC_PORT(x)		(TT_RTC_BAS + 2*(x))
-#define CHECK_DRIVER_INIT()	(MACH_IS_ATARI && ATARIHW_PRESENT(TT_CLK))
-
-#define NVRAM_BYTES		50
-
-/* On Ataris, the checksum is over all bytes except the checksum bytes
- * themselves; these are at the very end */
-#define ATARI_CKS_RANGE_START	0
-#define ATARI_CKS_RANGE_END	47
-#define ATARI_CKS_LOC		48
-
-#define mach_check_checksum	atari_check_checksum
-#define mach_set_checksum	atari_set_checksum
-#define mach_proc_infos		atari_proc_infos
-
-#endif
-
-/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with
- * rtc_lock held. Due to the index-port/data-port design of the RTC, we
- * don't want two different things trying to get to it at once. (e.g. the
- * periodic 11 min sync from kernel/time/ntp.c vs. this driver.)
- */
-
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
@@ -119,12 +54,9 @@  static int nvram_open_mode;	/* special o
 #define NVRAM_WRITE		1 /* opened for writing (exclusive) */
 #define NVRAM_EXCL		2 /* opened with O_EXCL */
 
-static int mach_check_checksum(void);
-static void mach_set_checksum(void);
-
 #ifdef CONFIG_PROC_FS
-static void mach_proc_infos(unsigned char *contents, struct seq_file *seq,
-								void *offset);
+static void pc_nvram_proc_read(unsigned char *contents, struct seq_file *seq,
+                               void *offset);
 #endif
 
 /*
@@ -138,6 +70,14 @@  static void mach_proc_infos(unsigned cha
  * know about the RTC cruft.
  */
 
+#define NVRAM_BYTES		(128 - NVRAM_FIRST_BYTE)
+
+/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with
+ * rtc_lock held. Due to the index-port/data-port design of the RTC, we
+ * don't want two different things trying to get to it at once. (e.g. the
+ * periodic 11 min sync from kernel/time/ntp.c vs. this driver.)
+ */
+
 unsigned char __nvram_read_byte(int i)
 {
 	return CMOS_READ(NVRAM_FIRST_BYTE + i);
@@ -173,9 +113,22 @@  void nvram_write_byte(unsigned char c, i
 }
 EXPORT_SYMBOL(nvram_write_byte);
 
+/* On PCs, the checksum is built only over bytes 2..31 */
+#define PC_CKS_RANGE_START	2
+#define PC_CKS_RANGE_END	31
+#define PC_CKS_LOC		32
+
 int __nvram_check_checksum(void)
 {
-	return mach_check_checksum();
+	int i;
+	unsigned short sum = 0;
+	unsigned short expect;
+
+	for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
+		sum += __nvram_read_byte(i);
+	expect = __nvram_read_byte(PC_CKS_LOC)<<8 |
+	    __nvram_read_byte(PC_CKS_LOC+1);
+	return (sum & 0xffff) == expect;
 }
 EXPORT_SYMBOL(__nvram_check_checksum);
 
@@ -193,7 +146,13 @@  EXPORT_SYMBOL(nvram_check_checksum);
 
 static void __nvram_set_checksum(void)
 {
-	mach_set_checksum();
+	int i;
+	unsigned short sum = 0;
+
+	for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
+		sum += __nvram_read_byte(i);
+	__nvram_write_byte(sum >> 8, PC_CKS_LOC);
+	__nvram_write_byte(sum & 0xff, PC_CKS_LOC + 1);
 }
 
 #if 0
@@ -396,7 +355,7 @@  static int nvram_proc_read(struct seq_fi
 		contents[i] = __nvram_read_byte(i);
 	spin_unlock_irq(&rtc_lock);
 
-	mach_proc_infos(contents, seq, offset);
+	pc_nvram_proc_read(contents, seq, offset);
 
 	return 0;
 }
@@ -443,10 +402,6 @@  static int __init nvram_init(void)
 {
 	int ret;
 
-	/* First test whether the driver should init at all */
-	if (!CHECK_DRIVER_INIT())
-		return -ENODEV;
-
 	ret = misc_register(&nvram_dev);
 	if (ret) {
 		printk(KERN_ERR "nvram: can't misc_register on minor=%d\n",
@@ -476,36 +431,6 @@  static void __exit nvram_cleanup_module(
 module_init(nvram_init);
 module_exit(nvram_cleanup_module);
 
-/*
- * Machine specific functions
- */
-
-#if MACH == PC
-
-static int pc_check_checksum(void)
-{
-	int i;
-	unsigned short sum = 0;
-	unsigned short expect;
-
-	for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
-		sum += __nvram_read_byte(i);
-	expect = __nvram_read_byte(PC_CKS_LOC)<<8 |
-	    __nvram_read_byte(PC_CKS_LOC+1);
-	return (sum & 0xffff) == expect;
-}
-
-static void pc_set_checksum(void)
-{
-	int i;
-	unsigned short sum = 0;
-
-	for (i = PC_CKS_RANGE_START; i <= PC_CKS_RANGE_END; ++i)
-		sum += __nvram_read_byte(i);
-	__nvram_write_byte(sum >> 8, PC_CKS_LOC);
-	__nvram_write_byte(sum & 0xff, PC_CKS_LOC + 1);
-}
-
 #ifdef CONFIG_PROC_FS
 
 static char *floppy_types[] = {
@@ -520,8 +445,8 @@  static char *gfx_types[] = {
 	"monochrome",
 };
 
-static void pc_proc_infos(unsigned char *nvram, struct seq_file *seq,
-								void *offset)
+static void pc_nvram_proc_read(unsigned char *nvram, struct seq_file *seq,
+                               void *offset)
 {
 	int checksum;
 	int type;
@@ -582,143 +507,8 @@  static void pc_proc_infos(unsigned char
 
 	return;
 }
-#endif
-
-#endif /* MACH == PC */
-
-#if MACH == ATARI
-
-static int atari_check_checksum(void)
-{
-	int i;
-	unsigned char sum = 0;
-
-	for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
-		sum += __nvram_read_byte(i);
-	return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) &&
-	    (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff));
-}
-
-static void atari_set_checksum(void)
-{
-	int i;
-	unsigned char sum = 0;
 
-	for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
-		sum += __nvram_read_byte(i);
-	__nvram_write_byte(~sum, ATARI_CKS_LOC);
-	__nvram_write_byte(sum, ATARI_CKS_LOC + 1);
-}
-
-#ifdef CONFIG_PROC_FS
-
-static struct {
-	unsigned char val;
-	char *name;
-} boot_prefs[] = {
-	{ 0x80, "TOS" },
-	{ 0x40, "ASV" },
-	{ 0x20, "NetBSD (?)" },
-	{ 0x10, "Linux" },
-	{ 0x00, "unspecified" }
-};
-
-static char *languages[] = {
-	"English (US)",
-	"German",
-	"French",
-	"English (UK)",
-	"Spanish",
-	"Italian",
-	"6 (undefined)",
-	"Swiss (French)",
-	"Swiss (German)"
-};
-
-static char *dateformat[] = {
-	"MM%cDD%cYY",
-	"DD%cMM%cYY",
-	"YY%cMM%cDD",
-	"YY%cDD%cMM",
-	"4 (undefined)",
-	"5 (undefined)",
-	"6 (undefined)",
-	"7 (undefined)"
-};
-
-static char *colors[] = {
-	"2", "4", "16", "256", "65536", "??", "??", "??"
-};
-
-static void atari_proc_infos(unsigned char *nvram, struct seq_file *seq,
-								void *offset)
-{
-	int checksum = nvram_check_checksum();
-	int i;
-	unsigned vmode;
-
-	seq_printf(seq, "Checksum status  : %svalid\n", checksum ? "" : "not ");
-
-	seq_printf(seq, "Boot preference  : ");
-	for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) {
-		if (nvram[1] == boot_prefs[i].val) {
-			seq_printf(seq, "%s\n", boot_prefs[i].name);
-			break;
-		}
-	}
-	if (i < 0)
-		seq_printf(seq, "0x%02x (undefined)\n", nvram[1]);
-
-	seq_printf(seq, "SCSI arbitration : %s\n",
-	    (nvram[16] & 0x80) ? "on" : "off");
-	seq_printf(seq, "SCSI host ID     : ");
-	if (nvram[16] & 0x80)
-		seq_printf(seq, "%d\n", nvram[16] & 7);
-	else
-		seq_printf(seq, "n/a\n");
-
-	/* the following entries are defined only for the Falcon */
-	if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON)
-		return;
-
-	seq_printf(seq, "OS language      : ");
-	if (nvram[6] < ARRAY_SIZE(languages))
-		seq_printf(seq, "%s\n", languages[nvram[6]]);
-	else
-		seq_printf(seq, "%u (undefined)\n", nvram[6]);
-	seq_printf(seq, "Keyboard language: ");
-	if (nvram[7] < ARRAY_SIZE(languages))
-		seq_printf(seq, "%s\n", languages[nvram[7]]);
-	else
-		seq_printf(seq, "%u (undefined)\n", nvram[7]);
-	seq_printf(seq, "Date format      : ");
-	seq_printf(seq, dateformat[nvram[8] & 7],
-	    nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/');
-	seq_printf(seq, ", %dh clock\n", nvram[8] & 16 ? 24 : 12);
-	seq_printf(seq, "Boot delay       : ");
-	if (nvram[10] == 0)
-		seq_printf(seq, "default");
-	else
-		seq_printf(seq, "%ds%s\n", nvram[10],
-		    nvram[10] < 8 ? ", no memory test" : "");
-
-	vmode = (nvram[14] << 8) | nvram[15];
-	seq_printf(seq,
-	    "Video mode       : %s colors, %d columns, %s %s monitor\n",
-	    colors[vmode & 7],
-	    vmode & 8 ? 80 : 40,
-	    vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC");
-	seq_printf(seq, "                   %soverscan, compat. mode %s%s\n",
-	    vmode & 64 ? "" : "no ",
-	    vmode & 128 ? "on" : "off",
-	    vmode & 256 ?
-	    (vmode & 16 ? ", line doubling" : ", half screen") : "");
-
-	return;
-}
-#endif
-
-#endif /* MACH == ATARI */
+#endif /* CONFIG_PROC_FS */
 
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_MISCDEV(NVRAM_MINOR);