Import 2.3.16
[davej-history.git] / arch / sparc / prom / devmap.c
blob463b07527acccb53cf962ad12b8070811ebc2334
1 /* $Id: devmap.c,v 1.6 1998/03/09 14:04:23 jj Exp $
2 * promdevmap.c: Map device/IO areas to virtual addresses.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 */
7 #include <linux/types.h>
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
11 #include <asm/openprom.h>
12 #include <asm/oplib.h>
14 extern void restore_current(void);
16 /* Just like the routines in palloc.c, these should not be used
17 * by the kernel at all. Bootloader facility mainly. And again,
18 * this is only available on V2 proms and above.
21 /* Map physical device address 'paddr' in IO space 'ios' of size
22 * 'num_bytes' to a virtual address, with 'vhint' being a hint to
23 * the prom as to where you would prefer the mapping. We return
24 * where the prom actually mapped it.
26 char *
27 prom_mapio(char *vhint, int ios, unsigned int paddr, unsigned int num_bytes)
29 unsigned long flags;
30 char *ret;
32 save_flags(flags); cli();
33 if((num_bytes == 0) || (paddr == 0)) ret = (char *) 0x0;
34 else
35 ret = (*(romvec->pv_v2devops.v2_dumb_mmap))(vhint, ios, paddr,
36 num_bytes);
37 restore_current();
38 restore_flags(flags);
39 return ret;
42 /* Unmap an IO/device area that was mapped using the above routine. */
43 void
44 prom_unmapio(char *vaddr, unsigned int num_bytes)
46 unsigned long flags;
48 if(num_bytes == 0x0) return;
49 save_flags(flags); cli();
50 (*(romvec->pv_v2devops.v2_dumb_munmap))(vaddr, num_bytes);
51 restore_current();
52 restore_flags(flags);
53 return;