Module Name:    src
Committed By:   skrll
Date:           Sun Feb  5 21:46:37 UTC 2012

Modified Files:
        src/sys/arch/hp700/dev: pdc.c

Log Message:
Delay some things to attach time - pdc_init is too early.

Minor tidyup while I'm here.

OK riz@


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/hp700/dev/pdc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hp700/dev/pdc.c
diff -u src/sys/arch/hp700/dev/pdc.c:1.40 src/sys/arch/hp700/dev/pdc.c:1.41
--- src/sys/arch/hp700/dev/pdc.c:1.40	Sat Oct  1 15:51:17 2011
+++ src/sys/arch/hp700/dev/pdc.c	Sun Feb  5 21:46:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pdc.c,v 1.40 2011/10/01 15:51:17 chs Exp $	*/
+/*	$NetBSD: pdc.c,v 1.41 2012/02/05 21:46:37 skrll Exp $	*/
 
 /*	$OpenBSD: pdc.c,v 1.14 2001/04/29 21:05:43 mickey Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pdc.c,v 1.40 2011/10/01 15:51:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pdc.c,v 1.41 2012/02/05 21:46:37 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,8 +63,8 @@ enum pdc_type pdc_type;
 
 static struct pdc_result pdcret1 PDC_ALIGNMENT;
 static struct pdc_result pdcret2 PDC_ALIGNMENT;
+static char pdc_consbuf[IODC_MINIOSIZ] PDC_ALIGNMENT;
 
-char pdc_consbuf[IODC_MINIOSIZ] PDC_ALIGNMENT;
 iodcio_t pdc_cniodc, pdc_kbdiodc;
 pz_device_t *pz_kbd, *pz_cons;
 
@@ -105,10 +105,6 @@ static int pdcsettod(todr_chip_handle_t,
 void
 pdc_init(void)
 {
-	static struct todr_chip_handle todr = {
-		.todr_settime = pdcsettod,
-		.todr_gettime = pdcgettod,
-	};
 	static int kbd_iodc[IODC_MAXSIZE/sizeof(int)];
 	static int cn_iodc[IODC_MAXSIZE/sizeof(int)];
 	int err;
@@ -116,12 +112,11 @@ pdc_init(void)
 
 	pagezero_cookie = hp700_pagezero_map();
 
-	/*
-	 * locore has updated pdc with (pdcio_t)PAGE0->mem_pdc
-	 */
 	pz_kbd = &PAGE0->mem_kbd;
 	pz_cons = &PAGE0->mem_cons;
 
+	pdc = (pdcio_t)PAGE0->mem_pdc;
+
 	/* XXX should we reset the console/kbd here?
 	   well, /boot did that for us anyway */
 	if ((err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_READ,
@@ -133,19 +128,13 @@ pdc_init(void)
 #endif
 	}
 
+	hp700_pagezero_unmap(pagezero_cookie);
+
 	pdc_cniodc = (iodcio_t)cn_iodc;
 	pdc_kbdiodc = (iodcio_t)kbd_iodc;
 
 	/* XXX make pdc current console */
 	cn_tab = &constab[0];
-
-	cn_init_magic(&pdc_cnm_state);
-	cn_set_magic("+++++");
-
-	hp700_pagezero_unmap(pagezero_cookie);
-
-	/* attach the TOD clock */
-	todr_attach(&todr);
 }
 
 void
@@ -235,13 +224,22 @@ pdcmatch(device_t parent, cfdata_t cf, v
 void
 pdcattach(device_t parent, device_t self, void *aux)
 {
+	static struct todr_chip_handle todr = {
+		.todr_settime = pdcsettod,
+		.todr_gettime = pdcgettod,
+	};
 	struct pdc_softc *sc = device_private(self);
 
 	sc->sc_dv = self;
 	pdc_attached = 1;
 
-	if (!pdc)
-		pdc_init();
+	KASSERT(pdc != NULL);
+
+	cn_init_magic(&pdc_cnm_state);
+	cn_set_magic("+++++");
+
+	/* attach the TOD clock */
+	todr_attach(&todr);
 
 	aprint_normal("\n");
 

Reply via email to