mtd/docboot doc_bootstub.h, 1.1, 1.2 doc_bootstub.S, 1.2, 1.3 makespl.c, 1.1, 1.2

Kalev Lember kalev at infradead.org
Mon Aug 2 14:41:31 EDT 2004


Update of /home/cvs/mtd/docboot
In directory phoenix.infradead.org:/tmp/cvs-serv7267

Modified Files:
	doc_bootstub.h doc_bootstub.S makespl.c 
Log Message:
* add support to the Millennium Plus
* add an option to build a BIOS extension
* add an option to force specific DOC address


Index: doc_bootstub.h
===================================================================
RCS file: /home/cvs/mtd/docboot/doc_bootstub.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- doc_bootstub.h	9 Jul 2004 16:28:02 -0000	1.1
+++ doc_bootstub.h	2 Aug 2004 18:41:28 -0000	1.2
@@ -49,15 +49,46 @@
 
 #define DoC_2k_CDSN_IO 0x1800
 
-	
-	
+
+#define DoC_Mplus_NOP			0x1002
+#define DoC_Mplus_AliasResolution	0x1004
+#define DoC_Mplus_DOCControl		0x1006
+#define DoC_Mplus_AccessStatus		0x1008
+#define DoC_Mplus_DeviceSelect		0x1008
+#define DoC_Mplus_Configuration		0x100a
+#define DoC_Mplus_OutputControl		0x100c
+#define DoC_Mplus_FlashControl		0x1020
+#define DoC_Mplus_FlashSelect 		0x1022
+#define DoC_Mplus_FlashCmd		0x1024
+#define DoC_Mplus_FlashAddress		0x1026
+#define DoC_Mplus_FlashData0		0x1028
+#define DoC_Mplus_FlashData1		0x1029
+#define DoC_Mplus_ReadPipeInit		0x102a
+#define DoC_Mplus_LastDataRead		0x102c
+#define DoC_Mplus_LastDataRead1		0x102d
+#define DoC_Mplus_WritePipeTerm 	0x102e
+#define DoC_Mplus_ECCSyndrome0		0x1040
+#define DoC_Mplus_ECCSyndrome1		0x1041
+#define DoC_Mplus_ECCSyndrome2		0x1042
+#define DoC_Mplus_ECCSyndrome3		0x1043
+#define DoC_Mplus_ECCSyndrome4		0x1044
+#define DoC_Mplus_ECCSyndrome5		0x1045
+#define DoC_Mplus_ECCConf 		0x1046
+#define DoC_Mplus_Toggle		0x1046
+#define DoC_Mplus_DownloadStatus	0x1074
+#define DoC_Mplus_CtrlConfirm		0x1076
+#define DoC_Mplus_Power			0x1fff
+
+
 #define DOC_MODE_RESET 0
 #define DOC_MODE_NORMAL 1
 #define DOC_MODE_RESERVED1 2
 #define DOC_MODE_RESERVED2 3
 
-#define DOC_MODE_MDWREN 4
-#define DOC_MODE_CLR_ERR 0x80
+#define DOC_MODE_CLR_ERR 	0x80
+#define DOC_MODE_RST_LAT	0x10
+#define DOC_MODE_BDECT		0x08
+#define DOC_MODE_MDWREN 	0x04
 
 #define DOC_ChipID_Doc2k 0x20
 #define DOC_ChipID_DocMil 0x30
@@ -70,23 +101,35 @@
 #define CDSN_CTRL_CLE 2
 #define CDSN_CTRL_CE 1
 
-	
+#define DOC_FLASH_CE		0x80
+#define DOC_FLASH_WP		0x40
+
 #define NAND_CMD_READ0 0
 #define NAND_CMD_READ1 1
 #define NAND_CMD_READOOB 0x50
 #define NAND_CMD_RESET 0xff
 
 	/* Some macros to make it obvious what we're accessing */
-#define BXREG DoC_CDSNControl
+#define BXREG	DoC_ChipID
 
-#define BX_ChipID		-4(%bx)
-#define BX_DOCControl		-2(%bx)
-#define BX_CDSNControl		(%bx)
-#define BX_ConfigurationInput	24(%bx)
-#define BX_ReadPipeInit		25(%bx)
-#define BX_WritePipeTerm	26(%bx)
-#define BX_LastDataRead		27(%bx)
-#define BX_NOP			28(%bx)
+#define BX_ChipID		(%bx)
+#define BX_DOCControl		2(%bx)
+#define BX_CDSNControl		4(%bx)
+#define BX_ConfigurationInput	28(%bx)
+#define BX_ReadPipeInit		29(%bx)
+#define BX_WritePipeTerm	30(%bx)
+#define BX_LastDataRead		31(%bx)
+#define BX_NOP			32(%bx)
+
+#define BX_Mplus_NOP		2(%bx)
+#define BX_Mplus_DOCControl	6(%bx)
+#define BX_Mplus_FlashControl	32(%bx)
+#define BX_Mplus_FlashSelect	34(%bx)
+#define BX_Mplus_FlashCmd	36(%bx)
+#define BX_Mplus_FlashAddress	38(%bx)
+#define BX_Mplus_ReadPipeInit	42(%bx)
+#define BX_Mplus_WritePipeTerm	46(%bx)
+#define BX_Mplus_CtrlConfirm	118(%bx)
 
 #define SIREG DoC_M_CDSN_IO
 #define SI_CDSN_IO		(%si)
@@ -96,3 +139,9 @@
 
 #define CHECKSUM_LOCATION (512-6)
 #define SETUP_SECTS_LOCATION 497
+
+#define DOC_BIOS_HOOK 0x19
+
+/* #define DOC_ADDRESS	0xc800 */
+/* #define BIOS_EXTENSION */
+/* #define MILPLUS */

Index: doc_bootstub.S
===================================================================
RCS file: /home/cvs/mtd/docboot/doc_bootstub.S,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- doc_bootstub.S	12 Jul 2004 19:18:38 -0000	1.2
+++ doc_bootstub.S	2 Aug 2004 18:41:29 -0000	1.3
@@ -4,6 +4,8 @@
  *
  *  Author: Dan Brown <dan_brown at ieee.org>
  *
+ *  Diskonchip Millennium Plus support by Kalev Lember <kalev at smartlink.ee>
+ *
  *  Portions taken from the DOC Grub bootloader by
  *          David Woodhouse <dwmw2 at infradead.org>
  *
@@ -43,16 +45,23 @@
 	 * DS will be the segment of the DOC itself.
 	 */
 
+#ifndef DOC_ADDRESS
 		/* Store the DiskOnChip segment */
 	movw	%ds, %cs:doc_seg
+#endif
+#ifdef BIOS_EXTENSION
+       .byte	0x55, 0xAA	/* BIOS extension signature */
+       .byte	0x02		/* BIOS extension size in 512 byte blocks */
 
+	/* BIOS will call far _start + 3 */
+#endif
 	cld
 		/* Test for multiple loads due to aliased ROM addresses.  If
 		   the code pointed to by the interrupt vector is identical to
 		   our code, just return. */
 	xorw	%dx, %dx
 	movw	%dx, %ds
-	movw	0x0062, %es
+	movw	(DOC_BIOS_HOOK * 4), %es
 	pushw	%cs
 	popw	%ds
 	xorw	%di, %di
@@ -64,8 +73,8 @@
 
 	/* What we need to do is:
 	   1. Check the current end-of-memory in the BIOS
-	   2. Reduce it by the amount of memory we need for our INT 18h 
-	   3. Return, and wait for our INT 18h to be called.
+	   2. Reduce it by the amount of memory we need for our INT 18h/19h 
+	   3. Return, and wait for our INT 18h/19h to be called.
 	*/
 
 	MSG(spl_string)
@@ -85,9 +94,9 @@
 	shlw	$6,%ax
 	movw	%ax,%es
 
-		/* Set up our shiny new INT 18h handler */
-	movw	%ax,0x0062
-	movw	$int18,0x0060
+		/* Set up our shiny new INT 18h/19h handler */
+	movw	%ax,(DOC_BIOS_HOOK * 4 + 2)
+	movw	$handler,(DOC_BIOS_HOOK * 4)
 
 		/* Copy ourself into the new segment we've just reserved */
 	movw	$0x200, %cx
@@ -101,7 +110,7 @@
 skip_install:
 	lret	
 
-/* The actual int18 handler does three things:
+/* The actual int 18h/19h handler does three things:
    1) Copy the real-mode kernel from the DOC into the same 64k memory segment
       originally used by the MSYS IPL to store the 0x3000 bytes of SPL (on the
       theory that we already know it's safe to use).
@@ -112,7 +121,7 @@
       supposed to set.  Then jump to the real-mode kernel.
  */
 
-int18:
+handler:
 	pushw	%cs
 	popw	%ds
 	MSG(loading_string)
@@ -139,13 +148,21 @@
 	movw	$BXREG, %bx
 	movw	$SIREG, %si
 
-		/* Reset DiskOnChip */
+		/* Enable the DiskOnChip ASIC */
+#ifdef MILPLUS
+	movb	$(DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT), BX_Mplus_DOCControl
+	movb	$~(DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT), BX_Mplus_CtrlConfirm
+
+		/* Assert ChipEnable and WriteProtect */
+	movb	$(DOC_FLASH_CE | DOC_FLASH_WP), BX_Mplus_FlashSelect
+#else
 	movb	$DOC_MODE_CLR_ERR + DOC_MODE_MDWREN + DOC_MODE_NORMAL, BX_DOCControl
 	movb	$DOC_MODE_CLR_ERR + DOC_MODE_MDWREN + DOC_MODE_NORMAL, BX_DOCControl
-	
+
 		/* Flash command:	Reset */
 	movb	$NAND_CMD_RESET, %al
 	call	doc_cmd
+#endif
 
 	xorw	%di, %di
 	movw	$0x20, %dx	/* scan from second eraseblock */
@@ -241,9 +258,27 @@
 nextpage:
 	popw	%di
 doc_readpage:
+#ifdef MILPLUS
+		/* Flash command:	Reset */
+	movb	$NAND_CMD_RESET, %al
+	call	doc_cmd
+#endif
 		/* Flash command:	Read0 */
 	movb	$NAND_CMD_READ0, %al
 	call	doc_cmd
+#ifdef MILPLUS
+	movb	$0, BX_Mplus_FlashAddress
+	movb	%dl, BX_Mplus_FlashAddress
+	movb	%dh, BX_Mplus_FlashAddress
+		/* Terminate the write pipeline */
+	movb	$0, BX_Mplus_WritePipeTerm
+	movb	$0, BX_Mplus_WritePipeTerm
+		/* Deassert ALE */
+	movb	$0, BX_Mplus_FlashControl
+	call	doc_wait
+	testb	$0, BX_Mplus_ReadPipeInit
+	testb	$0, BX_Mplus_ReadPipeInit
+#else
 	movb	$CDSN_CTRL_WP + CDSN_CTRL_ALE + CDSN_CTRL_CE, BX_CDSNControl
 	movb	$0, SI_CDSN_IO
 	movb	%dl, SI_CDSN_IO
@@ -258,6 +293,7 @@
 notbigchip:
 	call	doc_wait
 	testb	$0, BX_ReadPipeInit
+#endif
 	movw	$0x208, %cx	/* Read page + 8 bytes OOB */
 	pushw	%di
 rploop:
@@ -274,6 +310,28 @@
 
                 /* doc_cmd:      Send a command to the flash chip */
 doc_cmd:
+#ifdef MILPLUS
+		/* Send the command to the flash */
+	movb	%al, BX_Mplus_FlashCmd
+		/* Terminate the write pipeline */
+	movb	$0, BX_Mplus_WritePipeTerm
+	movb	$0, BX_Mplus_WritePipeTerm
+	/* fall through... */
+
+                /* doc_wait:     Wait for the DiskOnChip to be ready */
+doc_wait:
+	/* FIXME: probably only three NOP's are needed */
+	testb	$0xc0, BX_Mplus_NOP
+	testb	$0xc0, BX_Mplus_NOP
+	testb	$0xc0, BX_Mplus_NOP
+	testb	$0xc0, BX_Mplus_NOP
+doc_waitloop:    
+	movb	BX_Mplus_FlashControl, %al
+	andw	$0xc0, %ax
+	cmpw	$0xc0, %ax
+	jne	doc_waitloop
+	ret
+#else
                 /* Enable CLE line to flash */
         movb    $CDSN_CTRL_WP + CDSN_CTRL_CLE + CDSN_CTRL_CE, BX_CDSNControl
                 /* Write the actual command */
@@ -294,6 +352,7 @@
 	testb	$0x80, BX_NOP
 	testb	$0x80, BX_NOP
         ret
+#endif
                 
 
 /*
@@ -356,7 +415,11 @@
 /***************************************************************************/
 code_end:
 
+#ifdef DOC_ADDRESS
+doc_seg:	.word DOC_ADDRESS
+#else
 doc_seg:	.word 0
+#endif
 
 /* gdt structure for high loading using int15/87 */
 gdt:

Index: makespl.c
===================================================================
RCS file: /home/cvs/mtd/docboot/makespl.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- makespl.c	9 Jul 2004 16:28:02 -0000	1.1
+++ makespl.c	2 Aug 2004 18:41:29 -0000	1.2
@@ -48,7 +48,9 @@
 
 int main(int argc, char **argv)
 {
-	int len,i, stubfd, imgfd, outfd;
+	int len, i, stubfd, imgfd, outfd, biosfd;
+	int ret;
+	char bios_extension;
 	unsigned char checksum=0;
 	int imglen;
 	int total_sects, setup_sects, kernel_sects;
@@ -56,10 +58,14 @@
 	//memset(buf, 0xff, sizeof(buf));
 
 	if (argc < 4) {
-		fprintf(stderr, "Usage: makespl <stubfile> <kernelfile> <outfile>\n");
+		fprintf(stderr, "Usage: makespl <stubfile> <kernelfile> <outfile> [bios_extensionfile]\n");
 		exit(1);
 	}
 
+	if (argv[4])
+		bios_extension=1;
+	else
+		bios_extension=0;
 	
 	stubfd = open(argv[1], O_RDONLY);
 	if (stubfd < 0) {
@@ -84,6 +90,14 @@
 		exit(1);
 	}
 
+	if (bios_extension) {
+		biosfd = open(argv[4], O_WRONLY | O_CREAT | O_TRUNC, 0664);
+		if (biosfd < 0) {
+			perror("open BIOS extension output file");
+			exit(1);
+		}
+	}
+
 	/* Read the bootstub */
 	len = read(stubfd, buf, 512);
 	if (len < 0) {
@@ -124,16 +138,33 @@
 	/* Calculate the csum */
 	buf[CHECKSUM_LOCATION] = 0;
 
-	for (i = 0; i < sizeof(buf); i++)
-		checksum += buf[i];
-
-	/* Set the slack byte to fix the csum */
-	buf[CHECKSUM_LOCATION] = 0x55 - checksum;
-
-	/* Write the bootstub page */
-	writeblocks(outfd, buf, 512, spl_sig);
-	/* Write the commandline page */
-	writeblocks(outfd, buf + 512, 512, cmdline_sig);
+	if (bios_extension) {
+		for (i = 0; i < 1024; i++)
+			checksum += buf[i];
+
+		/* Set the slack byte to fix the csum */
+		buf[CHECKSUM_LOCATION] = 0 - checksum;
+	} else {
+		for (i = 0; i < sizeof(buf); i++)
+			checksum += buf[i];
+
+		/* Set the slack byte to fix the csum */
+		buf[CHECKSUM_LOCATION] = 0x55 - checksum;
+	}
+
+	if (bios_extension) {
+		/* Write the bootstub and commandline to one file */
+		ret = write(biosfd, buf, 1024);
+		if (ret < 0) {
+			perror("write BIOS extension output file");
+			exit(1);
+		}
+	} else {
+		/* Write the bootstub page */
+		writeblocks(outfd, buf, 512, spl_sig);
+		/* Write the commandline page */
+		writeblocks(outfd, buf + 512, 512, cmdline_sig);
+	}
 	/* Write the rest of the first buffer */
 	writeblocks(outfd, buf + 1024, sizeof(buf) - 1024, kern_sig);
 





More information about the linux-mtd-cvs mailing list