📄 1006.ide.patch
字号:
diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/arch/mips/tango2/setup.c linuxmips-2.4.30/arch/mips/tango2/setup.c--- linuxmips-2.4.30.ref/arch/mips/tango2/setup.c 2007-05-08 10:41:10.000000000 -0700+++ linuxmips-2.4.30/arch/mips/tango2/setup.c 2007-05-08 10:41:54.000000000 -0700@@ -34,6 +34,8 @@ #include <asm/tango2/tango2.h> #include <asm/tango2/rmdefs.h> +extern int em86xx_sbox_init(void);+ void tango2_restart(char *command) { unsigned long flags, tmp;@@ -213,5 +215,27 @@ /* Initialize Switch box */ em86xx_sbox_init();++#ifdef CONFIG_TANGO2_HACK+ /* This portion will be done in bootloader later */+ + gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_default_timing, 0x10101010);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_CS_config, 0x00001044);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_timing0, 0x10101010);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_use_timing0, 0x000001f4);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_timing1, 0x00110101);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_use_timing1, 0x000003f3);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_timing2, 0);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_use_timing2, 0);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_timing3, 0);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_use_timing3, 0);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_timing4, 0);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_use_timing4, 0);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_timing5, 0);+ gbus_write_uint32(pGBus, REG_BASE_host_interface + PB_use_timing5, 0);+ + // use GPIO#8, IRQ 14 for PCI IRQ, ISA IDE uses GPIO#6.+ gbus_write_uint32(pGBus, REG_BASE_system_block + SYS_gpio_int, 0x0607080d);+#endif } diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/drivers/cdrom/cdrom.c linuxmips-2.4.30/drivers/cdrom/cdrom.c--- linuxmips-2.4.30.ref/drivers/cdrom/cdrom.c 2004-11-29 09:47:16.000000000 -0800+++ linuxmips-2.4.30/drivers/cdrom/cdrom.c 2007-05-08 10:41:54.000000000 -0700@@ -268,6 +268,7 @@ #include <asm/fcntl.h> #include <asm/segment.h> #include <asm/uaccess.h>+#include <asm/io.h> /* used to tell the module to turn on full debugging messages */ static int debug;@@ -285,6 +286,10 @@ MODULE_PARM(lockdoor, "i"); MODULE_PARM(check_media_type, "i"); +#ifdef CONFIG_SD_CDROM_DIRECT_DMA+extern int is_contiguous_memory(unsigned long address, unsigned int len, unsigned long *physaddr);+#endif+ #if (ERRLOGMASK!=CD_NOTHING) #define cdinfo(type, fmt, args...) \ if ((ERRLOGMASK & type) || debug==1 ) \@@ -436,6 +441,34 @@ return 0; } +int cdrom_get_media_event(struct cdrom_device_info *cdi,+ struct media_event_desc *med)+{+ struct cdrom_generic_command cgc;+ unsigned char buffer[8];+ struct event_header *eh = (struct event_header *) buffer;++ init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);+ cgc.cmd[0] = GPCMD_GET_EVENT_STATUS_NOTIFICATION;+ cgc.cmd[1] = 1; /* IMMED */+ cgc.cmd[4] = 1 << 4; /* media event */+ cgc.cmd[8] = sizeof(buffer);+ cgc.quiet = 1;++ if (cdi->ops->generic_packet(cdi, &cgc))+ return 1;++ if (be16_to_cpu(eh->data_len) < sizeof(*med))+ return 1;++ if (eh->nea || eh->notification_class != 0x4)+ return 1;++ memcpy(med, &buffer[sizeof(*eh)], sizeof(*med));+ return 0;+}++ struct cdrom_device_info *cdrom_find_device(kdev_t dev) { struct cdrom_device_info *cdi;@@ -553,6 +586,8 @@ } else { cdinfo(CD_OPEN, "wrong media type, but CDO_CHECK_TYPE not set.\n");+ ret=-EMEDIUMTYPE;+ goto clean_up_and_return; } } @@ -871,10 +906,12 @@ tracks->xa=0; tracks->error=0; cdinfo(CD_COUNT_TRACKS, "entering cdrom_count_tracks\n"); +#if 0 if (!CDROM_CAN(CDC_PLAY_AUDIO)) { tracks->error=CDS_NO_INFO; return; } +#endif /* Grab the TOC header so we can see how many tracks there are */ if ((ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCHDR, &header))) { if (ret == -ENOMEDIUM)@@ -1875,51 +1912,246 @@ struct request_sense *usense, sense; unsigned char *ubuf; int ret;+ void *alloc_ptr = NULL; /* Not NULL: direct buffer not used */+#ifdef CONFIG_SD_CDROM_DIRECT_DMA+ u32 paddr;+ int try_ddma = 0;+#endif if (cgc->data_direction == CGC_DATA_UNKNOWN) return -EINVAL; - if (cgc->buflen < 0 || cgc->buflen >= 131072)- return -EINVAL;+#ifdef CONFIG_SD_CDROM_DIRECT_DMA+ try_ddma = (((+ cgc->cmd[0] == GPCMD_READ_10 || cgc->cmd[0] == GPCMD_READ_CD ||+ cgc->cmd[0] == GPCMD_WRITE_10 || cgc->cmd[0] == GPCMD_WRITE_AND_VERIFY_10 ||+ cgc->cmd[0] == GPCMD_VERIFY_10+ ) /* READ_10 , READ_CD, WRITE_10, VERIFY_10, or WRITE_AND_VERIFY_10 */+ && (cgc->buffer != NULL) /* user specified buffer existed */ + && ((((u32)cgc->buffer) & (PAGE_SIZE - 1)) == 0) /* buffer aligned by page */+ && ((cgc->buflen & (PAGE_SIZE - 1)) == 0) /* size aligned by page */+ && (cgc->buflen >= 131072) /* size >= 128KB */ ) ? 1 : 0);+#endif++#ifdef CONFIG_SD_CDROM_DIRECT_DMA+ if (try_ddma == 0) { /* not DDMA, check the size for allocation */+#endif+#ifndef MAX_KMALLOC_ORDER+ if (cgc->buflen < 0 || cgc->buflen >= 131072) + return -EINVAL;+#else+ if (cgc->buflen < 0 || cgc->buflen >= (PAGE_SIZE<<MAX_KMALLOC_ORDER)) + return -EINVAL;+#endif+#ifdef CONFIG_SD_CDROM_DIRECT_DMA+ }+#endif usense = cgc->sense; cgc->sense = &sense;- if (usense && !access_ok(VERIFY_WRITE, usense, sizeof(*usense))) {+ if (usense && !access_ok(VERIFY_WRITE, usense, sizeof(*usense))) return -EFAULT;- } ubuf = cgc->buffer;- if (cgc->data_direction == CGC_DATA_READ ||- cgc->data_direction == CGC_DATA_WRITE) {- cgc->buffer = kmalloc(cgc->buflen, GFP_KERNEL);- if (cgc->buffer == NULL)- return -ENOMEM;- }-+ cgc->reserved[0] = NULL; - if (cgc->data_direction == CGC_DATA_READ) {- if (!access_ok(VERIFY_READ, ubuf, cgc->buflen)) {- kfree(cgc->buffer);+ if (cgc->data_direction == CGC_DATA_READ) { + /* first check for access */+ if (!access_ok(VERIFY_WRITE, ubuf, cgc->buflen)) return -EFAULT;++#ifdef CONFIG_SD_CDROM_DIRECT_DMA+ if (try_ddma != 0) { /* try to see if we can do DDMA */+ if (is_contiguous_memory((u32)ubuf, cgc->buflen, &paddr)) { /* physically contiguous? yes */+ u32 i, sz;+ for (i = 0, sz = cgc->buflen; (i < 12) && ((sz & 1) == 0); i++, sz >>= 1)+ ; + if (sz < 8192) { /* can be done with direct DMA */+// printk("Kernel memory = Vaddr(0x%08lx) Paddr(0x%08lx-0x%08lx)\n", (u32)ubuf, paddr, paddr + cgc->buflen);+ dma_cache_inv((u32)ubuf, cgc->buflen); /* Invalidate the cache */+ cgc->reserved[0] = (void *)paddr; /* use physical */+ }+ }+ } +#endif /* CONFIG_SD_CDROM_DIRECT_DMA */++ if (cgc->reserved[0] == NULL) { /* direct DMA not possible */+#ifdef CONFIG_SD_CDROM_DIRECT_DMA+ if (try_ddma != 0) {+#ifndef MAX_KMALLOC_ORDER+ return -EINVAL; /* should not happen here */+#else+ if (cgc->buflen >= (PAGE_SIZE<<MAX_KMALLOC_ORDER)) + return -EINVAL;+#endif+ }+#endif+ alloc_ptr = cgc->buffer = kmalloc(cgc->buflen, GFP_KERNEL);+ if (cgc->buffer == NULL) + return -ENOMEM; } } else if (cgc->data_direction == CGC_DATA_WRITE) {- if (copy_from_user(cgc->buffer, ubuf, cgc->buflen)) {- kfree(cgc->buffer);+ if (!access_ok(VERIFY_READ, ubuf, cgc->buflen)) return -EFAULT;++#ifdef CONFIG_SD_CDROM_DIRECT_DMA+ if (try_ddma != 0) { /* try to see if we can do DDMA */+ if (is_contiguous_memory((u32)ubuf, cgc->buflen, &paddr)) { /* physically contiguous? yes */+ u32 i, sz;+ for (i = 0, sz = cgc->buflen; (i < 12) && ((sz & 1) == 0); i++, sz >>= 1)+ ; + if (sz < 8192) { /* can be done with direct DMA */+// printk("Kernel memory = Vaddr(0x%08lx) Paddr(0x%08lx-0x%08lx)\n", (u32)ubuf, paddr, paddr + cgc->buflen);+ dma_cache_wback_inv((u32)ubuf, cgc->buflen); /* WB and Invalidate the cache */+ cgc->reserved[0] = (void *)paddr; /* use physical */+ }+ }+ }+#endif /* CONFIG_SD_CDROM_DIRECT_DMA */++ if (cgc->reserved[0] == NULL) { /* direct DMA not possible */+#ifdef CONFIG_SD_CDROM_DIRECT_DMA+ if (try_ddma != 0) {+#ifndef MAX_KMALLOC_ORDER+ return -EINVAL; /* should not happen here */+#else+ if (cgc->buflen >= (PAGE_SIZE<<MAX_KMALLOC_ORDER)) + return -EINVAL;+#endif+ }+#endif+ alloc_ptr = cgc->buffer = kmalloc(cgc->buflen, GFP_KERNEL);+ if (cgc->buffer == NULL) + return -ENOMEM;+ }++ if (alloc_ptr != NULL) {+ if (copy_from_user(cgc->buffer, ubuf, cgc->buflen)) {+ kfree(cgc->buffer);+ return -EFAULT;+ } } } ret = cdi->ops->generic_packet(cdi, cgc); __copy_to_user(usense, cgc->sense, sizeof(*usense));- if (!ret && cgc->data_direction == CGC_DATA_READ)- __copy_to_user(ubuf, cgc->buffer, cgc->buflen);- if (cgc->data_direction == CGC_DATA_READ ||- cgc->data_direction == CGC_DATA_WRITE) {- kfree(cgc->buffer);++ if (!ret && cgc->data_direction == CGC_DATA_READ) {+ if (alloc_ptr != NULL) + __copy_to_user(ubuf, cgc->buffer, cgc->buflen);+ }++ if (alloc_ptr != NULL)+ kfree(alloc_ptr);++ return ret;+}++#ifdef CONFIG_SD_CDROM_DMAPACKET++/*+ * CDROM audio read, with DMA support. Added in 2.4.18-pre4, akpm.+ *+ * Initially, we try to perform multiframe bus-mastering. If the IDE+ * layer experiences a DMA error, we fall back to single-frame DMA.+ * If the IDE layer again detects a DMA error, we fall back to multiframe+ * PIO.+ *+ * We do not want to disable drive-level DMA at any stage, because+ * some devices can perform non-packet DMA quite happily, but appear+ * to not be able to perform packet DMA correctly.+ *+ * If the drive is not using_dma, we never attempt packet DMA.+ */+static int cdda_read_audio(int cmd,+ struct cdrom_device_info *cdi,+ struct cdrom_generic_command *cgc,+ struct cdrom_read_audio *ra)+{+ int lba;+ unsigned frames_todo;+ int ret;+ void *xferbuf = 0;+ unsigned nr_local_frames;+ char *useraddr;++ ret = -EINVAL;+ if (ra->addr_format == CDROM_MSF) {+ lba = msf_to_lba(ra->addr.msf.minute,+ ra->addr.msf.second,+ ra->addr.msf.frame);+ } else if (ra->addr_format == CDROM_LBA) {+ lba = ra->addr.lba;+ } else {+ goto out; }++ if (lba < 0 || ra->nframes <= 0)+ goto out;++ /*+ * We can't sensibly support more that 64k because we later+ * use a buffer_head to map the temp buffer. And b_count is+ * unisgned short.+ */+ nr_local_frames = ra->nframes;+ if (nr_local_frames * CD_FRAMESIZE_RAW > 32768)+ nr_local_frames = 32768 / CD_FRAMESIZE_RAW;++ if (cdi->dma_mode == CDROM_DMA_SINGLE)+ nr_local_frames = 1;++ do {+ xferbuf = kmalloc(CD_FRAMESIZE_RAW * nr_local_frames, GFP_KERNEL);+ } while (!xferbuf && nr_local_frames--);+ ret = -ENOMEM;+ if (!xferbuf)+ goto out;++ cgc->buffer = xferbuf;+ cgc->data_direction = CGC_DATA_READ;+ if (cdi->dma_mode != CDROM_DMA_NONE)+ cgc->do_dma = 1;+ frames_todo = ra->nframes;+ useraddr = ra->buf;+retry:+ while (frames_todo) {+ unsigned frames_now = min(frames_todo, nr_local_frames);++ cgc->dma_error = 0;+ ret = cdrom_read_block(cdi, cgc, lba, frames_now, 1, CD_FRAMESIZE_RAW);+ if (ret) {+ /*+ * Here we implement DMA size fallback+ */+ if (cgc->dma_error && cdi->dma_mode == CDROM_DMA_MULTI) {+ printk(KERN_WARNING "CDROM: falling back to "+ "single frame DMA\n");+ cdi->dma_mode = CDROM_DMA_SINGLE;+ nr_local_frames = 1;+ goto retry;+ } else if (cgc->dma_error && cdi->dma_mode == CDROM_DMA_SINGLE) {+ printk(KERN_WARNING "CDROM: disabled DMA\n");+ cdi->dma_mode = CDROM_DMA_NONE;+ goto retry;+ }+ goto out;+ }+ ret = -EFAULT;+ if (copy_to_user(useraddr, cgc->buffer, CD_FRAMESIZE_RAW * frames_now))+ goto out;+ useraddr += CD_FRAMESIZE_RAW * frames_now;+ frames_todo -= frames_now;+ lba += frames_now;+ }+ ret = 0;+out:+ kfree(xferbuf); return ret; } +#endif+ static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -