This message generated a parse failure. Raw output follows here. Please use 'back' to navigate. From devnull@lkml.org Fri Apr 26 23:21:01 2024 Received: from entropy.muc.muohio.edu (entropy.muc.muohio.edu [134.53.213.10]) by herbie.ucs.indiana.edu (8.8.8/8.8.8) with ESMTP id NAA16777 for ; Sun, 13 Sep 1998 13:01:15 -0500 (EST) Received: from vger.rutgers.edu (root@vger.rutgers.edu [128.6.190.2]) by entropy.muc.muohio.edu (8.8.8/Not-Vulnerable) with ESMTP id OAA27301; Sun, 13 Sep 1998 14:00:13 -0400 Received: by vger.rutgers.edu id <154156-1366>; Sun, 13 Sep 1998 10:41:14 -0400 Received: from snowcrash.cymru.net ([163.164.160.3]:1640 "EHLO snowcrash.cymru.net" ident: "NO-IDENT-SERVICE[2]") by vger.rutgers.edu with ESMTP id <154562-1366>; Sun, 13 Sep 1998 10:14:45 -0400 Received: from the-village.bc.nu (the-village.bc.nu [163.164.160.21]) by snowcrash.cymru.net (8.8.7/8.7.1) with SMTP id SAA10487; Sun, 13 Sep 1998 18:16:06 +0100 Received: by the-village.bc.nu (Smail3.1.29.1 #2) id m0zIGel-000aQwC; Sun, 13 Sep 98 19:13 BST Message-Id: Date: Sun, 13 Sep 98 19:13 BST From: alan@lxorguk.ukuu.org.uk (Alan Cox) To: jes.sorensen@cern.ch, linux-kernel@vger.rutgers.edu, torvalds@transmeta.com Subject: PATCH: Nubus clean up X-Orcpt: rfc822;linux-kernel@vger.rutgers.edu Sender: owner-linux-kernel@vger.rutgers.edu Precedence: bulk X-Loop: majordomo@vger.rutgers.edu This patch cleans up the Nubus support. It makes the following changes o Remove 68K specific code from drivers/nubus/nubus.c (its generic equivalent moved into include/asm/hwtest.h on relevant hardware) o Add a /proc/nubus. Note unlike the PCI world it makes sense to use text here. The data strings and the icons for each hardware device are in the card configuration proms. o Clean up the daynaport driver to match and fix some bugs, this affects only Macintosh specific code. These changes mean the nubus code should (once folks find the base addresses etc) work on non Mac68K platforms (eg older PMAC). diff -u --new-file --recursive --exclude-from ../exclude linux.vanilla/drivers/net/daynaport.c linux/drivers/net/daynaport.c --- linux.vanilla/drivers/net/daynaport.c Tue Sep 8 18:58:27 1998 +++ linux/drivers/net/daynaport.c Sun Sep 13 18:07:44 1998 @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -57,6 +59,13 @@ static void sane_block_output(struct device *dev, int count, const unsigned char *buf, const int start_page); +static void slow_sane_get_8390_hdr(struct device *dev, struct e8390_pkt_hdr *hdr, + int ring_page); +static void slow_sane_block_input(struct device *dev, int count, + struct sk_buff *skb, int ring_offset); +static void slow_sane_block_output(struct device *dev, int count, + const unsigned char *buf, const int start_page); + #define WD_START_PG 0x00 /* First page of TX buffer */ #define WD03_STOP_PG 0x20 /* Last page +1 of RX ring */ @@ -81,11 +90,11 @@ int regd; int v; - if(nubus_hwreg_present(&ptr[0x00])==0) + if(hwreg_present(&ptr[0x00])==0) return -EIO; - if(nubus_hwreg_present(&ptr[0x0D<base_addr=(int)(nubus_slot_addr(slot)+APPLE_8390_BASE); dev->mem_start=(int)(nubus_slot_addr(slot)+APPLE_8390_MEM); - dev->mem_end=dev->mem_start+APPLE_MEMSIZE; /* 8K it seems */ + + memsize = apple_8390_mem_probe((void *)dev->mem_start); + + dev->mem_end=dev->mem_start+memsize; dev->irq=slot; printk("apple/clone: testing board: "); - printk("memory - "); + printk("%dK memory - ", memsize>>10); i=(void *)dev->mem_start; - memset((void *)i,0xAA, DAYNA_MEMSIZE); + memset((void *)i,0xAA, memsize); while(i<(volatile unsigned short *)dev->mem_end) { if(*i!=0xAAAA) @@ -366,8 +425,15 @@ ei_status.get_8390_hdr = &dayna_get_8390_hdr; ei_status.reg_offset = fwrd4_offsets; break; - case NS8390_APPLE: /* Apple/Asante/Farallon */ case NS8390_FARALLON: + case NS8390_APPLE: /* Apple/Asante/Farallon */ + /* 16 bit card, register map is reversed */ + ei_status.reset_8390 = &ns8390_no_reset; + ei_status.block_input = &slow_sane_block_input; + ei_status.block_output = &slow_sane_block_output; + ei_status.get_8390_hdr = &slow_sane_get_8390_hdr; + ei_status.reg_offset = back4_offsets; + break; case NS8390_ASANTE: /* 16 bit card, register map is reversed */ ei_status.reset_8390 = &ns8390_no_reset; @@ -442,7 +508,7 @@ { unsigned char *target=nubus_slot_addr(dev->irq); if (ei_debug > 1) - printk("Need to reset the NS8390 t=%lu...", jiffies); + printk("Need to reset the NS8390 t=%lu...", jiffies); ei_status.txing = 0; /* This write resets the card */ target[0xC0000]=0; @@ -585,12 +651,89 @@ } } + static void sane_block_output(struct device *dev, int count, const unsigned char *buf, int start_page) { long shmem = (start_page - WD_START_PG)<<8; memcpy((char *)dev->mem_start+shmem, buf, count); +} + +static void word_memcpy_tocard(void *tp, const void *fp, int count) +{ + volatile unsigned short *to = tp; + const unsigned short *from = fp; + + count++; + count/=2; + + while(count--) + *to++=*from++; +} + +static void word_memcpy_fromcard(void *tp, const void *fp, int count) +{ + unsigned short *to = tp; + const volatile unsigned short *from = fp; + volatile int p; + + count++; + count/=2; + + while(count--) + *to++=*from++; +} + +static void slow_sane_get_8390_hdr(struct device *dev, struct e8390_pkt_hdr *hdr, int ring_page) +{ + unsigned long hdr_start = (ring_page - WD_START_PG)<<8; + word_memcpy_fromcard((void *)hdr, (char *)dev->mem_start+hdr_start, 4); + /* Register endianism - fix here rather than 8390.c */ + hdr->count=(hdr->count&0xFF)<<8|(hdr->count>>8); +} + +static void slow_sane_block_input(struct device *dev, int count, struct sk_buff *skb, int ring_offset) +{ + unsigned long xfer_base = ring_offset - (WD_START_PG<<8); + unsigned long xfer_start = xfer_base+dev->mem_start; + + if (xfer_start + count > dev->rmem_end) + { + /* We must wrap the input move. */ + int semi_count = dev->rmem_end - xfer_start; + word_memcpy_fromcard(skb->data, (char *)dev->mem_start+xfer_base, semi_count); + count -= semi_count; + word_memcpy_fromcard(skb->data + semi_count, + (char *)dev->rmem_start, count); + } + else + { + word_memcpy_fromcard(skb->data, (char *)dev->mem_start+xfer_base, count); + } +} + +static void slow_sane_block_output(struct device *dev, int count, const unsigned char *buf, + int start_page) +{ + long shmem = (start_page - WD_START_PG)<<8; + + word_memcpy_tocard((char *)dev->mem_start+shmem, buf, count); +#if 0 + long shmem = (start_page - WD_START_PG)<<8; + volatile unsigned short *to=(unsigned short *)(dev->mem_start+shmem); + volatile int p; + unsigned short *bp=(unsigned short *)buf; + + count=(count+1)/2; + + while(count--) + { + *to++=*bp++; + for(p=0;p<10;p++) + p++; + } +#endif } /* diff -u --new-file --recursive --exclude-from ../exclude linux.vanilla/drivers/nubus/nubus.c linux/drivers/nubus/nubus.c --- linux.vanilla/drivers/nubus/nubus.c Tue Sep 8 18:58:27 1998 +++ linux/drivers/nubus/nubus.c Sun Sep 13 03:52:24 1998 @@ -12,8 +12,11 @@ #include #include #include +#include /* for LCIII stuff; better find a general way like MACH_HAS_NUBUS */ #include +#include + #undef LCIII_WEIRDNESS @@ -24,49 +27,6 @@ * -- Alan */ - - -/* This function tests for the presence of an address, specially a - * hardware register address. It is called very early in the kernel - * initialization process, when the VBR register isn't set up yet. On - * an Atari, it still points to address 0, which is unmapped. So a bus - * error would cause another bus error while fetching the exception - * vector, and the CPU would do nothing at all. So we needed to set up - * a temporary VBR and a vector table for the duration of the test. - * - * See the atari/config.c code we nicked it from for more clues. - */ - -int nubus_hwreg_present( volatile void *regp ) -{ - int ret = 0; - long save_sp, save_vbr; - long tmp_vectors[3]; - unsigned long flags; - - save_flags(flags); - cli(); - - __asm__ __volatile__ - ( "movec %/vbr,%2\n\t" - "movel #Lberr1,%4@(8)\n\t" - "movec %4,%/vbr\n\t" - "movel %/sp,%1\n\t" - "moveq #0,%0\n\t" - "tstb %3@\n\t" - "nop\n\t" - "moveq #1,%0\n" - "Lberr1:\n\t" - "movel %1,%/sp\n\t" - "movec %2,%/vbr" - : "=&d" (ret), "=&r" (save_sp), "=&r" (save_vbr) - : "a" (regp), "a" (tmp_vectors) - ); - restore_flags(flags); - return( ret ); -} - - /* * Yes this sucks. The ROM can appear on arbitary bytes of the long @@ -102,7 +62,7 @@ { unsigned char *p=*ptr; - if(len>8192) + if(len>65536) printk("rewind of %d!\n", len); while(len) { @@ -119,7 +79,7 @@ static void nubus_advance(unsigned char **ptr, int len, int map) { unsigned char *p=*ptr; - if(len>8192) + if(len>65536) printk("advance of %d!\n", len); while(len) { @@ -373,7 +333,7 @@ { rp--; - if(!nubus_hwreg_present(rp)) + if(!hwreg_present(rp)) continue; dp=*rp; @@ -594,6 +554,52 @@ return ng; } +#ifdef CONFIG_PROC_FS + +/* + * /proc for Nubus devices + */ + +static int sprint_nubus_config(int slot, char *ptr, int len) +{ + if(len<150) + return -1; + sprintf(ptr, "Device: %s %s\n", nubus_slots[slot].slot_cardname, + (nubus_slots[slot].slot_flags&NUBUS_DEVICE_ACTIVE)? + "[active]":"[unused]"); + return strlen(ptr); +} + +int get_nubus_list(char *buf) +{ + int nprinted, len, size; + int slot; +#define MSG "\nwarning: page-size limit reached!\n" + + /* reserve same for truncation warning message: */ + size = PAGE_SIZE - (strlen(MSG) + 1); + len = sprintf(buf, "Nubus devices found:\n"); + + for (slot=0; slot< 16; slot++) + { + if(!(nubus_slots[slot].slot_flags&NUBUS_DEVICE_PRESENT)) + continue; + nprinted = sprint_nubus_config(slot, buf + len, size - len); + if (nprinted < 0) { + return len + sprintf(buf + len, MSG); + } + len += nprinted; + } + return len; +} + +static struct proc_dir_entry proc_nubus = { + PROC_NUBUS, 5, "nubus", + S_IFREG | S_IRUGO, 1, 0, 0, + 0, &proc_array_inode_operations +}; +#endif + void nubus_init(void) { /* @@ -624,4 +630,7 @@ nubus_init_via(); printk("Scanning nubus slots.\n"); nubus_probe_bus(); + proc_register(&proc_root, &proc_nubus); } + + \ No newline at end of file diff -u --new-file --recursive --exclude-from ../exclude linux.vanilla/fs/proc/array.c linux/fs/proc/array.c --- linux.vanilla/fs/proc/array.c Tue Sep 8 18:58:17 1998 +++ linux/fs/proc/array.c Sun Sep 13 03:42:32 1998 @@ -1223,6 +1223,11 @@ case PROC_PCI: return get_pci_list(page); #endif + +#ifdef CONFIG_NUBUS + case PROC_NUBUS: + return get_nubus_list(page); +#endif case PROC_CPUINFO: return get_cpuinfo(page); diff -u --new-file --recursive --exclude-from ../exclude linux.vanilla/include/linux/proc_fs.h linux/include/linux/proc_fs.h --- linux.vanilla/include/linux/proc_fs.h Tue Sep 8 18:49:37 1998 +++ linux/include/linux/proc_fs.h Sun Sep 13 17:30:33 1998 @@ -23,6 +23,7 @@ PROC_CPUINFO, PROC_PCI, PROC_MCA, + PROC_NUBUS, PROC_SELF, /* will change inode # */ PROC_NET, PROC_SCSI, - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/faq.html