Skip to contentSkip to conversation

Additional PDC cleanups

parisc-linux Ryan Bradetich 2 participants 2 messages Mar 25, 2001

lore
Share & tools
lore
#0 lore raw

Here is a patch that makes the real*_calls in firmware.c static. This works with the defconfig for but will not work when the STI console is enabled. I am posting the patch here for review, and also suggestions on how to organize the STI calls so we can encapsulate the real*_calls in firmware.c

The problem with the STI code is this #define in the drivers/video/sti/sticore.h

#define STI_CALL(func, flags, inptr, outptr, glob_cfg) \
	({	 						\
		real32_call( func, (unsigned long)STI_PTR(flags), \
				    STI_PTR(inptr), STI_PTR(outptr), \
				    glob_cfg); \
	})

My first thoughts were to make the STI_CALL function look like this:

#define STI_CALL(func, flags, inptr, outptr, glob_cfg) \
	({	 						\
		pdc_sti_call( func, (unsigned long)STI_PTR(flags), \
				    STI_PTR(inptr), STI_PTR(outptr), \
				    glob_cfg); \
	})

and define the pdc_sti_call in firmware.c. Anyone have a different approach that would make more sense?

Thanks,

- Ryan

===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/firmware.c,v retrieving revision 1.25

firmware.c +78 -2
diff -u -p -r1.25 firmware.c
@@ -334,6 +334,82 @@ int pdc_mem_mem_table(void *r_addr, void
 }
 #endif
 
+/* FIXME: Is this pdc used?  I could not find type reference to ftc_bitmap
+ * so I guessed at unsigned long.  Someone who knows what this does, can fix 
+ * it later. :)
+ */
+int pdc_do_firm_test_reset(unsigned long ftc_bitmap)
+{
+	return mem_pdc_call(PDC_BROADCAST_RESET, PDC_DO_FIRM_TEST_RESET,
+			    PDC_FIRM_TEST_MAGIC, ftc_bitmap);
+}
+
+int pdc_do_reset()
+{
+	return mem_pdc_call(PDC_BROADCAST_RESET, PDC_DO_RESET);
+}
+
+/*
+ * pdc_putc:
+ * Console character print using IODC.
+ *
+ * Note that only these special chars are architected for console IODC io:
+ * BEL, BS, CR, and LF. Others are passed through.
+ * Since the HP console requires CR+LF to perform a 'newline', we translate
+ * "\n" to "\r\n".
+ */
+
+void pdc_iodc_putc(unsigned char c)
+{
+	/* XXX Should we spinlock posx usage */
+	static int posx;	/* for simple TAB-Simulation... */
+	static int __attribute__((aligned(8)))   iodc_retbuf[32];
+	static char __attribute__((aligned(64))) iodc_dbuf[4096];
+	unsigned int n;
+
+	switch (c) {
+	case '\n':
+		iodc_dbuf[0] = '\r'; 
+		iodc_dbuf[1] = '\n';
+               	n = 2;
+               	posx = 0;
+		break;
+	case '\t':
+		pdc_putc(' ');
+		while (posx & 7) 	/* expand TAB */
+			pdc_putc(' ');
+		return;		/* return since IODC can't handle this */
+	case '\b':
+		posx-=2;		/* BS */
+	default:
+		iodc_dbuf[0] = c;
+		n = 1;
+		posx++;
+		break;
+	}
+
+	real32_call(PAGE0->mem_cons.iodc_io,
+		    (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
+		    PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
+		    __pa(iodc_retbuf), 0, __pa(iodc_dbuf), n, 0);
+}
+
+int pdc_iodc_getc(unsigned char *c)
+{
+	unsigned long flags;
+	static int __attribute__((aligned(8)))   iodc_retbuf[32];
+	static char __attribute__((aligned(64))) iodc_dbuf[4096];
+	
+	save_flags(flags);
+	cli();
+	real32_call(PAGE0->mem_kbd.iodc_io,
+		    (unsigned long)PAGE0->mem_kbd.hpa, ENTRY_IO_CIN,
+		    PAGE0->mem_kbd.spa, __pa(PAGE0->mem_kbd.dp.layers),
+		    __pa(iodc_retbuf), 0, __pa(iodc_dbuf), 1, 0);
+	restore_flags(flags);
+	c = *iodc_dbuf;	/* save the character directly to ch */
+	return *iodc_retbuf == 0;
+}
 
 static spinlock_t pdc_lock = SPIN_LOCK_UNLOCKED;
 
@@ -364,7 +440,7 @@ struct narrow_stack {
 	/* in reality, there's nearly 8k of stack after this */
 };
 
-long real32_call(unsigned long fn, ...)
+static long real32_call(unsigned long fn, ...)
 {
 	va_list args;
 	unsigned long r, flags;
@@ -421,7 +497,7 @@ struct wide_stack {
 	/* in reality, there's nearly 8k of stack after this */
 };
 
-long real64_call(unsigned long fn, ...)
+static long real64_call(unsigned long fn, ...)
 {
 	va_list args;
 	unsigned long r, flags;

Index: arch/parisc/kernel/pdc_cons.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/pdc_cons.c,v retrieving revision 1.24

pdc_cons.c +4 -70

93 lines not on this page · raw message

Index: arch/parisc/kernel/process.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/process.c,v retrieving revision 1.34

process.c +2 -5
diff -u -p -r1.34 process.c
@@ -113,15 +113,12 @@ void machine_restart(char *cmd)
 		** memory self tests. (Not implemented yet)
 		*/
 		if (ftc_bitmap) {
-			mem_pdc_call( PDC_BROADCAST_RESET,
-				PDC_DO_FIRM_TEST_RESET, PDC_FIRM_TEST_MAGIC,
-				ftc_bitmap);
+			pdc_do_firm_test_reset(ftc_bitmap);
 		}
 #endif
 
 		/* "Normal" system reset */
-		(void) mem_pdc_call(PDC_BROADCAST_RESET, PDC_DO_RESET,
-			0L, 0L, 0L);
+		pdc_do_reset();
 
 		/* Nope...box should reset with just CMD_RESET now */
 		gsc_writel(CMD_RESET, COMMAND_GLOBAL);

Index: include/asm-parisc/pdc.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/asm-parisc/pdc.h,v retrieving revision 1.28

pdc.h +9 -2
diff -u -p -r1.28 pdc.h
@@ -600,8 +600,8 @@ struct zeropage {
 #ifndef __ASSEMBLY__
 extern void pdc_console_init(void);
 /* pdc_get/put are NOT SMP safe - use at your own risk! */
-extern int  pdc_getc(void);		/* wait for char */
-extern void pdc_putc(unsigned char);	/* print char */
+extern int  pdc_iodc_getc(unsigned char *); /* wait for char */
+extern void pdc_iodc_putc(unsigned char);   /* print char */
 
 extern void setup_pdc(void);            /* in inventory.c */
 
@@ -639,6 +639,9 @@ int pdc_pci_irt(void *r_addr, void *hpa,
 int pdc_tod_read(struct pdc_tod *tod);
 int pdc_tod_set(unsigned long sec, unsigned long usec);
 
+int pdc_do_firm_test_reset(unsigned long ftc_bitmap);
+int pdc_do_reset(void);
+
 #ifdef __LP64__
 int pdc_mem_mem_table(void *r_addr, void *tbl, unsigned long entries);
 #endif
@@ -646,6 +649,10 @@ int pdc_mem_mem_table(void *r_addr, void
 /* on all currently-supported platforms, IODC I/O calls are always
  * 32-bit calls, and MEM_PDC calls are always the same width as the OS.
  * This means Cxxx boxes can't run wide kernels right now. -PB
+ *
+ * CONFIG_PDC_NARROW has been added to allow 64-bit kernels to run on
+ * systems with 32-bit MEM_PDC calls. This will allow wide kernels to
+ * run on Cxxx boxes now. -RB
  *
  * Note that some PAT boxes may have 64-bit IODC I/O...
  */
#1 lore raw
Quoted 11 lines · Ryan Bradetich

My first thoughts were to make the STI_CALL function look like this:

#define STI_CALL(func, flags, inptr, outptr, glob_cfg) \
	({	 						\
		pdc_sti_call( func, (unsigned long)STI_PTR(flags), \
				    STI_PTR(inptr), STI_PTR(outptr), \
				    glob_cfg); \
	})

and define the pdc_sti_call in firmware.c. Anyone have a different approach that would make more sense?

Makes sense. you might want to remove the cast and do it inside pdc_sti_call. every time i look at the sti code, i have to resist the urge to rip it into tiny pieces and redo it :-)

Quoted 9 lines

+/*
+ * pdc_putc:
+ * Console character print using IODC.
+ *
+ * Note that only these special chars are architected for console IODC io:
+ * BEL, BS, CR, and LF. Others are passed through.
+ * Since the HP console requires CR+LF to perform a 'newline', we translate
+ * "\n" to "\r\n".
+ */

This is so close to being kernel-doc it seems foolish not to go the whole hog.

/**
* iodc_putc - Console character print using IODC.
* @c: the character to output.
*
* Note that only these special chars are architected for console IODC io:
* BEL, BS, CR, and LF. Others are passed through.
* Since the HP console requires CR+LF to perform a 'newline', we translate
* "\n" to "\r\n".
*/

Signature · 1 line
Revolutions do not require corporate support.