Subject: Re: 2048 bytes blocks CDROMs

From: [email-masked] (Juergen Keil)
Date: 10 Mar 1994 20:02:44 GMT

In article <[email-masked]> aa@info-gtpp1
(Andre April) writes:

> I have a Sparcstation LX an want to add a CDROM. I also have a NEC
> Multispin 3Xi (CDR-500 I think). When I try to use it with my LX,
> I always get a message like "2048 bytes blocks unsupported".
> 
> Wasn't it a way to support it or are the 512 bytes ones only supported ?
> Answerbook don't mention differences between CDROMs.
> BTW, I use Solaris 2.3 if it can help.

Below is the procedure for booting (installing) SunOS 5.1 [SunOS 5.3]
from a Toshiba / NEC drive with 2K default block size that you could
try.  It works for a NEC CDR 84.1 drive (configured for SCSI-II mode);
I havn't tested it with the newer NEC drives yet. The patch can also
be applied to an already installed system.

====================================================================

For installing Solaris 2.1 [or Solaris 2.3] from a Toshiba XM-3[34]01 or
a NEC CDR 84.1 CDROM drive you can use the following procedure:

  1. At the monitor prompt, boot kadb from the Solaris 2.1 [2.3] CD
     (Btw. you need at least Boot Prom revision 2.4, older Boot
     Proms can't boot from a 2048 bytes/sector CDROM drive)

	ok boot cdrom kadb -d

     The monitor loads kadb an says something like

	Rebooting with command: cdrom kadb -d
	Boot device: /sbus/esp..../sd@6,0:c  File and Args: kadb -d
	kadb:

  2. At the kadb: prompt press <RETURN>, this will load
     /kernel/unix from the cd.

	kadb: /kernel/unix
	Size: xxx+yyy+zzz bytes
	/kernel/unix loaded - wwwwww bytes used
	kadb[0]:

  3. At the kadb[0]: prompt, set a breakpoint at main+10 and start the
     kernel:

	kadb[0]: main+10:b
	kadb[0]: :c

     The kernel starts and loads all required device drivers (esp. the
     harddisk driver, which we'll want to patch). Then it will stop at
     our  breakpoint.  The following messages appear on the screen:

	SunOS Release 5.x Version ....
	  .
	  .
	  .
	breakpoint	main+10: call clkstart
	kadb[0]:

	[SunOS 5.3 has a 'call callb_init' at main+10]

  4. Now the harddisk driver (which also supports cdrom drives) is loaded
     and we can install the patch: Again at the kadb[0]: prompt type

     For SunOS 5.1 use:

	kadb[0]: sr_mode_select+24?W 2d054400 ec27bff8

     And for SunOS 5.3:

	kadb[0]: sr_mode_select+20?W 2f054400 ee27bff8

     Before patching, you might want to verify the original code: Type

	kadb[0]: sr_mode_select?i

     and some more returns. The original code should look like this:

     SunOS 5.1:

	sr_mode_select:			save	%sp, -0x68, %sp
	sr_mode_select+4:		mov	0x24, %o0
	sr_mode_select+8:		call	sr_mode_select + 8
	sr_mode_select+0xc:		clr	%o1
	sr_mode_select+0x10:		mov	%o0, %i5
	sr_mode_select+0x14:		add	%fp, -0x8, %o0
	sr_mode_select+0x18:		call	sr_mode_select + 0x18
	sr_mode_select+0x1c:		mov	0x6, %o1
	sr_mode_select+0x20:		stb	%i2, [%fp - 0x4]
	sr_mode_select+0x24:		mov	0x15, %l6
	sr_mode_select+0x28:		stb	%l6, [%fp - 0x8]
	sr_mode_select+0x2c:		add	%fp, -0x8, %l7

     After the patch is installed, we have

	sr_mode_select+0x24:		sethi	%hi(0x15100000), %l6
	sr_mode_select+0x28:		st	%l6, [%fp - 0x8]

     And the same for SunOS 5.3, here the code is a bit different:

	sr_mode_select: 		save    %sp, -0x68, %sp
	sr_mode_select+4:               mov     0x24, %o0
	sr_mode_select+8:               call    kmem_zalloc
	sr_mode_select+0xc:             clr     %o1
	sr_mode_select+0x10:            mov     %o0, %i5
	sr_mode_select+0x14:            add     %fp, -0x8, %o0
	sr_mode_select+0x18:            call    blkclr
	sr_mode_select+0x1c:            mov     0x6, %o1
	sr_mode_select+0x20:            mov     0x15, %l7
	sr_mode_select+0x24:            stb     %l7, [%fp - 0x8]
	sr_mode_select+0x28:            stb     %i2, [%fp - 0x4]
	sr_mode_select+0x2c:            mov     0x3, %o0

     After the patch is installed, we have

	sr_mode_select+0x20:            sethi   %hi(0x15100000), %l7
	sr_mode_select+0x24:            st      %l7, [%fp - 0x8]

  5. Continue the installation with :c at the kadb[0]: prompt

	kadb[0]: :c

The kernel will complain once about a data overrun on the first access
to the CDROM, but should have no further problems with the Toshiba/NEC
CDROM drive.

The same patch can be used on an already installed Solaris 2.1 [2.3] system:
As root, type:

[SunOS 5.1]
	# cp /kernel/drv/sd /kernel/drv/sd.orig
	# adb -w /kernel/drv/sd
	sr_mode_select+24?W 2d054400 ec27bff8
	$q
	#

[SunOS 5.3]
	# cp /kernel/drv/sd /kernel/drv/sd.orig
	# adb -w /kernel/drv/sd
	sr_mode_select+20?W 2f054400 ee27bff8
	$q
	#

and reboot.

With this patch installed you can access mode1 data cds and audio cds
(with x_cdplayer, workman).  To make use of the other features of the
Toshiba/NEC drives (reading XA type discs (Electronic Book CDs, Photo
CDs), multisession discs (PhotoCD) or the digital audio samples from
audio tracks) you'll need a third party scsi target driver (e.g our's
:-), though.
-- 
Juergen Keil          [email-masked] ...!{uunet,mcsun}!unido!tools!jk