summaryrefslogtreecommitdiff
path: root/recipes/ixp4xx/ixp-osal-1.5/2.6.patch
blob: 3e47fe28def957c37fd867b7899df2944c749d77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
diff -Naur ixp_osal.orig/Makefile ixp_osal/Makefile
--- ixp_osal.orig/Makefile	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/Makefile	2005-08-24 00:18:02.000000000 +0200
@@ -172,7 +172,7 @@
 
 # TODO push this to linux make
 ifeq ($(IX_OSAL_MK_HOST_OS), linux)
-INCLUDE_DIRS += $(LINUX_SRC)/include/asm-arm/arch-ixp425/
+INCLUDE_DIRS += $(LINUX_SRC)/include/asm-arm/arch-ixp4xx/
 endif
 
 CFLAGS += $(INCLUDE_DIRS:%=-I%)
diff -Naur ixp_osal.orig/include/linux-2.6.h ixp_osal/include/linux-2.6.h
--- ixp_osal.orig/include/linux-2.6.h	1970-01-01 01:00:00.000000000 +0100
+++ ixp_osal/include/linux-2.6.h	2005-08-26 15:20:23.000000000 +0200
@@ -0,0 +1,52 @@
+/* */
+
+#include "asm/page.h"
+
+#if !defined (IXP425_TIMER_BASE_PHYS)
+# define IXP425_TIMER_BASE_PHYS 	IXP4XX_TIMER_BASE_PHYS
+#endif
+#if !defined (IRQ_IXP425_XSCALE_PMU)
+# define IRQ_IXP425_XSCALE_PMU		IRQ_IXP4XX_XSCALE_PMU
+#endif
+#if !defined (IXP425_QMGR_BASE_PHYS)
+# define IXP425_QMGR_BASE_PHYS		IXP4XX_QMGR_BASE_PHYS
+#endif
+#if !defined (IXP425_PERIPHERAL_BASE_PHYS)
+# define IXP425_PERIPHERAL_BASE_PHYS	IXP4XX_PERIPHERAL_BASE_PHYS
+#endif
+#if !defined (IXP425_PERIPHERAL_BASE_VIRT)
+# define IXP425_PERIPHERAL_BASE_VIRT	IXP4XX_PERIPHERAL_BASE_VIRT
+#endif
+#if !defined (IXP425_EXP_CFG_BASE_PHYS)
+# define IXP425_EXP_CFG_BASE_PHYS	IXP4XX_EXP_CFG_BASE_PHYS
+#endif
+#if !defined (IXP425_EXP_CFG_BASE_VIRT)
+# define IXP425_EXP_CFG_BASE_VIRT	IXP4XX_EXP_CFG_BASE_VIRT
+#endif
+#if !defined (IXP425_PCI_CFG_BASE_PHYS)
+# define IXP425_PCI_CFG_BASE_PHYS	IXP4XX_PCI_CFG_BASE_PHYS
+#endif
+#if !defined (IXP425_PCI_CFG_BASE_VIRT)
+# define IXP425_PCI_CFG_BASE_VIRT	IXP4XX_PCI_CFG_BASE_VIRT
+#endif
+#if !defined (IXP425_EXP_BUS_BASE2_PHYS)
+# define IXP425_EXP_BUS_BASE2_PHYS	IXP4XX_EXP_BUS_CS2_BASE_PHYS
+#endif
+#if !defined (IXP425_EthA_BASE_PHYS)
+# define IXP425_EthA_BASE_PHYS		(IXP4XX_PERIPHERAL_BASE_PHYS + 0x9000)
+#endif
+#if !defined (IXP425_EthB_BASE_PHYS)
+# define IXP425_EthB_BASE_PHYS		(IXP4XX_PERIPHERAL_BASE_PHYS + 0xA000)
+#endif
+#if !defined (IXP425_ICMR)
+# define IXP425_ICMR			IXP4XX_ICMR
+#endif
+#if !defined (IXP425_USB_BASE_PHYS)
+# define IXP425_USB_BASE_PHYS		IXP4XX_USB_BASE_PHYS
+#endif
+#if !defined (IXP425_INTC_BASE_PHYS)
+# define IXP425_INTC_BASE_PHYS		IXP4XX_INTC_BASE_PHYS
+#endif
+#if !defined (IRQ_IXP425_USB)
+# define IRQ_IXP425_USB			IRQ_IXP4XX_USB
+#endif
diff -Naur ixp_osal.orig/os/linux/include/core/IxOsalOs.h ixp_osal/os/linux/include/core/IxOsalOs.h
--- ixp_osal.orig/os/linux/include/core/IxOsalOs.h	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/include/core/IxOsalOs.h	2005-08-26 01:56:22.000000000 +0200
@@ -56,6 +56,7 @@
 #include <linux/cache.h>
 #include <linux/mm.h>
 #include <linux/config.h>
+#include <linux/version.h>
 #include <asm/pgalloc.h>
 
 /**
@@ -66,9 +67,23 @@
 
 #define IX_OSAL_OS_MMU_PHYS_TO_VIRT(addr)  ((addr) ? phys_to_virt((unsigned int)(addr)) : 0)
 
-#define IX_OSAL_OS_CACHE_INVALIDATE(addr, size)  ( invalidate_dcache_range((__u32)addr, (__u32)addr + size )) 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+/*
+ * 2.6 kernels do not export the required cache functions.
+ */
+extern void ixOsalCacheInvalidateRange(unsigned long start, unsigned long size);
+extern void ixOsalCacheFlushRange(unsigned long start, unsigned long size);
+
+#define IX_OSAL_OS_CACHE_INVALIDATE(addr, size) \
+ixOsalCacheInvalidateRange((unsigned long)addr, (unsigned long)addr + size)
+#define IX_OSAL_OS_CACHE_FLUSH(addr, size) \
+ixOsalCacheFlushRange((unsigned long)addr, (unsigned long)addr + size )
 
+#else
+
+#define IX_OSAL_OS_CACHE_INVALIDATE(addr, size)  ( invalidate_dcache_range((__u32)addr, (__u32)addr + size )) 
 #define IX_OSAL_OS_CACHE_FLUSH(addr, size) ( clean_dcache_range((__u32)addr, (__u32)addr + size ))
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) */
 
 #define printf	printk /* For backword compatibility, needs to move to better location */
 
diff -Naur ixp_osal.orig/os/linux/include/platforms/ixp400/IxOsalOsIxp400.h ixp_osal/os/linux/include/platforms/ixp400/IxOsalOsIxp400.h
--- ixp_osal.orig/os/linux/include/platforms/ixp400/IxOsalOsIxp400.h	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/include/platforms/ixp400/IxOsalOsIxp400.h	2005-08-26 15:20:23.000000000 +0200
@@ -53,6 +53,8 @@
 #include "asm/hardware.h"
 #include "asm/arch/irqs.h"
 
+#include <linux-2.6.h>		/* Glue */
+
 /* physical addresses to be used when requesting memory with IX_OSAL_MEM_MAP */
 #define IX_OSAL_IXP400_INTC_PHYS_BASE          IXP425_INTC_BASE_PHYS
 #define IX_OSAL_IXP400_GPIO_PHYS_BASE          IXP425_GPIO_BASE_PHYS
@@ -108,7 +110,6 @@
 #define IX_OSAL_IXP400_NPEB_VIRT_BASE          IXP425_NPEB_BASE_VIRT
 #define IX_OSAL_IXP400_NPEC_VIRT_BASE          IXP425_NPEC_BASE_VIRT
 #define IX_OSAL_IXP400_PERIPHERAL_VIRT_BASE    IXP425_PERIPHERAL_BASE_VIRT
-#define IX_OSAL_IXP400_QMGR_VIRT_BASE          IXP425_QMGR_BASE_VIRT
 #define IX_OSAL_IXP400_OSTS_VIRT_BASE          IXP425_TIMER_BASE_VIRT
 #define IX_OSAL_IXP400_USB_VIRT_BASE           IXP425_USB_BASE_VIRT
 #define IX_OSAL_IXP400_EXP_CFG_VIRT_BASE       IXP425_EXP_CFG_BASE_VIRT
@@ -239,12 +240,21 @@
      * Queue Manager 
      */
     {
+#ifdef IXP425_QMGR_BASE_VIRT
      IX_OSAL_STATIC_MAP,	/* type            */
      IX_OSAL_IXP400_QMGR_PHYS_BASE,	/* physicalAddress */
      IX_OSAL_IXP400_QMGR_MAP_SIZE,	/* size            */
      IX_OSAL_IXP400_QMGR_VIRT_BASE,	/* virtualAddress  */
      NULL,			/* mapFunction     */
      NULL,			/* unmapFunction   */
+#else
+     IX_OSAL_DYNAMIC_MAP,                  /* type            */
+     IX_OSAL_IXP400_QMGR_PHYS_BASE,   /* physicalAddress */
+     IX_OSAL_IXP400_QMGR_MAP_SIZE,    /* size            */
+     0,                               /* virtualAddress  */
+     ixOsalLinuxMemMap,		/* mapFunction     */
+     ixOsalLinuxMemUnmap,	/* unmapFunction   */
+#endif
      0,				/* refCount        */
      IX_OSAL_BE | IX_OSAL_LE_DC,	/* endianType      */   
      "qMgr"			/* name            */
diff -Naur ixp_osal.orig/os/linux/make/macros.mk ixp_osal/os/linux/make/macros.mk
--- ixp_osal.orig/os/linux/make/macros.mk	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/make/macros.mk	2005-08-26 15:17:37.000000000 +0200
@@ -71,10 +71,12 @@
 ################################################################
 # Linux Compiler & linker commands
 
-ifeq ($(IX_OSAL_MK_TARGET_ENDIAN), linuxbe)
-LINUX_CROSS_COMPILE := $(HARDHAT_BASE)/devkit/arm/xscale_be/bin/xscale_be-
-else
-LINUX_CROSS_COMPILE := $(HARDHAT_BASE)/devkit/arm/xscale_le/bin/xscale_le-
+ifeq "$(LINUX_CROSS_COMPILE)" "" 
+ ifeq ($(IX_OSAL_MK_TARGET_ENDIAN), linuxbe)
+  LINUX_CROSS_COMPILE := $(HARDHAT_BASE)/devkit/arm/xscale_be/bin/xscale_be-
+ else
+  LINUX_CROSS_COMPILE := $(HARDHAT_BASE)/devkit/arm/xscale_le/bin/xscale_le-
+ endif
 endif
 
 LINUX_SRC := $($(IX_TARGET)_KERNEL_DIR)
@@ -91,9 +93,11 @@
 LINUX_MACH_CFLAGS := -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale
 
 CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -Wall -Wno-trigraphs -fno-common \
-          -pipe -mapcs-32 -mshort-load-bytes -msoft-float -DMODULE \
+          -pipe -mapcs-32 -msoft-float -DMODULE \
           -D__linux -DCPU=33 -DXSCALE=33 $(LINUX_MACH_CFLAGS) -DEXPORT_SYMTAB
 
+# -mshort-load-bytes removed by Marc Singer's patch TODO(hannes) why?
+
 # Linux linker flags
 LDFLAGS := -r
 
diff -Naur ixp_osal.orig/os/linux/src/core/IxOsalOsCacheMMU.c ixp_osal/os/linux/src/core/IxOsalOsCacheMMU.c
--- ixp_osal.orig/os/linux/src/core/IxOsalOsCacheMMU.c	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/src/core/IxOsalOsCacheMMU.c	2005-08-26 01:56:22.000000000 +0200
@@ -210,3 +210,59 @@
 	free_pages ((unsigned int) memptr, order);
     }
 }
+
+
+/*
+ * 2.6 kernels do not export the required cache functions.
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+
+#define _IX_STR(x) #x
+#define IX_STR(x) _IX_STR(x)
+#define IX_CLM IX_STR(IX_OSAL_CACHE_LINE_SIZE-1)
+
+/*
+ * reimplementation of kernel's invalidate_dcache_range()
+ */
+void
+ixOsalCacheInvalidateRange(unsigned long start, unsigned long size)
+{
+  __asm__
+    ("    tst    %0, #" IX_CLM "\n"
+     "    mcrne  p15, 0, %0, c7, c10, 1      @ clean D cache line\n"
+     "    bic    %0, %0, #" IX_CLM "\n"
+     "    tst    %1, #" IX_CLM "\n"
+     "    mcrne  p15, 0, %1, c7, c10, 1      @ clean D cache line\n"
+     "1:  mcr    p15, 0, %0, c7, c6, 1       @ invalidate D cache line\n"
+     "    add    %0, %0, #" IX_STR(IX_OSAL_CACHE_LINE_SIZE) "\n"
+     "    cmp    %0, %1\n"
+     "    blo    1b\n"
+     "    mcr    p15, 0, %0, c7, c10, 4      @ drain write & fill buffer\n"
+     : /* no output */
+     : "r"(start), "r"(size)
+     : "cc");
+}
+
+/*
+ * reimplementation of kernel's invalidate_dcache_range()
+ */
+void
+ixOsalCacheFlushRange(unsigned long start, unsigned long size)
+{
+  __asm__
+    ("    bic    %0, %0, #" IX_CLM "\n"
+     "1:  mcr    p15, 0, %0, c7, c10, 1      @ clean D cache line\n"
+     "    add    %0, %0, #" IX_STR(IX_OSAL_CACHE_LINE_SIZE) "\n"
+     "    cmp    %0, %1\n"
+     "    blo    1b\n"
+     "    mcr    p15, 0, %0, c7, c10, 4      @ drain write & fill buffer\n"
+     : /* no output */
+     : "r"(start), "r"(size)
+     : "cc");
+}
+
+#undef _IX_STR
+#undef IX_STR
+#undef IX_CLM
+
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) */
diff -Naur ixp_osal.orig/os/linux/src/core/IxOsalOsMsgQ.c ixp_osal/os/linux/src/core/IxOsalOsMsgQ.c
--- ixp_osal.orig/os/linux/src/core/IxOsalOsMsgQ.c	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/src/core/IxOsalOsMsgQ.c	2005-08-24 00:18:02.000000000 +0200
@@ -45,9 +45,9 @@
  * -- End Intel Copyright Notice --
  */
 #include <linux/linkage.h>
+#include <linux/spinlock.h>
 #include <linux/ipc.h>
 #include <linux/msg.h>
-#include <linux/spinlock.h>
 #include <linux/interrupt.h>
 
 #include "IxOsal.h"
diff -Naur ixp_osal.orig/os/linux/src/core/IxOsalOsSemaphore.c ixp_osal/os/linux/src/core/IxOsalOsSemaphore.c
--- ixp_osal.orig/os/linux/src/core/IxOsalOsSemaphore.c	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/src/core/IxOsalOsSemaphore.c	2005-08-26 15:58:16.000000000 +0200
@@ -46,7 +46,7 @@
  */
 
 #include <linux/slab.h>
-#include <asm-arm/hardirq.h>
+#include <linux/hardirq.h>
 #include "IxOsal.h"
 
 /* Define a large number */
@@ -93,7 +93,7 @@
 {
 
     IX_STATUS ixStatus = IX_SUCCESS;
-    UINT32 timeoutTime;
+    unsigned long timeoutTime;
 
     if (sid == NULL)
     {
diff -Naur ixp_osal.orig/os/linux/src/core/IxOsalOsServices.c ixp_osal/os/linux/src/core/IxOsalOsServices.c
--- ixp_osal.orig/os/linux/src/core/IxOsalOsServices.c	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/src/core/IxOsalOsServices.c	2005-08-26 15:53:22.000000000 +0200
@@ -53,6 +53,7 @@
 #include <linux/time.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/interrupt.h>
 
 #include "IxOsal.h"
 
@@ -88,7 +89,7 @@
 /*
  * General interrupt handler
  */
-static void
+static irqreturn_t
 ixOsalOsIsrProxy (int irq, void *dev_id, struct pt_regs *regs)
 {
     IxOsalInfoType *isr_proxy_info = (IxOsalInfoType *) dev_id;
@@ -97,6 +98,7 @@
 		   "ixOsalOsIsrProxy: Interrupt used before ixOsalIrqBind was invoked");
 
     isr_proxy_info->routine (isr_proxy_info->parameter);
+    return IRQ_HANDLED;
 }
 
 /*
@@ -104,11 +106,12 @@
  * This handler saves the interrupted Program Counter (PC)
  * into a global variable
  */
-static void
+static irqreturn_t
 ixOsalOsIsrProxyWithPC (int irq, void *dev_id, struct pt_regs *regs)
 {
     ixOsalLinuxInterruptedPc = regs->ARM_pc;
     ixOsalOsIsrProxy(irq, dev_id, regs);
+    return IRQ_HANDLED;
 }
 
 /**************************************
@@ -190,10 +193,15 @@
 PUBLIC UINT32
 ixOsalIrqLock ()
 {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+    unsigned long flags;
+    local_irq_save(flags);
+#else
     UINT32 flags;
     save_flags (flags);
     cli ();
-    return flags;
+#endif
+    return (UINT32)flags;
 }
 
 /* Enable interrupts and task scheduling,
@@ -203,7 +211,11 @@
 PUBLIC void
 ixOsalIrqUnlock (UINT32 lockKey)
 {
+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+    local_irq_restore((unsigned long)lockKey);
+# else
     restore_flags (lockKey);
+# endif
 }
 
 PUBLIC UINT32
@@ -315,10 +327,11 @@
 PUBLIC void
 ixOsalSleep (UINT32 milliseconds)
 {
-    if (milliseconds != 0)
+    signed long delay = milliseconds*HZ;
+    if ( delay >= 1000 )
     {
         current->state = TASK_INTERRUPTIBLE;
-        schedule_timeout ((milliseconds * HZ) / 1000);
+        schedule_timeout (delay / 1000);
     }
     else
     {
diff -Naur ixp_osal.orig/os/linux/src/core/IxOsalOsSymbols.c ixp_osal/os/linux/src/core/IxOsalOsSymbols.c
--- ixp_osal.orig/os/linux/src/core/IxOsalOsSymbols.c	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/src/core/IxOsalOsSymbols.c	2005-08-30 19:19:33.000000000 +0200
@@ -64,6 +64,10 @@
 
 EXPORT_SYMBOL (ixOsalCacheDmaMalloc);
 EXPORT_SYMBOL (ixOsalCacheDmaFree);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+EXPORT_SYMBOL (ixOsalCacheInvalidateRange);
+EXPORT_SYMBOL (ixOsalCacheFlushRange);
+#endif
 
 EXPORT_SYMBOL (ixOsalThreadCreate);
 EXPORT_SYMBOL (ixOsalThreadStart);
diff -Naur ixp_osal.orig/os/linux/src/core/IxOsalOsThread.c ixp_osal/os/linux/src/core/IxOsalOsThread.c
--- ixp_osal.orig/os/linux/src/core/IxOsalOsThread.c	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/src/core/IxOsalOsThread.c	2005-08-26 00:50:32.000000000 +0200
@@ -46,6 +46,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/version.h>
 
 #include "IxOsal.h"
 
@@ -65,11 +66,11 @@
     void *arg = IxOsalOsThreadData.arg;
     static int seq = 0;
 
-    daemonize ();
+    daemonize ("IxOsal %d", ++seq);
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
     exit_files (current);
-
-    snprintf(current->comm, sizeof(current->comm), "IxOsal %d", ++seq);
+#endif
 
     up (&IxOsalThreadMutex);
 
diff -Naur ixp_osal.orig/os/linux/src/modules/ioMem/IxOsalOsIoMem.c ixp_osal/os/linux/src/modules/ioMem/IxOsalOsIoMem.c
--- ixp_osal.orig/os/linux/src/modules/ioMem/IxOsalOsIoMem.c	2005-08-24 00:16:37.000000000 +0200
+++ ixp_osal/os/linux/src/modules/ioMem/IxOsalOsIoMem.c	2005-08-24 00:18:02.000000000 +0200
@@ -45,6 +45,7 @@
  * -- End Intel Copyright Notice --
  */
 
+#include <asm/page.h>
 #include <asm/io.h>
 #include <linux/ioport.h>