diff -urN sys.orig/arch/powerpc/oea/cpu_subr.c sys/arch/powerpc/oea/cpu_subr.c --- sys.orig/arch/powerpc/oea/cpu_subr.c 2004-03-12 00:40:13.000000000 +0900 +++ sys/arch/powerpc/oea/cpu_subr.c 2005-08-13 11:28:30.000000000 +0900 @@ -189,6 +189,7 @@ { "7455", MPC7455, REVFMT_MAJMIN }, { "7457", MPC7457, REVFMT_MAJMIN }, { "8240", MPC8240, REVFMT_MAJMIN }, + { "8245", MPC8245, REVFMT_MAJMIN }, { "", 0, REVFMT_HEX } }; diff -urN sys.orig/arch/sandpoint/include/intr.h sys/arch/sandpoint/include/intr.h --- sys.orig/arch/sandpoint/include/intr.h 2003-09-04 06:33:35.000000000 +0900 +++ sys/arch/sandpoint/include/intr.h 2005-08-14 19:11:42.000000000 +0900 @@ -180,8 +180,8 @@ /* * Motorola SandPoint PPC eval board interrupt list */ -#define ICU_LEN 25 -#define ICU_MASK 0x01ffffff +#define ICU_LEN (OPENPIC_MAX_INT + 1) +#define ICU_MASK ((1u << ICU_LEN) - 1) #define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN) @@ -189,14 +189,14 @@ #define SINT_NET 0x20000000 #define SINT_CLOCK 0x40000000 #define SINT_SERIAL 0x80000000 -#define SPL_CLOCK 0x00000001 +#define SPL_CLOCK 0x08000000 #define SINT_MASK (SINT_ISA|SINT_CLOCK|SINT_NET|SINT_SERIAL) #define CNT_SINT_ISA 28 #define CNT_SINT_NET 29 #define CNT_SINT_CLOCK 30 #define CNT_SINT_SERIAL 31 -#define CNT_CLOCK 0 +#define CNT_CLOCK 27 #define splbio() splraise(imask[IPL_BIO]) #define splnet() splraise(imask[IPL_NET]) diff -urN sys.orig/arch/sandpoint/include/openpicreg.h sys/arch/sandpoint/include/openpicreg.h --- sys.orig/arch/sandpoint/include/openpicreg.h 2001-08-30 11:08:43.000000000 +0900 +++ sys/arch/sandpoint/include/openpicreg.h 2005-08-14 19:10:30.000000000 +0900 @@ -67,15 +67,16 @@ #define SANDPOINT_INTR_RESERVED_13 13 #define SANDPOINT_INTR_RESERVED_14 14 #define SANDPOINT_INTR_RESERVED_15 15 -#define SANDPOINT_INTR_SERCON 16 /* Not often used */ -#define SANDPOINT_INTR_I2C 17 -#define SANDPOINT_INTR_DMA0 18 -#define SANDPOINT_INTR_DMA1 19 -#define SANDPOINT_INTR_I2O 20 -#define SANDPOINT_INTR_TIMER0 21 -#define SANDPOINT_INTR_TIMER1 22 -#define SANDPOINT_INTR_TIMER2 23 -#define SANDPOINT_INTR_TIMER3 24 +#define SANDPOINT_INTR_I2C 16 +#define SANDPOINT_INTR_DMA0 17 +#define SANDPOINT_INTR_DMA1 18 +#define SANDPOINT_INTR_I2O 19 +#define SANDPOINT_INTR_TIMER0 20 +#define SANDPOINT_INTR_TIMER1 21 +#define SANDPOINT_INTR_TIMER2 22 +#define SANDPOINT_INTR_TIMER3 23 +#define SANDPOINT_INTR_UART0 24 /* MPC824[15] DUART */ +#define SANDPOINT_INTR_UART1 25 /* MPC824[15] DUART */ #define OPENPIC_MAX_EXTERNAL_INT 15 @@ -97,22 +98,30 @@ #define SANDPOINT_INTR_TIMER1 10 #define SANDPOINT_INTR_TIMER2 11 #define SANDPOINT_INTR_TIMER3 12 +#define SANDPOINT_INTR_UART0 13 /* MPC824[15] DUART */ +#define SANDPOINT_INTR_UART1 14 /* MPC824[15] DUART */ #define OPENPIC_MAX_EXTERNAL_INT 4 #endif +#define OPENPIC_MAX_INT SANDPOINT_INTR_UART1 + /* interrupt vector/priority reg */ #define OPENPIC_SRC_VECTOR(irq) \ ((irq <= OPENPIC_MAX_EXTERNAL_INT) ? (0x10200 + (irq) * 0x20) \ : ((irq <= OPENPIC_MAX_EXTERNAL_INT + 3) ? \ (0x11000 + ((irq) - OPENPIC_MAX_EXTERNAL_INT) * 0x20) \ : ((irq == OPENPIC_MAX_EXTERNAL_INT + 4) ? 0x110C0 \ - : (0x01120 + \ - ((irq) - (OPENPIC_MAX_EXTERNAL_INT + 5)) * 0x40)))) + : ((irq >= OPENPIC_MAX_EXTERNAL_INT + 9) ? \ + (0x11120 + ((irq) - (OPENPIC_MAX_EXTERNAL_INT + 9)) \ + * 0x20) \ + : (0x01120 + ((irq) - (OPENPIC_MAX_EXTERNAL_INT + 5)) \ + * 0x40))))) #define OPENPIC_INIT_SRC(irq) \ (((OPENPIC_IMASK | (8 << OPENPIC_PRIORITY_SHIFT)) | \ - (((irq) <= OPENPIC_MAX_EXTERNAL_INT) ? \ + ((((irq) <= OPENPIC_MAX_EXTERNAL_INT) || \ + ((irq) >= OPENPIC_MAX_EXTERNAL_INT + 9)) ? \ (OPENPIC_POLARITY_NEGATIVE | OPENPIC_SENSE_LEVEL) : 0)) \ | (irq)) diff -urN sys.orig/arch/sandpoint/pci/pchb.c sys/arch/sandpoint/pci/pchb.c --- sys.orig/arch/sandpoint/pci/pchb.c 2003-07-15 12:35:49.000000000 +0900 +++ sys/arch/sandpoint/pci/pchb.c 2005-07-15 22:13:20.000000000 +0900 @@ -74,6 +74,7 @@ case PCI_PRODUCT_MOT_MPC106: case PCI_PRODUCT_MOT_MPC107: case PCI_PRODUCT_MOT_MPC8240: + case PCI_PRODUCT_MOT_MPC8245: return (1); } break; diff -urN sys.orig/arch/sandpoint/pci/pci_machdep.c sys/arch/sandpoint/pci/pci_machdep.c --- sys.orig/arch/sandpoint/pci/pci_machdep.c 2003-07-15 12:35:49.000000000 +0900 +++ sys/arch/sandpoint/pci/pci_machdep.c 2005-08-13 12:02:33.000000000 +0900 @@ -238,6 +238,7 @@ #else if (1) { #endif +#ifndef KUROBOX /* XXX */ /* * Sandpoint has 4 PCI slots. * Sandpoint rev. X2 has them in a weird order. Counting @@ -254,6 +255,7 @@ line, pin + '@'); goto bad; } +#endif /* KUROBOX */ /* * In the PCI configuration code, we simply assign the dev @@ -261,11 +263,15 @@ * interrupt, but subtract off the lowest dev (13) to get * the IRQ. */ +#ifdef KUROBOX + *ihp = line - 11; +#else /* KUROBOX */ #if defined(OPENPIC_SERIAL_MODE) *ihp = line - 11; #else *ihp = line - 13; #endif +#endif /* KUROBOX */ } return 0; diff -urN sys.orig/arch/sandpoint/sandpoint/disksubr.c sys/arch/sandpoint/sandpoint/disksubr.c --- sys.orig/arch/sandpoint/sandpoint/disksubr.c 2003-10-08 13:25:46.000000000 +0900 +++ sys/arch/sandpoint/sandpoint/disksubr.c 2005-08-26 00:34:56.000000000 +0900 @@ -43,6 +43,10 @@ #include "opt_mbr.h" +#ifndef MBR_MAGIC_EB +#define MBR_MAGIC_EB (0x55aa) +#endif + int fat_types[] = { MBR_PTYPE_FAT12, MBR_PTYPE_FAT16S, MBR_PTYPE_FAT16B, MBR_PTYPE_FAT32, @@ -51,9 +55,92 @@ #define NO_MBR_SIGNATURE ((struct mbr_partition *) -1) +#ifdef BSDDISKLABEL_EI +void swap_endian_disklabel(struct disklabel *, struct disklabel *); +u_int16_t dkcksum_re(struct disklabel *); +#endif + static struct mbr_partition * -mbr_findslice __P((struct mbr_partition* dp, struct buf *bp)); +mbr_findslice __P((struct mbr_partition* dp, struct buf *bp, int *f_endian)); + +#ifdef BSDDISKLABEL_EI +void +swap_endian_disklabel(struct disklabel *nlp, struct disklabel *olp) +{ + int i; +#define SW16(X) nlp->X = bswap16(olp->X) +#define SW32(X) nlp->X = bswap32(olp->X) + SW32(d_magic); + SW16(d_type); + SW16(d_subtype); + + /* no need to swap char strings */ + memcpy(nlp->d_typename, olp->d_typename, sizeof(nlp->d_typename)); + + /* XXX What should we do for d_un (an union of char and pointers) ? */ + memcpy(nlp->d_packname, olp->d_packname, sizeof(nlp->d_packname)); + + SW32(d_secsize); + SW32(d_nsectors); + SW32(d_ntracks); + SW32(d_ncylinders); + SW32(d_secpercyl); + SW32(d_secperunit); + + SW16(d_sparespertrack); + SW16(d_sparespercyl); + + SW32(d_acylinders); + + SW16(d_rpm); + SW16(d_interleave); + SW16(d_trackskew); /* sector 0 skew, per track */ + SW16(d_cylskew); /* sector 0 skew, per cylinder */ + SW32(d_headswitch); /* head switch time, usec */ + SW32(d_trkseek); /* track-to-track seek, usec */ + SW32(d_flags); /* generic flags */ + + for (i = 0; i < NDDATA; i++) + SW32(d_drivedata[i]); /* drive-type specific information */ + + for (i = 0; i < NSPARE; i++) + SW32(d_spare[i]); /* reserved for future use */ + + SW32(d_magic2); /* the magic number (again) */ + SW16(d_checksum); /* xor of data incl. partitions */ + + /* filesystem and partition information: */ + SW16(d_npartitions); /* number of partitions in following */ + SW32(d_bbsize); /* size of boot area at sn0, bytes */ + SW32(d_sbsize); /* max size of fs superblock, bytes */ + + for (i = 0; i < MAXPARTITIONS; i++) { + SW32(d_partitions[i].p_size); + SW32(d_partitions[i].p_offset); + SW32(d_partitions[i].p_fsize); + /* p_fstype and p_frag is uint8_t, so no need to swap */ + nlp->d_partitions[i].p_fstype = olp->d_partitions[i].p_fstype; + nlp->d_partitions[i].p_frag = olp->d_partitions[i].p_frag; + SW16(d_partitions[i].p_cpg); + } +#undef SW32 +#undef SW16 +} + +u_int16_t +dkcksum_re(struct disklabel *lp) +{ + u_int16_t *start, *end; + u_int16_t sum = 0; + + start = (u_int16_t *)lp; + end = (u_int16_t *)&lp->d_partitions[bswap16(lp->d_npartitions)]; + while (start < end) + sum ^= *start++; + return (sum); +} +#endif /* * Scan MBR for NetBSD partittion. Return NO_MBR_SIGNATURE if no MBR found @@ -62,18 +149,25 @@ */ static struct mbr_partition * -mbr_findslice(dp, bp) +mbr_findslice(dp, bp, f_endian) struct mbr_partition *dp; struct buf *bp; + int *f_endian; { struct mbr_partition *ourdp = NULL; u_int16_t *mbrmagicp; int i; - /* Note: Magic number is little-endian. */ + *f_endian = 0; + + /* Note: Magic number is little-endian. but... */ mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGIC_OFFSET); - if (*mbrmagicp != MBR_MAGIC) + if ((*mbrmagicp != MBR_MAGIC) && (*mbrmagicp != MBR_MAGIC_EB)) { return (NO_MBR_SIGNATURE); + } + if (*mbrmagicp == MBR_MAGIC_EB) { + *f_endian = 1; + } /* XXX how do we check veracity/bounds of this? */ memcpy(dp, bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp)); @@ -138,6 +232,7 @@ struct disklabel *dlp; char *msg = NULL; int dospartoff, cyl, i, *ip; + int f_endian; /* minimal requirements for archtypal disk label */ if (lp->d_secsize == 0) @@ -187,15 +282,21 @@ } else { struct mbr_partition *ourdp = NULL; - ourdp = mbr_findslice(dp, bp); + ourdp = mbr_findslice(dp, bp, &f_endian); if (ourdp == NO_MBR_SIGNATURE) goto nombrpart; for (i = 0; i < MBR_PART_COUNT; i++, dp++) { /* Install in partition e, f, g, or h. */ pp = &lp->d_partitions[RAW_PART + 1 + i]; - pp->p_offset = dp->mbrp_start; - pp->p_size = dp->mbrp_size; + if (f_endian) { + pp->p_offset = bswap32(dp->mbrp_start); + pp->p_size = bswap32(dp->mbrp_size); + } + else { + pp->p_offset = dp->mbrp_start; + pp->p_size = dp->mbrp_size; + } for (ip = fat_types; *ip != -1; ip++) { if (dp->mbrp_type == *ip) pp->p_fstype = FS_MSDOS; @@ -210,14 +311,27 @@ if (dp == ourdp) { /* need sector address for SCSI/IDE, cylinder for ESDI/ST506/RLL */ - dospartoff = dp->mbrp_start; + if (f_endian) { + dospartoff = bswap32(dp->mbrp_start); + } + else { + dospartoff = dp->mbrp_start; + } cyl = MBR_PCYL(dp->mbrp_scyl, dp->mbrp_ssect); /* update disklabel with details */ - lp->d_partitions[2].p_size = - dp->mbrp_size; - lp->d_partitions[2].p_offset = - dp->mbrp_start; + if (f_endian) { + lp->d_partitions[2].p_size = + bswap32(dp->mbrp_size); + lp->d_partitions[2].p_offset = + bswap32(dp->mbrp_start); + } + else { + lp->d_partitions[2].p_size = + dp->mbrp_size; + lp->d_partitions[2].p_offset = + dp->mbrp_start; + } #if 0 if (lp->d_ntracks != dp->mbrp_ehd + 1 || lp->d_nsectors != DPSECT(dp->mbrp_esect)) { @@ -256,19 +370,38 @@ for (dlp = (struct disklabel *)bp->b_data; dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp)); dlp = (struct disklabel *)((char *)dlp + sizeof(long))) { - if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { - if (msg == NULL) - msg = "no disk label"; - } else if (dlp->d_npartitions > MAXPARTITIONS || + if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC) { + /* disklabel is written in host's endian */ + if (dlp->d_npartitions > MAXPARTITIONS || dkcksum(dlp) != 0) - msg = "disk label corrupted"; - else { - *lp = *dlp; - msg = NULL; - break; + msg = "disk label corrupted"; + else { + *lp = *dlp; + msg = NULL; + break; + } } - } +#ifdef BSDDISKLABEL_EI + if (bswap32(dlp->d_magic) == DISKMAGIC && + bswap32(dlp->d_magic2) == DISKMAGIC) { + /* disklabel is written in reversed endian */ + if (bswap16(dlp->d_npartitions) > MAXPARTITIONS || + dkcksum_re(dlp) != 0) + msg = "disk label corruptted"; + else { + swap_endian_disklabel(lp, dlp); + /* recalculate cksum in host's endian */ + lp->d_checksum = 0; + lp->d_checksum = dkcksum(lp); + msg = NULL; + break; + } + } +#endif + if (msg == NULL) + msg = "no disk label"; + } if (msg) goto done; @@ -309,7 +442,9 @@ } done: +#if 0 bp->b_flags |= B_INVAL; +#endif brelse(bp); return (msg); } @@ -385,6 +520,7 @@ struct buf *bp; struct disklabel *dlp; int error, dospartoff, cyl; + int f_endian; /* get a buffer and initialize it */ bp = geteblk((int)lp->d_secsize); @@ -407,14 +543,19 @@ if ((error = biowait(bp)) == 0) { struct mbr_partition *ourdp = NULL; - ourdp = mbr_findslice(dp, bp); + ourdp = mbr_findslice(dp, bp, &f_endian); if (ourdp == NO_MBR_SIGNATURE) goto nombrpart; if (ourdp) { /* need sector address for SCSI/IDE, cylinder for ESDI/ST506/RLL */ - dospartoff = ourdp->mbrp_start; + if (f_endian) { + dospartoff = bswap32(ourdp->mbrp_start); + } + else { + dospartoff = ourdp->mbrp_start; + } cyl = MBR_PCYL(ourdp->mbrp_scyl, ourdp->mbrp_ssect); } } @@ -449,6 +590,21 @@ (*strat)(bp); error = biowait(bp); goto done; +#ifdef BSDDISKLABEL_EI + } else if (bswap32(dlp->d_magic) == DISKMAGIC && + bswap32(dlp->d_magic2) == DISKMAGIC && + bswap16(dlp->d_npartitions) <= MAXPARTITIONS && + dkcksum_re(dlp) == 0) { + /* found disklabel in the opposite endian */ + swap_endian_disklabel(dlp, lp); + /* recalculate cksum in reversed endian */ + dlp->d_checksum = 0; + dlp->d_checksum = dkcksum_re(dlp); + bp->b_flags = B_BUSY | B_WRITE; + (*strat)(bp); + error = biowait(bp); + goto done; +#endif } } error = ESRCH; diff -urN sys.orig/arch/sandpoint/sandpoint/extintr.c sys/arch/sandpoint/sandpoint/extintr.c --- sys.orig/arch/sandpoint/sandpoint/extintr.c 2004-02-13 20:36:17.000000000 +0900 +++ sys/arch/sandpoint/sandpoint/extintr.c 2005-08-14 19:16:58.000000000 +0900 @@ -469,8 +469,12 @@ openpic_base = (volatile unsigned char *) base; +#ifndef KUROBOX x = openpic_read(OPENPIC_FEATURE); maxirq = (x >> 16) & 0x7ff; +#else /* KUROBOX */ + maxirq = ICU_LEN; /* XXX to avoid overrun */ +#endif /* KUROBOX */ /* disable all interrupts */ for (irq = 0; irq < maxirq; irq++) diff -urN sys.orig/arch/sandpoint/sandpoint/locore.S sys/arch/sandpoint/sandpoint/locore.S --- sys.orig/arch/sandpoint/sandpoint/locore.S 2003-07-31 16:50:05.000000000 +0900 +++ sys/arch/sandpoint/sandpoint/locore.S 2005-08-25 22:41:15.000000000 +0900 @@ -33,6 +33,7 @@ */ #include "opt_ddb.h" +#include "opt_ddbparam.h" #include "fs_kernfs.h" #include "opt_ipkdb.h" #include "opt_multiprocessor.h" @@ -76,24 +77,26 @@ .asciz "pci2", "pci3", "winbondA", "winbondB" .asciz "winbondC", "winbondD", "rsvd10", "rsvd11" .asciz "rsvd12", "rsvd13", "rsvd14", "rsvd15" - .asciz "sercon", "i2c", "dma0", "dma1" - .asciz "i2o", "timer0", "timer1", "timer2" - .asciz "timer3" + .asciz "i2c", "dma0", "dma1", "i2o" + .asciz "timer0", "timer1", "timer2", timer3" + .asciz "uart0", "uart1", "unused", "clock" + .asciz "softisa", "softnet", "softclock", "softserial" #else .asciz "pci0", "pci1", "pci2", "pci3" .asciz "sercon", "i2c", "dma0", "dma1" .asciz "i2o", "timer0", "timer1", "timer2" - .asciz "timer3", "unused0", "unused1", "unused2" - .asciz "unused3", "unused4", "unused5", "unused6" - .asciz "unused7", "unused8", "unused9", "unused10" - .asciz "unused11" + .asciz "timer3", "uart0", "uart1", "unused0" + .asciz "unused1", "unused2", "unused3", "unused4" + .asciz "unused5", "unused6", "unused7", "unused8" + .asciz "unused9", "unused10", "unused11", "clock" + .asciz "softisa", "softnet", "softclock", "softserial" #endif GLOBAL(eintrnames) .align 4 GLOBAL(intrcnt) .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - .long 0,0,0,0,0,0,0,0,0 + .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 GLOBAL(eintrcnt) /* @@ -120,14 +123,41 @@ ori 8, 8, (HID0_ICE | HID0_DCE)@l mtspr 1008,8 -/* compute end of kernel memory */ +#if 1 + /* + * Clear BSS (use 0, 8, 9) + */ + li 0,0 + lis 8,_C_LABEL(edata)@ha + addi 8,8,_C_LABEL(edata)@l + lis 9,_C_LABEL(end)@ha + addi 9,9,_C_LABEL(end)@l +1: cmpw 0,8,9 /* edata & end are >= word aligned */ + bge 2f + stw 0,0(8) + addi 8,8,4 + b 1b +2: +#endif + /* compute end of kernel memory */ #if NKSYMS || defined(DDB) || defined(LKM) || defined(KERNFS) +#ifdef SYMTAB_SPACE /* SYMTAB_SPACE is *NOT* use startsym/endsym */ + lis 4,_C_LABEL(end)@ha + addi 4,4,_C_LABEL(end)@l lis 7,_C_LABEL(startsym)@ha addi 7,7,_C_LABEL(startsym)@l - stw 3,0(7) + stw 4,0(7) /* end -> startsym */ lis 7,_C_LABEL(endsym)@ha addi 7,7,_C_LABEL(endsym)@l - stw 4,0(7) + stw 4,0(7) /* end -> endsym */ +#else + lis 7,_C_LABEL(startsym)@ha + addi 7,7,_C_LABEL(startsym)@l + stw 4,0(7) /* argv[2] -> startsym */ + lis 7,_C_LABEL(endsym)@ha + addi 7,7,_C_LABEL(endsym)@l + stw 5,0(7) /* argv[3] -> endsym */ +#endif #else lis 4,_C_LABEL(end)@ha addi 4,4,_C_LABEL(end)@l @@ -166,6 +196,47 @@ mtmsr 3 b 0xFFF00100 +#ifdef KUROBOX + .globl _C_LABEL(kurobox_setup_avr) +_C_LABEL(kurobox_setup_avr): + lis 4,0xfc00 + addi 4,4,0x4500 + li 5,0x80 + stb 5,3(4) + eieio +#ifdef KUROBOX_HG + li 5, ((133000000 / 16) / 9600) +#else /* KUROBOX_HG */ + li 5, ((100000000 / 16) / 9600) +#endif /* KUROBOX_HG */ + stb 5,0(4) + eieio +#ifdef KUROBOX_HG + li 5, (((133000000 / 16) / 9600) >> 8) +#else /* KUROBOX_HG */ + li 5, (((100000000 / 16) / 9600) >> 8) +#endif /* KUROBOX_HG */ + stb 5,1(4) + eieio + li 5, 0x1b + stb 5,3(4) + eieio + li 5, 0x7 + stb 5,2(4) + eieio + blr + + .globl _C_LABEL(kurobox_write_avr) +_C_LABEL(kurobox_write_avr): + lis 4,0xfc00 + addi 4,4,0x4500 + stb 3,0(4) + stb 3,0(4) + stb 3,0(4) + stb 3,0(4) + eieio + blr +#endif /* KUROBOX */ /* * Include common switch / setfault code */ diff -urN sys.orig/arch/sandpoint/sandpoint/machdep.c sys/arch/sandpoint/sandpoint/machdep.c --- sys.orig/arch/sandpoint/sandpoint/machdep.c 2004-02-14 23:33:29.000000000 +0900 +++ sys/arch/sandpoint/sandpoint/machdep.c 2005-08-13 10:59:30.000000000 +0900 @@ -36,6 +36,7 @@ #include "opt_compat_netbsd.h" #include "opt_ddb.h" +#include "opt_ddbparam.h" #include "opt_inet.h" #include "opt_ccitt.h" #include "opt_iso.h" @@ -91,6 +92,11 @@ #endif #include "isa.h" +#ifdef KUROBOX +#if (NISA > 0) +#error KUROBOX is NOT have ISA bus. +#endif +#endif #if (NISA > 0) void isa_intr_init(void); #endif @@ -127,15 +133,20 @@ void ext_intr(void); void sandpoint_bus_space_init(void); +#ifdef KUROBOX +void kurobox_write_avr(int val); +void kurobox_setup_avr(void); +#endif + void initppc(u_int startkernel, u_int endkernel, u_int args, void *btinfo) { -#if 1 +#if 0 /* XXX BUG XXX This code clear the cpu_info[]!! */ { extern unsigned char *edata, *end; memset(&edata, 0, (u_int) &end - (u_int) &edata); } -#endif +#endif /* XXX BSS clear code moved to locore.S */ /* * Hardcode 32MB for now--we should probe for this or get it @@ -145,7 +156,15 @@ { /* XXX AKB */ u_int32_t physmemsize; +#ifdef KUROBOX +#ifdef KUROBOX_HG + physmemsize = 128 * 1024 * 1024; +#else /* KUROBOX_HG */ + physmemsize = 64 * 1024 * 1024; +#endif /* KUROBOX_HG */ +#else /* KUROBOX */ physmemsize = 32 * 1024 * 1024; +#endif /* KUROBOX */ physmemr[0].start = 0; physmemr[0].size = physmemsize; physmemr[1].size = 0; @@ -161,8 +180,16 @@ { /* XXX AKB */ extern u_long ticks_per_sec, ns_per_tick; +#ifdef KUROBOX +#ifdef KUROBOX_HG + ticks_per_sec = 130041000; /* XXX measured value */ +#else /* KUROBOX_HG */ + ticks_per_sec = 97553800; /* XXX measured value */ +#endif /* KUROBOX_HG */ +#else /* KUROBOX */ ticks_per_sec = 100000000; /* 100 MHz */ /* ticks_per_sec = 66000000; * 66 MHz */ +#endif /* KUROBOX */ ticks_per_sec /= 4; /* 4 cycles per DEC tick */ cpu_timebase = ticks_per_sec; ns_per_tick = 1000000000 / ticks_per_sec; @@ -171,14 +198,20 @@ /* * boothowto */ +#ifdef KUROBOX + boothowto = 0; /* XXX need prepare boot args. */ +#else /* KUROBOX */ boothowto = RB_SINGLE; +#endif /* KUROBOX */ sandpoint_bus_space_init(); +#ifndef KUROBOX consinit(); printf("avail_end %x\n", (unsigned) avail_end); printf("availmemr[0].start %x\n", (unsigned) availmemr[0].start); printf("availmemr[0].size %x\n", (unsigned) availmemr[0].size); +#endif /* KUROBOX */ /* * Initialize BAT registers. Map the EUMB MEMORY 1M area to the @@ -209,7 +242,18 @@ #if (NISA > 0) isa_intr_init(); #endif - +#ifdef KUROBOX + consinit(); +#if 0 +printf("startkernel %x\n", (unsigned) startkernel); +printf("endkernel %x\n", (unsigned) endkernel); +printf("startsym %x\n", (unsigned) startsym); +printf("endsym %x\n", (unsigned) endsym); +printf("avail_end %x\n", (unsigned) avail_end); +printf("availmemr[0].start %x\n", (unsigned) availmemr[0].start); +printf("availmemr[0].size %x\n", (unsigned) availmemr[0].size); +#endif /* 0 */ +#endif /* KUROBOX */ /* * Set the page size. */ @@ -271,9 +315,12 @@ void consinit(void) { - static int initted; + static int initted = 0; #if (NCOM > 0) bus_space_tag_t tag; +#ifdef KUROBOX + bus_space_handle_t ioh; +#endif /* KUROBOX */ #endif if (initted) @@ -281,10 +328,24 @@ initted = 1; #if (NCOM > 0) +#ifdef KUROBOX + tag = &sandpoint_mem_bs_tag; + bus_space_map(tag, 0xfc004500, 0x200, 0, &ioh); /* Map DUART */ + bus_space_write_1(tag, ioh, 0x11, 0xc1); /* Enable UART ch.2 */ + bus_space_unmap(tag, ioh, 0x200); /* Unmap */ +#ifdef KUROBOX_HG + if (comcnattach(tag, 0xfc004600, 57600, 133000000, COM_TYPE_NORMAL, + ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8))) +#else /* KUROBOX_HG */ + if (comcnattach(tag, 0xfc004600, 57600, 100000000, COM_TYPE_NORMAL, + ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8))) +#endif /* KUROBOX_HG */ +#else /* KUROBOX */ tag = &sandpoint_isa_io_bs_tag; if(comcnattach(tag, 0x3F8, 38400, COM_FREQ, COM_TYPE_NORMAL, ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8))) +#endif /* KUROBOX */ panic("can't init serial console"); else return; @@ -323,6 +384,15 @@ if (howto & RB_HALT) { doshutdownhooks(); printf("halted\n\n"); +#ifdef KUROBOX + /* KUROBOX power off */ + kurobox_setup_avr(); + kurobox_write_avr('E'); + DELAY(1000000); + DELAY(1000000); + DELAY(1000000); + kurobox_write_avr('G'); +#endif /* KUROBOX */ while(1); } if (!cold && (howto & RB_DUMP)) @@ -346,11 +416,19 @@ *ap++ = 0; if (ap[-2] == '-') *ap1 = 0; -#if 1 +#ifdef KUROBOX + /* KUROBOX reboot */ + kurobox_setup_avr(); + kurobox_write_avr('C'); + DELAY(1000000); + DELAY(1000000); + DELAY(1000000); + kurobox_write_avr('G'); +#else /* KUROBOX */ { extern void sandpoint_reboot __P((void)); sandpoint_reboot(); } -#endif +#endif /* KUROBOX */ while (1); } @@ -377,7 +455,7 @@ 0x00000000, 0xfd000000, 0xfe000000, }; -static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)] +static char ex_storage[4][EXTENT_FIXED_STORAGE_SIZE(8)] __attribute__((aligned(8))); void @@ -413,3 +491,63 @@ if (error) panic("sandpoint_bus_space_init: can't init isa iomem tag"); } + +#ifdef KUROBOX /* XXX from arch/powerpc/ibm4xx/dev/rtc.c */ +#include + +todr_chip_handle_t todr_handle; + +void +todr_attach(todr_chip_handle_t todr) +{ + if (todr_handle) + panic("todr_attach: rtc already configured"); + todr_handle = todr; +} + +void +inittodr(time_t base) +{ + int check; + struct timeval todrtime; + + check = 0; + if (todr_handle == NULL) { + printf("inittodr: rtc not present"); + time.tv_sec = base; + time.tv_usec = 0; + check = 1; + } else { + if (todr_gettime(todr_handle, &todrtime) != 0) { + printf("inittodr: Error reading clock"); + time.tv_sec = base; + time.tv_usec = 0; + check = 1; + } else { + time = todrtime; + if (time.tv_sec > base + 3 * SECDAY) { + printf("inittodr: Clock has gained %ld days", + (time.tv_sec - base) / SECDAY); + check = 1; + } + else if (time.tv_sec + SECDAY < base) { + printf("inittodr: Clock has lost %ld day(s)", + (base - time.tv_sec) / SECDAY); + check = 1; + } + } + } + if (check) + printf(" - CHECK AND RESET THE DATE.\n"); +} +void +resettodr(void) +{ + if (time.tv_sec == 0) + return; + + if (todr_handle != NULL && + todr_settime(todr_handle, (struct timeval *)&time) != 0) + printf("resettodr: failed to set time\n"); +} +#endif /* KUROBOX */ diff -urN sys.orig/arch/sandpoint/sandpoint/mainbus.c sys/arch/sandpoint/sandpoint/mainbus.c --- sys.orig/arch/sandpoint/sandpoint/mainbus.c 2003-07-15 12:35:50.000000000 +0900 +++ sys/arch/sandpoint/sandpoint/mainbus.c 2005-08-13 10:26:27.000000000 +0900 @@ -97,6 +97,10 @@ mba.mba_busname = "cpu"; config_found(self, &mba, mainbus_print); +#ifdef KUROBOX + mba.mba_busname = "eumb"; + config_found(self, &mba, mainbus_print); +#endif /* * XXX Note also that the presence of a PCI bus should * XXX _always_ be checked, and if present the bus should be diff -urN sys.orig/dev/i2c/files.i2c sys/dev/i2c/files.i2c --- sys.orig/dev/i2c/files.i2c 2003-10-21 01:24:10.000000000 +0900 +++ sys/dev/i2c/files.i2c 2005-08-13 10:34:48.000000000 +0900 @@ -57,3 +57,8 @@ device xrtc attach xrtc at iic file dev/i2c/x1226.c xrtc + +# Ricoh RS5C372 Real Time Clock +device rsrtc +attach rsrtc at iic +file dev/i2c/rs5c372.c rsrtc diff -urN sys.orig/dev/scsipi/sd.c sys/dev/scsipi/sd.c --- sys.orig/dev/scsipi/sd.c 2004-09-11 21:55:11.000000000 +0900 +++ sys/dev/scsipi/sd.c 2005-08-13 14:21:59.000000000 +0900 @@ -1982,7 +1982,9 @@ } page0: +#ifdef DEBUG /* XXX too noisy (with USB memory's SCSI emulation) */ printf("%s: fabricating a geometry\n", sd->sc_dev.dv_xname); +#endif /* Try calling driver's method for figuring out geometry. */ if (!sd->sc_periph->periph_channel->chan_adapter->adapt_getgeom || !(*sd->sc_periph->periph_channel->chan_adapter->adapt_getgeom)