VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / arch / parisc / kernel / firmware.c
1 /*
2  * arch/parisc/kernel/firmware.c  - safe PDC access routines
3  *
4  *      PDC == Processor Dependent Code
5  *
6  * See http://www.parisc-linux.org/documentation/index.html
7  * for documentation describing the entry points and calling
8  * conventions defined below.
9  *
10  * Copyright 1999 SuSE GmbH Nuernberg (Philipp Rumpf, prumpf@tux.org)
11  * Copyright 1999 The Puffin Group, (Alex deVries, David Kennedy)
12  * Copyright 2003 Grant Grundler <grundler parisc-linux org>
13  * Copyright 2003,2004 Ryan Bradetich <rbrad@parisc-linux.org>
14  *
15  *    This program is free software; you can redistribute it and/or modify
16  *    it under the terms of the GNU General Public License as published by
17  *    the Free Software Foundation; either version 2 of the License, or
18  *    (at your option) any later version.
19  *
20  */
21
22 /*      I think it would be in everyone's best interest to follow this
23  *      guidelines when writing PDC wrappers:
24  *
25  *       - the name of the pdc wrapper should match one of the macros
26  *         used for the first two arguments
27  *       - don't use caps for random parts of the name
28  *       - use the static PDC result buffers and "copyout" to structs
29  *         supplied by the caller to encapsulate alignment restrictions
30  *       - hold pdc_lock while in PDC or using static result buffers
31  *       - use __pa() to convert virtual (kernel) pointers to physical
32  *         ones.
33  *       - the name of the struct used for pdc return values should equal
34  *         one of the macros used for the first two arguments to the
35  *         corresponding PDC call
36  *       - keep the order of arguments
37  *       - don't be smart (setting trailing NUL bytes for strings, return
38  *         something useful even if the call failed) unless you are sure
39  *         it's not going to affect functionality or performance
40  *
41  *      Example:
42  *      int pdc_cache_info(struct pdc_cache_info *cache_info )
43  *      {
44  *              int retval;
45  *
46  *              spin_lock_irq(&pdc_lock);
47  *              retval = mem_pdc_call(PDC_CACHE,PDC_CACHE_INFO,__pa(cache_info),0);
48  *              convert_to_wide(pdc_result);
49  *              memcpy(cache_info, pdc_result, sizeof(*cache_info));
50  *              spin_unlock_irq(&pdc_lock);
51  *
52  *              return retval;
53  *      }
54  *                                      prumpf  991016  
55  */
56
57 #include <stdarg.h>
58
59 #include <linux/delay.h>
60 #include <linux/init.h>
61 #include <linux/kernel.h>
62 #include <linux/module.h>
63 #include <linux/string.h>
64 #include <linux/spinlock.h>
65
66 #include <asm/page.h>
67 #include <asm/pdc.h>
68 #include <asm/pdcpat.h>
69 #include <asm/system.h>
70 #include <asm/processor.h>      /* for boot_cpu_data */
71
72 static spinlock_t pdc_lock = SPIN_LOCK_UNLOCKED;
73 static unsigned long pdc_result[32] __attribute__ ((aligned (8)));
74 static unsigned long pdc_result2[32] __attribute__ ((aligned (8)));
75
76 #ifdef __LP64__
77 #define WIDE_FIRMWARE 0x1
78 #define NARROW_FIRMWARE 0x2
79
80 /* Firmware needs to be initially set to narrow to determine the 
81  * actual firmware width. */
82 int parisc_narrow_firmware = 1;
83 #endif
84
85 /* on all currently-supported platforms, IODC I/O calls are always
86  * 32-bit calls, and MEM_PDC calls are always the same width as the OS.
87  * This means Cxxx boxes can't run wide kernels right now. -PB
88  *
89  * CONFIG_PDC_NARROW has been added to allow 64-bit kernels to run on
90  * systems with 32-bit MEM_PDC calls. This will allow wide kernels to
91  * run on Cxxx boxes now. -RB
92  *
93  * Note that some PAT boxes may have 64-bit IODC I/O...
94  */
95
96 #ifdef __LP64__
97 long real64_call(unsigned long function, ...);
98 #endif
99 long real32_call(unsigned long function, ...);
100
101 #ifdef __LP64__
102 #   define MEM_PDC (unsigned long)(PAGE0->mem_pdc_hi) << 32 | PAGE0->mem_pdc
103 #   define mem_pdc_call(args...) unlikely(parisc_narrow_firmware) ? real32_call(MEM_PDC, args) : real64_call(MEM_PDC, args)
104 #else
105 #   define MEM_PDC (unsigned long)PAGE0->mem_pdc
106 #   define mem_pdc_call(args...) real32_call(MEM_PDC, args)
107 #endif
108
109
110 /**
111  * f_extend - Convert PDC addresses to kernel addresses.
112  * @address: Address returned from PDC.
113  *
114  * This function is used to convert PDC addresses into kernel addresses
115  * when the PDC address size and kernel address size are different.
116  */
117 static unsigned long f_extend(unsigned long address)
118 {
119 #ifdef __LP64__
120         if(unlikely(parisc_narrow_firmware)) {
121                 if((address & 0xff000000) == 0xf0000000)
122                         return 0xf0f0f0f000000000 | (u32)address;
123
124                 if((address & 0xf0000000) == 0xf0000000)
125                         return 0xffffffff00000000 | (u32)address;
126         }
127 #endif
128         return address;
129 }
130
131 /**
132  * convert_to_wide - Convert the return buffer addresses into kernel addresses.
133  * @address: The return buffer from PDC.
134  *
135  * This function is used to convert the return buffer addresses retrieved from PDC
136  * into kernel addresses when the PDC address size and kernel address size are
137  * different.
138  */
139 static void convert_to_wide(unsigned long *addr)
140 {
141 #ifdef __LP64__
142         int i;
143         unsigned int *p = (unsigned int *)addr;
144
145         if(unlikely(parisc_narrow_firmware)) {
146                 for(i = 31; i >= 0; --i)
147                         addr[i] = p[i];
148         }
149 #endif
150 }
151
152 /**
153  * set_firmware_width - Determine if the firmware is wide or narrow.
154  * 
155  * This function must be called before any pdc_* function that uses the convert_to_wide
156  * function.
157  */
158 void __init set_firmware_width(void)
159 {
160 #ifdef __LP64__
161         int retval;
162
163         spin_lock_irq(&pdc_lock);
164         retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_CAPABILITIES, __pa(pdc_result), 0);
165         convert_to_wide(pdc_result);
166         if(pdc_result[0] != NARROW_FIRMWARE)
167                 parisc_narrow_firmware = 0;
168         spin_unlock_irq(&pdc_lock);
169 #endif
170 }
171
172 /**
173  * pdc_emergency_unlock - Unlock the linux pdc lock
174  *
175  * This call unlocks the linux pdc lock in case we need some PDC functions
176  * (like pdc_add_valid) during kernel stack dump.
177  */
178 void pdc_emergency_unlock(void)
179 {
180         /* Spinlock DEBUG code freaks out if we unconditionally unlock */
181         if (spin_is_locked(&pdc_lock))
182                 spin_unlock(&pdc_lock);
183 }
184
185
186 /**
187  * pdc_add_valid - Verify address can be accessed without causing a HPMC.
188  * @address: Address to be verified.
189  *
190  * This PDC call attempts to read from the specified address and verifies
191  * if the address is valid.
192  * 
193  * The return value is PDC_OK (0) in case accessing this address is valid.
194  */
195 int pdc_add_valid(unsigned long address)
196 {
197         int retval;
198
199         spin_lock_irq(&pdc_lock);
200         retval = mem_pdc_call(PDC_ADD_VALID, PDC_ADD_VALID_VERIFY, address);
201         spin_unlock_irq(&pdc_lock);
202
203         return retval;
204 }
205 EXPORT_SYMBOL(pdc_add_valid);
206
207 /**
208  * pdc_chassis_info - Return chassis information.
209  * @result: The return buffer.
210  * @chassis_info: The memory buffer address.
211  * @len: The size of the memory buffer address.
212  *
213  * An HVERSION dependent call for returning the chassis information.
214  */
215 int __init pdc_chassis_info(struct pdc_chassis_info *chassis_info, void *led_info, unsigned long len)
216 {
217         int retval;
218
219         spin_lock_irq(&pdc_lock);
220         memcpy(&pdc_result, chassis_info, sizeof(*chassis_info));
221         memcpy(&pdc_result2, led_info, len);
222         retval = mem_pdc_call(PDC_CHASSIS, PDC_RETURN_CHASSIS_INFO,
223                               __pa(pdc_result), __pa(pdc_result2), len);
224         memcpy(chassis_info, pdc_result, sizeof(*chassis_info));
225         memcpy(led_info, pdc_result2, len);
226         spin_unlock_irq(&pdc_lock);
227
228         return retval;
229 }
230
231 /**
232  * pdc_pat_chassis_send_log - Sends a PDC PAT CHASSIS log message.
233  * @retval: -1 on error, 0 on success. Other value are PDC errors
234  * 
235  * Must be correctly formatted or expect system crash
236  */
237 #ifdef __LP64__
238 int pdc_pat_chassis_send_log(unsigned long state, unsigned long data)
239 {
240         int retval = 0;
241         
242         if (!is_pdc_pat())
243                 return -1;
244
245         spin_lock_irq(&pdc_lock);
246         retval = mem_pdc_call(PDC_PAT_CHASSIS_LOG, PDC_PAT_CHASSIS_WRITE_LOG, __pa(&state), __pa(&data));
247         spin_unlock_irq(&pdc_lock);
248
249         return retval;
250 }
251 #endif
252
253 /**
254  * pdc_chassis_disp - Updates display
255  * @retval: -1 on error, 0 on success
256  *
257  * Works on old PDC only (E class, others?)
258  */
259 int pdc_chassis_disp(unsigned long disp)
260 {
261         int retval = 0;
262
263         spin_lock_irq(&pdc_lock);
264         retval = mem_pdc_call(PDC_CHASSIS, PDC_CHASSIS_DISP, disp);
265         spin_unlock_irq(&pdc_lock);
266
267         return retval;
268 }
269
270 /**
271  * pdc_coproc_cfg - To identify coprocessors attached to the processor.
272  * @pdc_coproc_info: Return buffer address.
273  *
274  * This PDC call returns the presence and status of all the coprocessors
275  * attached to the processor.
276  */
277 int __init pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info)
278 {
279         int retval;
280
281         spin_lock_irq(&pdc_lock);
282         retval = mem_pdc_call(PDC_COPROC, PDC_COPROC_CFG, __pa(pdc_result));
283         convert_to_wide(pdc_result);
284         pdc_coproc_info->ccr_functional = pdc_result[0];
285         pdc_coproc_info->ccr_present = pdc_result[1];
286         pdc_coproc_info->revision = pdc_result[17];
287         pdc_coproc_info->model = pdc_result[18];
288         spin_unlock_irq(&pdc_lock);
289
290         return retval;
291 }
292
293 /**
294  * pdc_iodc_read - Read data from the modules IODC.
295  * @actcnt: The actual number of bytes.
296  * @hpa: The HPA of the module for the iodc read.
297  * @index: The iodc entry point.
298  * @iodc_data: A buffer memory for the iodc options.
299  * @iodc_data_size: Size of the memory buffer.
300  *
301  * This PDC call reads from the IODC of the module specified by the hpa
302  * argument.
303  */
304 int pdc_iodc_read(unsigned long *actcnt, unsigned long hpa, unsigned int index,
305                   void *iodc_data, unsigned int iodc_data_size)
306 {
307         int retval;
308
309         spin_lock_irq(&pdc_lock);
310         retval = mem_pdc_call(PDC_IODC, PDC_IODC_READ, __pa(pdc_result), hpa, 
311                               index, __pa(pdc_result2), iodc_data_size);
312         convert_to_wide(pdc_result);
313         *actcnt = pdc_result[0];
314         memcpy(iodc_data, pdc_result2, iodc_data_size);
315         spin_unlock_irq(&pdc_lock);
316
317         return retval;
318 }
319 EXPORT_SYMBOL(pdc_iodc_read);
320
321 /**
322  * pdc_system_map_find_mods - Locate unarchitected modules.
323  * @pdc_mod_info: Return buffer address.
324  * @mod_path: pointer to dev path structure.
325  * @mod_index: fixed address module index.
326  *
327  * To locate and identify modules which reside at fixed I/O addresses, which
328  * do not self-identify via architected bus walks.
329  */
330 int pdc_system_map_find_mods(struct pdc_system_map_mod_info *pdc_mod_info,
331                              struct pdc_module_path *mod_path, long mod_index)
332 {
333         int retval;
334
335         spin_lock_irq(&pdc_lock);
336         retval = mem_pdc_call(PDC_SYSTEM_MAP, PDC_FIND_MODULE, __pa(pdc_result), 
337                               __pa(pdc_result2), mod_index);
338         convert_to_wide(pdc_result);
339         memcpy(pdc_mod_info, pdc_result, sizeof(*pdc_mod_info));
340         memcpy(mod_path, pdc_result2, sizeof(*mod_path));
341         spin_unlock_irq(&pdc_lock);
342
343         pdc_mod_info->mod_addr = f_extend(pdc_mod_info->mod_addr);
344         return retval;
345 }
346
347 /**
348  * pdc_system_map_find_addrs - Retrieve additional address ranges.
349  * @pdc_addr_info: Return buffer address.
350  * @mod_index: Fixed address module index.
351  * @addr_index: Address range index.
352  * 
353  * Retrieve additional information about subsequent address ranges for modules
354  * with multiple address ranges.  
355  */
356 int pdc_system_map_find_addrs(struct pdc_system_map_addr_info *pdc_addr_info, 
357                               long mod_index, long addr_index)
358 {
359         int retval;
360
361         spin_lock_irq(&pdc_lock);
362         retval = mem_pdc_call(PDC_SYSTEM_MAP, PDC_FIND_ADDRESS, __pa(pdc_result),
363                               mod_index, addr_index);
364         convert_to_wide(pdc_result);
365         memcpy(pdc_addr_info, pdc_result, sizeof(*pdc_addr_info));
366         spin_unlock_irq(&pdc_lock);
367
368         pdc_addr_info->mod_addr = f_extend(pdc_addr_info->mod_addr);
369         return retval;
370 }
371
372 /**
373  * pdc_model_info - Return model information about the processor.
374  * @model: The return buffer.
375  *
376  * Returns the version numbers, identifiers, and capabilities from the processor module.
377  */
378 int pdc_model_info(struct pdc_model *model) 
379 {
380         int retval;
381
382         spin_lock_irq(&pdc_lock);
383         retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_INFO, __pa(pdc_result), 0);
384         convert_to_wide(pdc_result);
385         memcpy(model, pdc_result, sizeof(*model));
386         spin_unlock_irq(&pdc_lock);
387
388         return retval;
389 }
390
391 /**
392  * pdc_model_sysmodel - Get the system model name.
393  * @name: A char array of at least 81 characters.
394  *
395  * Get system model name from PDC ROM (e.g. 9000/715 or 9000/778/B160L)
396  */
397 int pdc_model_sysmodel(char *name)
398 {
399         int retval;
400
401         spin_lock_irq(&pdc_lock);
402         retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_SYSMODEL, __pa(pdc_result),
403                               OS_ID_HPUX, __pa(name));
404         convert_to_wide(pdc_result);
405
406         if (retval == PDC_OK) {
407                 name[pdc_result[0]] = '\0'; /* add trailing '\0' */
408         } else {
409                 name[0] = 0;
410         }
411         spin_unlock_irq(&pdc_lock);
412
413         return retval;
414 }
415
416 /**
417  * pdc_model_versions - Identify the version number of each processor.
418  * @cpu_id: The return buffer.
419  * @id: The id of the processor to check.
420  *
421  * Returns the version number for each processor component.
422  *
423  * This comment was here before, but I do not know what it means :( -RB
424  * id: 0 = cpu revision, 1 = boot-rom-version
425  */
426 int pdc_model_versions(unsigned long *versions, int id)
427 {
428         int retval;
429
430         spin_lock_irq(&pdc_lock);
431         retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_VERSIONS, __pa(pdc_result), id);
432         convert_to_wide(pdc_result);
433         *versions = pdc_result[0];
434         spin_unlock_irq(&pdc_lock);
435
436         return retval;
437 }
438
439 /**
440  * pdc_model_cpuid - Returns the CPU_ID.
441  * @cpu_id: The return buffer.
442  *
443  * Returns the CPU_ID value which uniquely identifies the cpu portion of
444  * the processor module.
445  */
446 int pdc_model_cpuid(unsigned long *cpu_id)
447 {
448         int retval;
449
450         spin_lock_irq(&pdc_lock);
451         pdc_result[0] = 0; /* preset zero (call may not be implemented!) */
452         retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_CPU_ID, __pa(pdc_result), 0);
453         convert_to_wide(pdc_result);
454         *cpu_id = pdc_result[0];
455         spin_unlock_irq(&pdc_lock);
456
457         return retval;
458 }
459
460 /**
461  * pdc_model_capabilities - Returns the platform capabilities.
462  * @capabilities: The return buffer.
463  *
464  * Returns information about platform support for 32- and/or 64-bit
465  * OSes, IO-PDIR coherency, and virtual aliasing.
466  */
467 int pdc_model_capabilities(unsigned long *capabilities)
468 {
469         int retval;
470
471         spin_lock_irq(&pdc_lock);
472         pdc_result[0] = 0; /* preset zero (call may not be implemented!) */
473         retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_CAPABILITIES, __pa(pdc_result), 0);
474         convert_to_wide(pdc_result);
475         *capabilities = pdc_result[0];
476         spin_unlock_irq(&pdc_lock);
477
478         return retval;
479 }
480
481 /**
482  * pdc_cache_info - Return cache and TLB information.
483  * @cache_info: The return buffer.
484  *
485  * Returns information about the processor's cache and TLB.
486  */
487 int pdc_cache_info(struct pdc_cache_info *cache_info)
488 {
489         int retval;
490
491         spin_lock_irq(&pdc_lock);
492         retval = mem_pdc_call(PDC_CACHE, PDC_CACHE_INFO, __pa(pdc_result), 0);
493         convert_to_wide(pdc_result);
494         memcpy(cache_info, pdc_result, sizeof(*cache_info));
495         spin_unlock_irq(&pdc_lock);
496
497         return retval;
498 }
499
500 #ifndef CONFIG_PA20
501 /**
502  * pdc_btlb_info - Return block TLB information.
503  * @btlb: The return buffer.
504  *
505  * Returns information about the hardware Block TLB.
506  */
507 int pdc_btlb_info(struct pdc_btlb_info *btlb) 
508 {
509         int retval;
510
511         spin_lock_irq(&pdc_lock);
512         retval = mem_pdc_call(PDC_BLOCK_TLB, PDC_BTLB_INFO, __pa(pdc_result), 0);
513         memcpy(btlb, pdc_result, sizeof(*btlb));
514         spin_unlock_irq(&pdc_lock);
515
516         if(retval < 0) {
517                 btlb->max_size = 0;
518         }
519         return retval;
520 }
521
522 /**
523  * pdc_mem_map_hpa - Find fixed module information.  
524  * @address: The return buffer
525  * @mod_path: pointer to dev path structure.
526  *
527  * This call was developed for S700 workstations to allow the kernel to find
528  * the I/O devices (Core I/O). In the future (Kittyhawk and beyond) this
529  * call will be replaced (on workstations) by the architected PDC_SYSTEM_MAP
530  * call.
531  *
532  * This call is supported by all existing S700 workstations (up to  Gecko).
533  */
534 int pdc_mem_map_hpa(struct pdc_memory_map *address,
535                 struct pdc_module_path *mod_path)
536 {
537         int retval;
538
539         spin_lock_irq(&pdc_lock);
540         memcpy(pdc_result2, mod_path, sizeof(*mod_path));
541         retval = mem_pdc_call(PDC_MEM_MAP, PDC_MEM_MAP_HPA, __pa(pdc_result),
542                                 __pa(pdc_result2));
543         memcpy(address, pdc_result, sizeof(*address));
544         spin_unlock_irq(&pdc_lock);
545
546         return retval;
547 }
548 #endif  /* !CONFIG_PA20 */
549
550 /**
551  * pdc_lan_station_id - Get the LAN address.
552  * @lan_addr: The return buffer.
553  * @hpa: The network device HPA.
554  *
555  * Get the LAN station address when it is not directly available from the LAN hardware.
556  */
557 int pdc_lan_station_id(char *lan_addr, unsigned long hpa)
558 {
559         int retval;
560
561         spin_lock_irq(&pdc_lock);
562         retval = mem_pdc_call(PDC_LAN_STATION_ID, PDC_LAN_STATION_ID_READ,
563                         __pa(pdc_result), hpa);
564         if (retval < 0) {
565                 /* FIXME: else read MAC from NVRAM */
566                 memset(lan_addr, 0, PDC_LAN_STATION_ID_SIZE);
567         } else {
568                 memcpy(lan_addr, pdc_result, PDC_LAN_STATION_ID_SIZE);
569         }
570         spin_unlock_irq(&pdc_lock);
571
572         return retval;
573 }
574 EXPORT_SYMBOL(pdc_lan_station_id);
575
576
577 /**
578  * pdc_get_initiator - Get the SCSI Interface Card params (SCSI ID, SDTR, SE or LVD)
579  * @hwpath: fully bc.mod style path to the device.
580  * @scsi_id: what someone told firmware the ID should be.
581  * @period: time in cycles 
582  * @width: 8 or 16-bit wide bus
583  * @mode: 0,1,2 -> SE,HVD,LVD signalling mode
584  *
585  * Get the SCSI operational parameters from PDC.
586  * Needed since HPUX never used BIOS or symbios card NVRAM.
587  * Most ncr/sym cards won't have an entry and just use whatever
588  * capabilities of the card are (eg Ultra, LVD). But there are
589  * several cases where it's useful:
590  *    o set SCSI id for Multi-initiator clusters,
591  *    o cable too long (ie SE scsi 10Mhz won't support 6m length),
592  *    o bus width exported is less than what the interface chip supports.
593  */
594 int pdc_get_initiator(struct hardware_path *hwpath, unsigned char *scsi_id,
595                 unsigned long *period, char *width, char *mode)
596 {
597         int retval;
598
599         spin_lock_irq(&pdc_lock);
600
601 /* BCJ-XXXX series boxes. E.G. "9000/785/C3000" */
602 #define IS_SPROCKETS() (strlen(boot_cpu_data.pdc.sys_model_name) == 14 && \
603         strncmp(boot_cpu_data.pdc.sys_model_name, "9000/785", 8) == 0)
604
605         retval = mem_pdc_call(PDC_INITIATOR, PDC_GET_INITIATOR, 
606                               __pa(pdc_result), __pa(hwpath));
607
608         if (retval < PDC_OK)
609                 goto fail;
610
611         *scsi_id = (unsigned char) pdc_result[0];
612
613         /* convert Bus speed in Mhz to period (in 1/10 ns) */
614         switch (pdc_result[1]) {
615                 /*
616                  * case  0:   driver determines rate
617                  * case -1:   Settings are uninitialized.
618                  */
619                 case  5:  *period = 2000; break;
620                 case 10:  *period = 1000; break;
621                 case 20:  *period = 500; break;
622                 case 40:  *period = 250; break;
623                 case 80:  *period = 125; break;
624                 default: /* Do nothing */ break;
625         }
626
627         /* 
628          * pdc_result[2]        PDC suggested SCSI id
629          * pdc_result[3]        PDC suggested SCSI rate
630          */
631
632         if (IS_SPROCKETS()) {
633                 /* 0 == 8-bit, 1 == 16-bit */
634                 *width = (char) pdc_result[4];
635
636                 /* ...in case someone needs it in the future.
637                  * sym53c8xx.c comments say it can't autodetect
638                  * for 825/825A/875 chips.
639                  *      0 == SE, 1 == HVD, 2 == LVD
640                  */
641                 *mode = (char) pdc_result[5]; 
642         }
643
644  fail:
645         spin_unlock_irq(&pdc_lock);
646         return (retval >= PDC_OK);
647 }
648 EXPORT_SYMBOL(pdc_get_initiator);
649
650
651 /**
652  * pdc_pci_irt_size - Get the number of entries in the interrupt routing table.
653  * @num_entries: The return value.
654  * @hpa: The HPA for the device.
655  *
656  * This PDC function returns the number of entries in the specified cell's
657  * interrupt table.
658  * Similar to PDC_PAT stuff - but added for Forte/Allegro boxes
659  */ 
660 int pdc_pci_irt_size(unsigned long *num_entries, unsigned long hpa)
661 {
662         int retval;
663
664         spin_lock_irq(&pdc_lock);
665         retval = mem_pdc_call(PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL_SIZE, 
666                               __pa(pdc_result), hpa);
667         convert_to_wide(pdc_result);
668         *num_entries = pdc_result[0];
669         spin_unlock_irq(&pdc_lock);
670
671         return retval;
672 }
673
674 /** 
675  * pdc_pci_irt - Get the PCI interrupt routing table.
676  * @num_entries: The number of entries in the table.
677  * @hpa: The Hard Physical Address of the device.
678  * @tbl: 
679  *
680  * Get the PCI interrupt routing table for the device at the given HPA.
681  * Similar to PDC_PAT stuff - but added for Forte/Allegro boxes
682  */
683 int pdc_pci_irt(unsigned long num_entries, unsigned long hpa, void *tbl)
684 {
685         int retval;
686
687         spin_lock_irq(&pdc_lock);
688         pdc_result[0] = num_entries;
689         retval = mem_pdc_call(PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL, 
690                               __pa(pdc_result), hpa, __pa(tbl));
691         spin_unlock_irq(&pdc_lock);
692
693         return retval;
694 }
695
696
697 #if 0   /* UNTEST CODE - left here in case someone needs it */
698
699 /** 
700  * pdc_pci_config_read - read PCI config space.
701  * @hpa         token from PDC to indicate which PCI device
702  * @pci_addr    configuration space address to read from
703  *
704  * Read PCI Configuration space *before* linux PCI subsystem is running.
705  */
706 unsigned int pdc_pci_config_read(void *hpa, unsigned long cfg_addr)
707 {
708         int retval;
709         spin_lock_irq(&pdc_lock);
710         pdc_result[0] = 0;
711         pdc_result[1] = 0;
712         retval = mem_pdc_call(PDC_PCI_INDEX, PDC_PCI_READ_CONFIG, 
713                               __pa(pdc_result), hpa, cfg_addr&~3UL, 4UL);
714         spin_unlock_irq(&pdc_lock);
715         return retval ? ~0 : (unsigned int) pdc_result[0];
716 }
717
718
719 /** 
720  * pdc_pci_config_write - read PCI config space.
721  * @hpa         token from PDC to indicate which PCI device
722  * @pci_addr    configuration space address to write
723  * @val         value we want in the 32-bit register
724  *
725  * Write PCI Configuration space *before* linux PCI subsystem is running.
726  */
727 void pdc_pci_config_write(void *hpa, unsigned long cfg_addr, unsigned int val)
728 {
729         int retval;
730         spin_lock_irq(&pdc_lock);
731         pdc_result[0] = 0;
732         retval = mem_pdc_call(PDC_PCI_INDEX, PDC_PCI_WRITE_CONFIG, 
733                               __pa(pdc_result), hpa,
734                               cfg_addr&~3UL, 4UL, (unsigned long) val);
735         spin_unlock_irq(&pdc_lock);
736         return retval;
737 }
738 #endif /* UNTESTED CODE */
739
740 /**
741  * pdc_tod_read - Read the Time-Of-Day clock.
742  * @tod: The return buffer:
743  *
744  * Read the Time-Of-Day clock
745  */
746 int pdc_tod_read(struct pdc_tod *tod)
747 {
748         int retval;
749
750         spin_lock_irq(&pdc_lock);
751         retval = mem_pdc_call(PDC_TOD, PDC_TOD_READ, __pa(pdc_result), 0);
752         convert_to_wide(pdc_result);
753         memcpy(tod, pdc_result, sizeof(*tod));
754         spin_unlock_irq(&pdc_lock);
755
756         return retval;
757 }
758 EXPORT_SYMBOL(pdc_tod_read);
759
760 /**
761  * pdc_tod_set - Set the Time-Of-Day clock.
762  * @sec: The number of seconds since epoch.
763  * @usec: The number of micro seconds.
764  *
765  * Set the Time-Of-Day clock.
766  */ 
767 int pdc_tod_set(unsigned long sec, unsigned long usec)
768 {
769         int retval;
770
771         spin_lock_irq(&pdc_lock);
772         retval = mem_pdc_call(PDC_TOD, PDC_TOD_WRITE, sec, usec);
773         spin_unlock_irq(&pdc_lock);
774
775         return retval;
776 }
777 EXPORT_SYMBOL(pdc_tod_set);
778
779 #ifdef __LP64__
780 int pdc_mem_mem_table(struct pdc_memory_table_raddr *r_addr,
781                 struct pdc_memory_table *tbl, unsigned long entries)
782 {
783         int retval;
784
785         spin_lock_irq(&pdc_lock);
786         retval = mem_pdc_call(PDC_MEM, PDC_MEM_TABLE, __pa(pdc_result), __pa(pdc_result2), entries);
787         convert_to_wide(pdc_result);
788         memcpy(r_addr, pdc_result, sizeof(*r_addr));
789         memcpy(tbl, pdc_result2, entries * sizeof(*tbl));
790         spin_unlock_irq(&pdc_lock);
791
792         return retval;
793 }
794 #endif /* __LP64__ */
795
796 /* FIXME: Is this pdc used?  I could not find type reference to ftc_bitmap
797  * so I guessed at unsigned long.  Someone who knows what this does, can fix
798  * it later. :)
799  */
800 int pdc_do_firm_test_reset(unsigned long ftc_bitmap)
801 {
802         int retval;
803
804         spin_lock_irq(&pdc_lock);
805         retval = mem_pdc_call(PDC_BROADCAST_RESET, PDC_DO_FIRM_TEST_RESET,
806                               PDC_FIRM_TEST_MAGIC, ftc_bitmap);
807         spin_unlock_irq(&pdc_lock);
808
809         return retval;
810 }
811
812 /*
813  * pdc_do_reset - Reset the system.
814  *
815  * Reset the system.
816  */
817 int pdc_do_reset()
818 {
819         int retval;
820
821         spin_lock_irq(&pdc_lock);
822         retval = mem_pdc_call(PDC_BROADCAST_RESET, PDC_DO_RESET);
823         spin_unlock_irq(&pdc_lock);
824
825         return retval;
826 }
827
828 /*
829  * pdc_soft_power_info - Enable soft power switch.
830  * @power_reg: address of soft power register
831  *
832  * Return the absolute address of the soft power switch register
833  */
834 int __init pdc_soft_power_info(unsigned long *power_reg)
835 {
836         int retval;
837
838         *power_reg = (unsigned long) (-1);
839         
840         spin_lock_irq(&pdc_lock);
841         retval = mem_pdc_call(PDC_SOFT_POWER, PDC_SOFT_POWER_INFO, __pa(pdc_result), 0);
842         if (retval == PDC_OK) {
843                 convert_to_wide(pdc_result);
844                 *power_reg = f_extend(pdc_result[0]);
845         }
846         spin_unlock_irq(&pdc_lock);
847
848         return retval;
849 }
850
851 /*
852  * pdc_soft_power_button - Control the soft power button behaviour
853  * @sw_control: 0 for hardware control, 1 for software control 
854  *
855  *
856  * This PDC function places the soft power button under software or
857  * hardware control.
858  * Under software control the OS may control to when to allow to shut 
859  * down the system. Under hardware control pressing the power button 
860  * powers off the system immediately.
861  */
862 int pdc_soft_power_button(int sw_control)
863 {
864         int retval;
865         spin_lock_irq(&pdc_lock);
866         retval = mem_pdc_call(PDC_SOFT_POWER, PDC_SOFT_POWER_ENABLE, __pa(pdc_result), sw_control);
867         spin_unlock_irq(&pdc_lock);
868         return retval;
869 }
870
871 /*
872  * pdc_io_reset - Hack to avoid overlapping range registers of Bridges devices.
873  * Primarily a problem on T600 (which parisc-linux doesn't support) but
874  * who knows what other platform firmware might do with this OS "hook".
875  */
876 void pdc_io_reset(void)
877 {
878         spin_lock_irq(&pdc_lock);  
879         mem_pdc_call(PDC_IO, PDC_IO_RESET, 0);
880         spin_unlock_irq(&pdc_lock);
881 }
882
883 /*
884  * pdc_io_reset_devices - Hack to Stop USB controller
885  *
886  * If PDC used the usb controller, the usb controller
887  * is still running and will crash the machines during iommu 
888  * setup, because of still running DMA. This PDC call
889  * stops the USB controller.
890  * Normally called after calling pdc_io_reset().
891  */
892 void pdc_io_reset_devices(void)
893 {
894         spin_lock_irq(&pdc_lock);  
895         mem_pdc_call(PDC_IO, PDC_IO_RESET_DEVICES, 0);
896         spin_unlock_irq(&pdc_lock);
897 }
898
899
900 /**
901  * pdc_iodc_putc - Console character print using IODC.
902  * @c: the character to output.
903  *
904  * Note that only these special chars are architected for console IODC io:
905  * BEL, BS, CR, and LF. Others are passed through.
906  * Since the HP console requires CR+LF to perform a 'newline', we translate
907  * "\n" to "\r\n".
908  */
909 void pdc_iodc_putc(unsigned char c)
910 {
911         /* XXX Should we spinlock posx usage */
912         static int posx;        /* for simple TAB-Simulation... */
913         static int __attribute__((aligned(8)))   iodc_retbuf[32];
914         static char __attribute__((aligned(64))) iodc_dbuf[4096];
915         unsigned int n;
916         unsigned int flags;
917
918         switch (c) {
919         case '\n':
920                 iodc_dbuf[0] = '\r';
921                 iodc_dbuf[1] = '\n';
922                 n = 2;
923                 posx = 0;
924                 break;
925         case '\t':
926                 pdc_iodc_putc(' ');
927                 while (posx & 7)        /* expand TAB */
928                         pdc_iodc_putc(' ');
929                 return;         /* return since IODC can't handle this */
930         case '\b':
931                 posx-=2;                /* BS */
932         default:
933                 iodc_dbuf[0] = c;
934                 n = 1;
935                 posx++;
936                 break;
937         }
938
939         spin_lock_irqsave(&pdc_lock, flags);
940         real32_call(PAGE0->mem_cons.iodc_io,
941                     (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
942                     PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
943                     __pa(iodc_retbuf), 0, __pa(iodc_dbuf), n, 0);
944         spin_unlock_irqrestore(&pdc_lock, flags);
945 }
946
947 /**
948  * pdc_iodc_outc - Console character print using IODC (without conversions).
949  * @c: the character to output.
950  *
951  * Write the character directly to the IODC console.
952  */
953 void pdc_iodc_outc(unsigned char c)
954 {
955         unsigned int n, flags;
956
957         /* fill buffer with one caracter and print it */
958         static int __attribute__((aligned(8)))   iodc_retbuf[32];
959         static char __attribute__((aligned(64))) iodc_dbuf[4096];
960
961         n = 1;
962         iodc_dbuf[0] = c;
963
964         spin_lock_irqsave(&pdc_lock, flags);
965         real32_call(PAGE0->mem_cons.iodc_io,
966                     (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
967                     PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
968                     __pa(iodc_retbuf), 0, __pa(iodc_dbuf), n, 0);
969         spin_unlock_irqrestore(&pdc_lock, flags);
970 }
971
972 /**
973  * pdc_iodc_getc - Read a character (non-blocking) from the PDC console.
974  *
975  * Read a character (non-blocking) from the PDC console, returns -1 if
976  * key is not present.
977  */
978 int pdc_iodc_getc(void)
979 {
980         unsigned int flags;
981         static int __attribute__((aligned(8)))   iodc_retbuf[32];
982         static char __attribute__((aligned(64))) iodc_dbuf[4096];
983         int ch;
984         int status;
985
986         /* Bail if no console input device. */
987         if (!PAGE0->mem_kbd.iodc_io)
988                 return 0;
989         
990         /* wait for a keyboard (rs232)-input */
991         spin_lock_irqsave(&pdc_lock, flags);
992         real32_call(PAGE0->mem_kbd.iodc_io,
993                     (unsigned long)PAGE0->mem_kbd.hpa, ENTRY_IO_CIN,
994                     PAGE0->mem_kbd.spa, __pa(PAGE0->mem_kbd.dp.layers), 
995                     __pa(iodc_retbuf), 0, __pa(iodc_dbuf), 1, 0);
996
997         ch = *iodc_dbuf;
998         status = *iodc_retbuf;
999         spin_unlock_irqrestore(&pdc_lock, flags);
1000
1001         if (status == 0)
1002             return -1;
1003         
1004         return ch;
1005 }
1006
1007 int pdc_sti_call(unsigned long func, unsigned long flags,
1008                  unsigned long inptr, unsigned long outputr,
1009                  unsigned long glob_cfg)
1010 {
1011         int retval;
1012
1013         spin_lock_irq(&pdc_lock);  
1014         retval = real32_call(func, flags, inptr, outputr, glob_cfg);
1015         spin_unlock_irq(&pdc_lock);
1016
1017         return retval;
1018 }
1019 EXPORT_SYMBOL(pdc_sti_call);
1020
1021 #ifdef __LP64__
1022 /**
1023  * pdc_pat_cell_get_number - Returns the cell number.
1024  * @cell_info: The return buffer.
1025  *
1026  * This PDC call returns the cell number of the cell from which the call
1027  * is made.
1028  */
1029 int pdc_pat_cell_get_number(struct pdc_pat_cell_num *cell_info)
1030 {
1031         int retval;
1032
1033         spin_lock_irq(&pdc_lock);
1034         retval = mem_pdc_call(PDC_PAT_CELL, PDC_PAT_CELL_GET_NUMBER, __pa(pdc_result));
1035         memcpy(cell_info, pdc_result, sizeof(*cell_info));
1036         spin_unlock_irq(&pdc_lock);
1037
1038         return retval;
1039 }
1040
1041 /**
1042  * pdc_pat_cell_module - Retrieve the cell's module information.
1043  * @actcnt: The number of bytes written to mem_addr.
1044  * @ploc: The physical location.
1045  * @mod: The module index.
1046  * @view_type: The view of the address type.
1047  * @mem_addr: The return buffer.
1048  *
1049  * This PDC call returns information about each module attached to the cell
1050  * at the specified location.
1051  */
1052 int pdc_pat_cell_module(unsigned long *actcnt, unsigned long ploc, unsigned long mod,
1053                         unsigned long view_type, void *mem_addr)
1054 {
1055         int retval;
1056         static struct pdc_pat_cell_mod_maddr_block result __attribute__ ((aligned (8)));
1057
1058         spin_lock_irq(&pdc_lock);
1059         retval = mem_pdc_call(PDC_PAT_CELL, PDC_PAT_CELL_MODULE, __pa(pdc_result), 
1060                               ploc, mod, view_type, __pa(&result));
1061         if(!retval) {
1062                 *actcnt = pdc_result[0];
1063                 memcpy(mem_addr, &result, *actcnt);
1064         }
1065         spin_unlock_irq(&pdc_lock);
1066
1067         return retval;
1068 }
1069
1070 /**
1071  * pdc_pat_cpu_get_number - Retrieve the cpu number.
1072  * @cpu_info: The return buffer.
1073  * @hpa: The Hard Physical Address of the CPU.
1074  *
1075  * Retrieve the cpu number for the cpu at the specified HPA.
1076  */
1077 int pdc_pat_cpu_get_number(struct pdc_pat_cpu_num *cpu_info, void *hpa)
1078 {
1079         int retval;
1080
1081         spin_lock_irq(&pdc_lock);
1082         retval = mem_pdc_call(PDC_PAT_CPU, PDC_PAT_CPU_GET_NUMBER,
1083                               __pa(&pdc_result), hpa);
1084         memcpy(cpu_info, pdc_result, sizeof(*cpu_info));
1085         spin_unlock_irq(&pdc_lock);
1086
1087         return retval;
1088 }
1089
1090 /**
1091  * pdc_pat_get_irt_size - Retrieve the number of entries in the cell's interrupt table.
1092  * @num_entries: The return value.
1093  * @cell_num: The target cell.
1094  *
1095  * This PDC function returns the number of entries in the specified cell's
1096  * interrupt table.
1097  */
1098 int pdc_pat_get_irt_size(unsigned long *num_entries, unsigned long cell_num)
1099 {
1100         int retval;
1101
1102         spin_lock_irq(&pdc_lock);
1103         retval = mem_pdc_call(PDC_PAT_IO, PDC_PAT_IO_GET_PCI_ROUTING_TABLE_SIZE,
1104                               __pa(pdc_result), cell_num);
1105         *num_entries = pdc_result[0];
1106         spin_unlock_irq(&pdc_lock);
1107
1108         return retval;
1109 }
1110
1111 /**
1112  * pdc_pat_get_irt - Retrieve the cell's interrupt table.
1113  * @r_addr: The return buffer.
1114  * @cell_num: The target cell.
1115  *
1116  * This PDC function returns the actual interrupt table for the specified cell.
1117  */
1118 int pdc_pat_get_irt(void *r_addr, unsigned long cell_num)
1119 {
1120         int retval;
1121
1122         spin_lock_irq(&pdc_lock);
1123         retval = mem_pdc_call(PDC_PAT_IO, PDC_PAT_IO_GET_PCI_ROUTING_TABLE,
1124                               __pa(r_addr), cell_num);
1125         spin_unlock_irq(&pdc_lock);
1126
1127         return retval;
1128 }
1129
1130 /**
1131  * pdc_pat_pd_get_addr_map - Retrieve information about memory address ranges.
1132  * @actlen: The return buffer.
1133  * @mem_addr: Pointer to the memory buffer.
1134  * @count: The number of bytes to read from the buffer.
1135  * @offset: The offset with respect to the beginning of the buffer.
1136  *
1137  */
1138 int pdc_pat_pd_get_addr_map(unsigned long *actual_len, void *mem_addr, 
1139                             unsigned long count, unsigned long offset)
1140 {
1141         int retval;
1142
1143         spin_lock_irq(&pdc_lock);
1144         retval = mem_pdc_call(PDC_PAT_PD, PDC_PAT_PD_GET_ADDR_MAP, __pa(pdc_result), 
1145                               __pa(pdc_result2), count, offset);
1146         *actual_len = pdc_result[0];
1147         memcpy(mem_addr, pdc_result2, *actual_len);
1148         spin_unlock_irq(&pdc_lock);
1149
1150         return retval;
1151 }
1152
1153 /**
1154  * pdc_pat_io_pci_cfg_read - Read PCI configuration space.
1155  * @pci_addr: PCI configuration space address for which the read request is being made.
1156  * @pci_size: Size of read in bytes. Valid values are 1, 2, and 4. 
1157  * @mem_addr: Pointer to return memory buffer.
1158  *
1159  */
1160 int pdc_pat_io_pci_cfg_read(unsigned long pci_addr, int pci_size, u32 *mem_addr)
1161 {
1162         int retval;
1163         spin_lock_irq(&pdc_lock);
1164         retval = mem_pdc_call(PDC_PAT_IO, PDC_PAT_IO_PCI_CONFIG_READ,
1165                                         __pa(pdc_result), pci_addr, pci_size);
1166         switch(pci_size) {
1167                 case 1: *(u8 *) mem_addr =  (u8)  pdc_result[0];
1168                 case 2: *(u16 *)mem_addr =  (u16) pdc_result[0];
1169                 case 4: *(u32 *)mem_addr =  (u32) pdc_result[0];
1170         }
1171         spin_unlock_irq(&pdc_lock);
1172
1173         return retval;
1174 }
1175
1176 /**
1177  * pdc_pat_io_pci_cfg_write - Retrieve information about memory address ranges.
1178  * @pci_addr: PCI configuration space address for which the write  request is being made.
1179  * @pci_size: Size of write in bytes. Valid values are 1, 2, and 4. 
1180  * @value: Pointer to 1, 2, or 4 byte value in low order end of argument to be 
1181  *         written to PCI Config space.
1182  *
1183  */
1184 int pdc_pat_io_pci_cfg_write(unsigned long pci_addr, int pci_size, u32 val)
1185 {
1186         int retval;
1187
1188         spin_lock_irq(&pdc_lock);
1189         retval = mem_pdc_call(PDC_PAT_IO, PDC_PAT_IO_PCI_CONFIG_WRITE,
1190                                 pci_addr, pci_size, val);
1191         spin_unlock_irq(&pdc_lock);
1192
1193         return retval;
1194 }
1195 #endif /* __LP64__ */
1196
1197
1198 /***************** 32-bit real-mode calls ***********/
1199 /* The struct below is used
1200  * to overlay real_stack (real2.S), preparing a 32-bit call frame.
1201  * real32_call_asm() then uses this stack in narrow real mode
1202  */
1203
1204 struct narrow_stack {
1205         /* use int, not long which is 64 bits */
1206         unsigned int arg13;
1207         unsigned int arg12;
1208         unsigned int arg11;
1209         unsigned int arg10;
1210         unsigned int arg9;
1211         unsigned int arg8;
1212         unsigned int arg7;
1213         unsigned int arg6;
1214         unsigned int arg5;
1215         unsigned int arg4;
1216         unsigned int arg3;
1217         unsigned int arg2;
1218         unsigned int arg1;
1219         unsigned int arg0;
1220         unsigned int frame_marker[8];
1221         unsigned int sp;
1222         /* in reality, there's nearly 8k of stack after this */
1223 };
1224
1225 long real32_call(unsigned long fn, ...)
1226 {
1227         va_list args;
1228         extern struct narrow_stack real_stack;
1229         extern unsigned long real32_call_asm(unsigned int *,
1230                                              unsigned int *, 
1231                                              unsigned int);
1232         
1233         va_start(args, fn);
1234         real_stack.arg0 = va_arg(args, unsigned int);
1235         real_stack.arg1 = va_arg(args, unsigned int);
1236         real_stack.arg2 = va_arg(args, unsigned int);
1237         real_stack.arg3 = va_arg(args, unsigned int);
1238         real_stack.arg4 = va_arg(args, unsigned int);
1239         real_stack.arg5 = va_arg(args, unsigned int);
1240         real_stack.arg6 = va_arg(args, unsigned int);
1241         real_stack.arg7 = va_arg(args, unsigned int);
1242         real_stack.arg8 = va_arg(args, unsigned int);
1243         real_stack.arg9 = va_arg(args, unsigned int);
1244         real_stack.arg10 = va_arg(args, unsigned int);
1245         real_stack.arg11 = va_arg(args, unsigned int);
1246         real_stack.arg12 = va_arg(args, unsigned int);
1247         real_stack.arg13 = va_arg(args, unsigned int);
1248         va_end(args);
1249         
1250         return real32_call_asm(&real_stack.sp, &real_stack.arg0, fn);
1251 }
1252
1253 #ifdef __LP64__
1254 /***************** 64-bit real-mode calls ***********/
1255
1256 struct wide_stack {
1257         unsigned long arg0;
1258         unsigned long arg1;
1259         unsigned long arg2;
1260         unsigned long arg3;
1261         unsigned long arg4;
1262         unsigned long arg5;
1263         unsigned long arg6;
1264         unsigned long arg7;
1265         unsigned long arg8;
1266         unsigned long arg9;
1267         unsigned long arg10;
1268         unsigned long arg11;
1269         unsigned long arg12;
1270         unsigned long arg13;
1271         unsigned long frame_marker[2];  /* rp, previous sp */
1272         unsigned long sp;
1273         /* in reality, there's nearly 8k of stack after this */
1274 };
1275
1276 long real64_call(unsigned long fn, ...)
1277 {
1278         va_list args;
1279         extern struct wide_stack real64_stack __attribute__ ((alias ("real_stack")));
1280         extern unsigned long real64_call_asm(unsigned long *,
1281                                              unsigned long *, 
1282                                              unsigned long);
1283     
1284         va_start(args, fn);
1285         real64_stack.arg0 = va_arg(args, unsigned long);
1286         real64_stack.arg1 = va_arg(args, unsigned long);
1287         real64_stack.arg2 = va_arg(args, unsigned long);
1288         real64_stack.arg3 = va_arg(args, unsigned long);
1289         real64_stack.arg4 = va_arg(args, unsigned long);
1290         real64_stack.arg5 = va_arg(args, unsigned long);
1291         real64_stack.arg6 = va_arg(args, unsigned long);
1292         real64_stack.arg7 = va_arg(args, unsigned long);
1293         real64_stack.arg8 = va_arg(args, unsigned long);
1294         real64_stack.arg9 = va_arg(args, unsigned long);
1295         real64_stack.arg10 = va_arg(args, unsigned long);
1296         real64_stack.arg11 = va_arg(args, unsigned long);
1297         real64_stack.arg12 = va_arg(args, unsigned long);
1298         real64_stack.arg13 = va_arg(args, unsigned long);
1299         va_end(args);
1300         
1301         return real64_call_asm(&real64_stack.sp, &real64_stack.arg0, fn);
1302 }
1303
1304 #endif /* __LP64__ */
1305