source: patches/linux-2.6.17.6-mips_fixes-1.patch@ 53823ce

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 53823ce was d75f6d0, checked in by Jim Gifford <clfs@…>, 18 years ago

Updates to Patches for 2.6.17.6

  • Property mode set to 100644
File size: 10.0 KB
RevLine 
[a66a890]1Submitted By: Jim Gifford (patches at jg555 dot com)
2Date: 2006-07-08
3Initial Package Version: 2.6.17.4
4Origin: Linux-MIPS Mailing List
5Upstream Status: Not Applied
6Description: These are patches that have not been accepted by
7 Linux-MIPS.
8
9 1 - iomap for MIPS - iomap.c io.h
10 2 - Cobalt ide fixes
11
12diff -Naur linux-2.6.17.4/arch/mips/lib/iomap.c linux-2.6.17.4.kernel/arch/mips/lib/iomap.c
13--- linux-2.6.17.4/arch/mips/lib/iomap.c 1969-12-31 16:00:00.000000000 -0800
14+++ linux-2.6.17.4.kernel/arch/mips/lib/iomap.c 2006-06-30 10:37:38.000000000 -0700
15@@ -0,0 +1,78 @@
16+/*
17+ * iomap.c, Memory Mapped I/O routines for MIPS architecture.
18+ *
19+ * This code is based on lib/iomap.c, by Linus Torvalds.
20+ *
21+ * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
22+ *
23+ * This program is free software; you can redistribute it and/or modify
24+ * it under the terms of the GNU General Public License as published by
25+ * the Free Software Foundation; either version 2 of the License, or
26+ * (at your option) any later version.
27+ *
28+ * This program is distributed in the hope that it will be useful,
29+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
30+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31+ * GNU General Public License for more details.
32+ *
33+ * You should have received a copy of the GNU General Public License
34+ * along with this program; if not, write to the Free Software
35+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36+ */
37+#include <linux/ioport.h>
38+#include <linux/module.h>
39+#include <linux/pci.h>
40+
41+#include <asm/io.h>
42+
43+void __iomem *ioport_map(unsigned long port, unsigned int nr)
44+{
45+ unsigned long end;
46+
47+ end = port + nr - 1UL;
48+ if (ioport_resource.start > port ||
49+ ioport_resource.end < end || port > end)
50+ return NULL;
51+
52+ return (void __iomem *)(mips_io_port_base + port);
53+}
54+
55+void ioport_unmap(void __iomem *addr)
56+{
57+}
58+EXPORT_SYMBOL(ioport_map);
59+EXPORT_SYMBOL(ioport_unmap);
60+
61+void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
62+{
63+ unsigned long start, len, flags;
64+
65+ if (dev == NULL)
66+ return NULL;
67+
68+ start = pci_resource_start(dev, bar);
69+ len = pci_resource_len(dev, bar);
70+ if (!start || !len)
71+ return NULL;
72+
73+ if (maxlen != 0 && len > maxlen)
74+ len = maxlen;
75+
76+ flags = pci_resource_flags(dev, bar);
77+ if (flags & IORESOURCE_IO)
78+ return ioport_map(start, len);
79+ if (flags & IORESOURCE_MEM) {
80+ if (flags & IORESOURCE_CACHEABLE)
81+ return ioremap_cachable(start, len);
82+ return ioremap_nocache(start, len);
83+ }
84+
85+ return NULL;
86+}
87+
88+void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
89+{
90+ iounmap(addr);
91+}
92+EXPORT_SYMBOL(pci_iomap);
93+EXPORT_SYMBOL(pci_iounmap);
94diff -Naur linux-2.6.17.4/arch/mips/lib/Makefile linux-2.6.17.4.kernel/arch/mips/lib/Makefile
95--- linux-2.6.17.4/arch/mips/lib/Makefile 2006-07-02 01:53:19.000000000 -0700
96+++ linux-2.6.17.4.kernel/arch/mips/lib/Makefile 2006-07-07 12:40:23.000000000 -0700
97@@ -5,6 +5,8 @@
98 lib-y += csum_partial_copy.o memcpy.o promlib.o strlen_user.o strncpy_user.o \
99 strnlen_user.o uncached.o
100
101+obj-y += iomap.o
102+
103 # libgcc-style stuff needed in the kernel
104 lib-y += ashldi3.o ashrdi3.o lshrdi3.o
105
106diff -Naur linux-2.6.17.4/include/asm-mips/io.h linux-2.6.17.4.kernel/include/asm-mips/io.h
107--- linux-2.6.17.4/include/asm-mips/io.h 2006-07-02 01:53:19.000000000 -0700
108+++ linux-2.6.17.4.kernel/include/asm-mips/io.h 2006-07-07 12:44:03.000000000 -0700
109@@ -519,6 +519,34 @@
110 }
111
112 /*
113+ * Memory Mapped I/O
114+ */
115+#define ioread8(addr) readb(addr)
116+#define ioread16(addr) readw(addr)
117+#define ioread32(addr) readl(addr)
118+
119+#define iowrite8(b,addr) writeb(b,addr)
120+#define iowrite16(w,addr) writew(w,addr)
121+#define iowrite32(l,addr) writel(l,addr)
122+
123+#define ioread8_rep(a,b,c) readsb(a,b,c)
124+#define ioread16_rep(a,b,c) readsw(a,b,c)
125+#define ioread32_rep(a,b,c) readsl(a,b,c)
126+
127+#define iowrite8_rep(a,b,c) writesb(a,b,c)
128+#define iowrite16_rep(a,b,c) writesw(a,b,c)
129+#define iowrite32_rep(a,b,c) writesl(a,b,c)
130+
131+/* Create a virtual mapping cookie for an IO port range */
132+extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
133+extern void ioport_unmap(void __iomem *);
134+
135+/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
136+struct pci_dev;
137+extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
138+extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
139+
140+/*
141 * ISA space is 'always mapped' on currently supported MIPS systems, no need
142 * to explicitly ioremap() it. The fact that the ISA IO space is mapped
143 * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
144diff -Naur linux-2.6.17.4/include/asm-mips/mach-cobalt/ide.h linux-2.6.17.4.kernel/include/asm-mips/mach-cobalt/ide.h
145--- linux-2.6.17.4/include/asm-mips/mach-cobalt/ide.h 1969-12-31 16:00:00.000000000 -0800
146+++ linux-2.6.17.4.kernel/include/asm-mips/mach-cobalt/ide.h 2006-07-07 12:40:46.000000000 -0700
147@@ -0,0 +1,83 @@
148+
149+/*
150+ * PIO "in" transfers can cause D-cache lines to be allocated
151+ * to the data being read. If the target is the page cache then
152+ * the kernel can create a user space mapping of the same page
153+ * without flushing it from the D-cache. This has large potential
154+ * to create cache aliases. The Cobalts seem to trigger this
155+ * problem easily.
156+ *
157+ * MIPs doesn't have a flush_dcache_range() so we roll
158+ * our own.
159+ *
160+ * -- pdh
161+ */
162+
163+#define MAX_HWIFS 2
164+
165+#include <asm/r4kcache.h>
166+
167+static inline void __flush_dcache(void)
168+{
169+ unsigned long dc_size, dc_line, addr, end;
170+
171+ dc_size = current_cpu_data.dcache.ways << current_cpu_data.dcache.waybit;
172+ dc_line = current_cpu_data.dcache.linesz;
173+
174+ addr = CKSEG0;
175+ end = addr + dc_size;
176+
177+ for (; addr < end; addr += dc_line)
178+ flush_dcache_line_indexed(addr);
179+}
180+
181+static inline void __flush_dcache_range(unsigned long start, unsigned long end)
182+{
183+ unsigned long dc_size, dc_line, addr;
184+
185+ dc_size = current_cpu_data.dcache.ways << current_cpu_data.dcache.waybit;
186+ dc_line = current_cpu_data.dcache.linesz;
187+
188+ addr = start & ~(dc_line - 1);
189+ end += dc_line - 1;
190+
191+ if (end - addr < dc_size)
192+ for (; addr < end; addr += dc_line)
193+ flush_dcache_line(addr);
194+ else
195+ __flush_dcache();
196+}
197+
198+static inline void __ide_insw(unsigned long port, void *addr, unsigned int count)
199+{
200+ insw(port, addr, count);
201+
202+ __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 2);
203+}
204+
205+static inline void __ide_insl(unsigned long port, void *addr, unsigned int count)
206+{
207+ insl(port, addr, count);
208+
209+ __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 4);
210+}
211+
212+static inline void __ide_mm_insw(volatile void __iomem *port, void *addr, unsigned int count)
213+{
214+ readsw(port, addr, count);
215+
216+ __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 2);
217+}
218+
219+static inline void __ide_mm_insl(volatile void __iomem *port, void *addr, unsigned int count)
220+{
221+ readsl(port, addr, count);
222+
223+ __flush_dcache_range((unsigned long) addr, (unsigned long) addr + count * 4);
224+}
225+
226+#define insw __ide_insw
227+#define insl __ide_insl
228+
229+#define __ide_mm_outsw writesw
230+#define __ide_mm_outsl writesl
[31d07f11]231diff -Naur linux-2.6.17.4/arch/mips/lib/ashldi3.c linux-2.6.17.4/arch/mips/lib/ashldi3.c
232--- linux-2.6.17.4/arch/mips/lib/ashldi3.c 1969-12-31 16:00:00.000000000 -0800
233+++ linux-2.6.17.4/arch/mips/lib/ashldi3.c 2006-06-19 18:16:13.000000000 -0700
234@@ -0,0 +1,29 @@
235+#include <linux/module.h>
236+
237+#include "libgcc.h"
238+
239+long long __ashldi3(long long u, word_type b)
240+{
241+ DWunion uu, w;
242+ word_type bm;
243+
244+ if (b == 0)
245+ return u;
246+
247+ uu.ll = u;
248+ bm = 32 - b;
249+
250+ if (bm <= 0) {
251+ w.s.low = 0;
252+ w.s.high = (unsigned int) uu.s.low << -bm;
253+ } else {
254+ const unsigned int carries = (unsigned int) uu.s.low >> bm;
255+
256+ w.s.low = (unsigned int) uu.s.low << b;
257+ w.s.high = ((unsigned int) uu.s.high << b) | carries;
258+ }
259+
260+ return w.ll;
261+}
262+
263+EXPORT_SYMBOL(__ashldi3);
264diff -Naur linux-2.6.17.4/arch/mips/lib/ashrdi3.c linux-2.6.17.4/arch/mips/lib/ashrdi3.c
265--- linux-2.6.17.4/arch/mips/lib/ashrdi3.c 1969-12-31 16:00:00.000000000 -0800
266+++ linux-2.6.17.4/arch/mips/lib/ashrdi3.c 2006-06-19 18:16:13.000000000 -0700
267@@ -0,0 +1,31 @@
268+#include <linux/module.h>
269+
270+#include "libgcc.h"
271+
272+long long __ashrdi3(long long u, word_type b)
273+{
274+ DWunion uu, w;
275+ word_type bm;
276+
277+ if (b == 0)
278+ return u;
279+
280+ uu.ll = u;
281+ bm = 32 - b;
282+
283+ if (bm <= 0) {
284+ /* w.s.high = 1..1 or 0..0 */
285+ w.s.high =
286+ uu.s.high >> 31;
287+ w.s.low = uu.s.high >> -bm;
288+ } else {
289+ const unsigned int carries = (unsigned int) uu.s.high << bm;
290+
291+ w.s.high = uu.s.high >> b;
292+ w.s.low = ((unsigned int) uu.s.low >> b) | carries;
293+ }
294+
295+ return w.ll;
296+}
297+
298+EXPORT_SYMBOL(__ashrdi3);
299diff -Naur linux-2.6.17.4/arch/mips/lib/libgcc.h linux-2.6.17.4/arch/mips/lib/libgcc.h
300--- linux-2.6.17.4/arch/mips/lib/libgcc.h 1969-12-31 16:00:00.000000000 -0800
301+++ linux-2.6.17.4/arch/mips/lib/libgcc.h 2006-06-19 18:16:13.000000000 -0700
302@@ -0,0 +1,26 @@
303+#ifndef __ASM_LIBGCC_H
304+#define __ASM_LIBGCC_H
305+
306+#include <asm/byteorder.h>
307+
308+typedef int word_type __attribute__ ((mode (__word__)));
309+
310+#ifdef __BIG_ENDIAN
311+struct DWstruct {
312+ int high, low;
313+};
314+#elif defined(__LITTLE_ENDIAN)
315+struct DWstruct {
316+ int low, high;
317+};
318+#else
319+#error I feel sick.
320+#endif
321+
322+typedef union
323+{
324+ struct DWstruct s;
325+ long long ll;
326+} DWunion;
327+
328+#endif /* __ASM_LIBGCC_H */
329diff -Naur linux-2.6.17.4/arch/mips/lib/lshrdi3.c linux-2.6.17.4/arch/mips/lib/lshrdi3.c
330--- linux-2.6.17.4/arch/mips/lib/lshrdi3.c 1969-12-31 16:00:00.000000000 -0800
331+++ linux-2.6.17.4/arch/mips/lib/lshrdi3.c 2006-06-19 18:16:13.000000000 -0700
332@@ -0,0 +1,29 @@
333+#include <linux/module.h>
334+
335+#include "libgcc.h"
336+
337+long long __lshrdi3(long long u, word_type b)
338+{
339+ DWunion uu, w;
340+ word_type bm;
341+
342+ if (b == 0)
343+ return u;
344+
345+ uu.ll = u;
346+ bm = 32 - b;
347+
348+ if (bm <= 0) {
349+ w.s.high = 0;
350+ w.s.low = (unsigned int) uu.s.high >> -bm;
351+ } else {
352+ const unsigned int carries = (unsigned int) uu.s.high << bm;
353+
354+ w.s.high = (unsigned int) uu.s.high >> b;
355+ w.s.low = ((unsigned int) uu.s.low >> b) | carries;
356+ }
357+
358+ return w.ll;
359+}
360+
361+EXPORT_SYMBOL(__lshrdi3);
Note: See TracBrowser for help on using the repository browser.