aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-sparc64')
-rw-r--r--include/asm-sparc64/a.out.h104
-rw-r--r--include/asm-sparc64/agp.h11
-rw-r--r--include/asm-sparc64/apb.h36
-rw-r--r--include/asm-sparc64/asi.h145
-rw-r--r--include/asm-sparc64/atomic.h86
-rw-r--r--include/asm-sparc64/audioio.h234
-rw-r--r--include/asm-sparc64/auxio.h98
-rw-r--r--include/asm-sparc64/bbc.h225
-rw-r--r--include/asm-sparc64/bitops.h294
-rw-r--r--include/asm-sparc64/bpp.h73
-rw-r--r--include/asm-sparc64/bsderrno.h94
-rw-r--r--include/asm-sparc64/bug.h19
-rw-r--r--include/asm-sparc64/bugs.h16
-rw-r--r--include/asm-sparc64/byteorder.h50
-rw-r--r--include/asm-sparc64/cache.h17
-rw-r--r--include/asm-sparc64/cacheflush.h72
-rw-r--r--include/asm-sparc64/chafsr.h242
-rw-r--r--include/asm-sparc64/checksum.h173
-rw-r--r--include/asm-sparc64/chmctrl.h184
-rw-r--r--include/asm-sparc64/cmt.h59
-rw-r--r--include/asm-sparc64/compat.h201
-rw-r--r--include/asm-sparc64/const.h19
-rw-r--r--include/asm-sparc64/cpudata.h31
-rw-r--r--include/asm-sparc64/cputime.h6
-rw-r--r--include/asm-sparc64/current.h8
-rw-r--r--include/asm-sparc64/dcr.h15
-rw-r--r--include/asm-sparc64/dcu.h26
-rw-r--r--include/asm-sparc64/delay.h38
-rw-r--r--include/asm-sparc64/display7seg.h79
-rw-r--r--include/asm-sparc64/div64.h1
-rw-r--r--include/asm-sparc64/dma-mapping.h27
-rw-r--r--include/asm-sparc64/dma.h221
-rw-r--r--include/asm-sparc64/ebus.h97
-rw-r--r--include/asm-sparc64/elf.h181
-rw-r--r--include/asm-sparc64/envctrl.h103
-rw-r--r--include/asm-sparc64/errno.h110
-rw-r--r--include/asm-sparc64/estate.h50
-rw-r--r--include/asm-sparc64/fbio.h302
-rw-r--r--include/asm-sparc64/fcntl.h78
-rw-r--r--include/asm-sparc64/fhc.h132
-rw-r--r--include/asm-sparc64/floppy.h811
-rw-r--r--include/asm-sparc64/fpumacro.h33
-rw-r--r--include/asm-sparc64/hardirq.h23
-rw-r--r--include/asm-sparc64/hdreg.h1
-rw-r--r--include/asm-sparc64/head.h59
-rw-r--r--include/asm-sparc64/hw_irq.h6
-rw-r--r--include/asm-sparc64/ide.h121
-rw-r--r--include/asm-sparc64/idprom.h35
-rw-r--r--include/asm-sparc64/io.h501
-rw-r--r--include/asm-sparc64/ioctl.h68
-rw-r--r--include/asm-sparc64/ioctls.h135
-rw-r--r--include/asm-sparc64/iommu.h19
-rw-r--r--include/asm-sparc64/ipc.h1
-rw-r--r--include/asm-sparc64/ipcbuf.h28
-rw-r--r--include/asm-sparc64/irq.h157
-rw-r--r--include/asm-sparc64/isa.h54
-rw-r--r--include/asm-sparc64/kbio.h56
-rw-r--r--include/asm-sparc64/kdebug.h52
-rw-r--r--include/asm-sparc64/kmap_types.h25
-rw-r--r--include/asm-sparc64/kprobes.h32
-rw-r--r--include/asm-sparc64/linkage.h6
-rw-r--r--include/asm-sparc64/local.h40
-rw-r--r--include/asm-sparc64/lsu.h20
-rw-r--r--include/asm-sparc64/mc146818rtc.h35
-rw-r--r--include/asm-sparc64/mman.h62
-rw-r--r--include/asm-sparc64/mmu.h99
-rw-r--r--include/asm-sparc64/mmu_context.h145
-rw-r--r--include/asm-sparc64/module.h7
-rw-r--r--include/asm-sparc64/mostek.h144
-rw-r--r--include/asm-sparc64/msgbuf.h27
-rw-r--r--include/asm-sparc64/namei.h26
-rw-r--r--include/asm-sparc64/ns87303.h119
-rw-r--r--include/asm-sparc64/openprom.h281
-rw-r--r--include/asm-sparc64/openpromio.h69
-rw-r--r--include/asm-sparc64/oplib.h360
-rw-r--r--include/asm-sparc64/page.h172
-rw-r--r--include/asm-sparc64/param.h23
-rw-r--r--include/asm-sparc64/parport.h175
-rw-r--r--include/asm-sparc64/pbm.h248
-rw-r--r--include/asm-sparc64/pci.h264
-rw-r--r--include/asm-sparc64/pconf.h25
-rw-r--r--include/asm-sparc64/percpu.h49
-rw-r--r--include/asm-sparc64/perfctr.h173
-rw-r--r--include/asm-sparc64/pgalloc.h188
-rw-r--r--include/asm-sparc64/pgtable.h464
-rw-r--r--include/asm-sparc64/pil.h26
-rw-r--r--include/asm-sparc64/poll.h23
-rw-r--r--include/asm-sparc64/posix_types.h126
-rw-r--r--include/asm-sparc64/processor.h197
-rw-r--r--include/asm-sparc64/psrcompat.h44
-rw-r--r--include/asm-sparc64/pstate.h90
-rw-r--r--include/asm-sparc64/ptrace.h297
-rw-r--r--include/asm-sparc64/reg.h56
-rw-r--r--include/asm-sparc64/resource.h19
-rw-r--r--include/asm-sparc64/rtc.h27
-rw-r--r--include/asm-sparc64/rwsem-const.h12
-rw-r--r--include/asm-sparc64/rwsem.h100
-rw-r--r--include/asm-sparc64/sbus.h122
-rw-r--r--include/asm-sparc64/scatterlist.h22
-rw-r--r--include/asm-sparc64/sections.h9
-rw-r--r--include/asm-sparc64/segment.h6
-rw-r--r--include/asm-sparc64/semaphore.h57
-rw-r--r--include/asm-sparc64/sembuf.h22
-rw-r--r--include/asm-sparc64/setup.h10
-rw-r--r--include/asm-sparc64/sfp-machine.h91
-rw-r--r--include/asm-sparc64/shmbuf.h38
-rw-r--r--include/asm-sparc64/shmparam.h11
-rw-r--r--include/asm-sparc64/sigcontext.h88
-rw-r--r--include/asm-sparc64/siginfo.h35
-rw-r--r--include/asm-sparc64/signal.h276
-rw-r--r--include/asm-sparc64/smp.h75
-rw-r--r--include/asm-sparc64/socket.h55
-rw-r--r--include/asm-sparc64/sockios.h13
-rw-r--r--include/asm-sparc64/solerrno.h132
-rw-r--r--include/asm-sparc64/spinlock.h310
-rw-r--r--include/asm-sparc64/spitfire.h461
-rw-r--r--include/asm-sparc64/starfire.h21
-rw-r--r--include/asm-sparc64/stat.h63
-rw-r--r--include/asm-sparc64/statfs.h55
-rw-r--r--include/asm-sparc64/string.h83
-rw-r--r--include/asm-sparc64/sunbpp.h80
-rw-r--r--include/asm-sparc64/svr4.h120
-rw-r--r--include/asm-sparc64/system.h350
-rw-r--r--include/asm-sparc64/termbits.h235
-rw-r--r--include/asm-sparc64/termios.h173
-rw-r--r--include/asm-sparc64/thread_info.h252
-rw-r--r--include/asm-sparc64/timer.h74
-rw-r--r--include/asm-sparc64/timex.h17
-rw-r--r--include/asm-sparc64/tlb.h128
-rw-r--r--include/asm-sparc64/tlbflush.h41
-rw-r--r--include/asm-sparc64/topology.h6
-rw-r--r--include/asm-sparc64/ttable.h407
-rw-r--r--include/asm-sparc64/types.h65
-rw-r--r--include/asm-sparc64/uaccess.h335
-rw-r--r--include/asm-sparc64/uctx.h71
-rw-r--r--include/asm-sparc64/unaligned.h6
-rw-r--r--include/asm-sparc64/unistd.h514
-rw-r--r--include/asm-sparc64/upa.h110
-rw-r--r--include/asm-sparc64/user.h60
-rw-r--r--include/asm-sparc64/utrap.h51
-rw-r--r--include/asm-sparc64/vga.h33
-rw-r--r--include/asm-sparc64/visasm.h63
-rw-r--r--include/asm-sparc64/vuid_event.h40
-rw-r--r--include/asm-sparc64/watchdog.h31
-rw-r--r--include/asm-sparc64/xor.h40
145 files changed, 15769 insertions, 0 deletions
diff --git a/include/asm-sparc64/a.out.h b/include/asm-sparc64/a.out.h
new file mode 100644
index 000000000000..02af289e3f46
--- /dev/null
+++ b/include/asm-sparc64/a.out.h
@@ -0,0 +1,104 @@
1/* $Id: a.out.h,v 1.8 2002/02/09 19:49:31 davem Exp $ */
2#ifndef __SPARC64_A_OUT_H__
3#define __SPARC64_A_OUT_H__
4
5#define SPARC_PGSIZE 0x2000 /* Thanks to the sun4 architecture... */
6#define SEGMENT_SIZE SPARC_PGSIZE /* whee... */
7
8#ifndef __ASSEMBLY__
9
10struct exec {
11 unsigned char a_dynamic:1; /* A __DYNAMIC is in this image */
12 unsigned char a_toolversion:7;
13 unsigned char a_machtype;
14 unsigned short a_info;
15 unsigned int a_text; /* length of text, in bytes */
16 unsigned int a_data; /* length of data, in bytes */
17 unsigned int a_bss; /* length of bss, in bytes */
18 unsigned int a_syms; /* length of symbol table, in bytes */
19 unsigned int a_entry; /* where program begins */
20 unsigned int a_trsize;
21 unsigned int a_drsize;
22};
23
24#endif /* !__ASSEMBLY__ */
25
26/* Where in the file does the text information begin? */
27#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
28
29/* Where do the Symbols start? */
30#define N_SYMOFF(x) (N_TXTOFF(x) + (x).a_text + \
31 (x).a_data + (x).a_trsize + \
32 (x).a_drsize)
33
34/* Where does text segment go in memory after being loaded? */
35#define N_TXTADDR(x) (unsigned long)(((N_MAGIC(x) == ZMAGIC) && \
36 ((x).a_entry < SPARC_PGSIZE)) ? \
37 0 : SPARC_PGSIZE)
38
39/* And same for the data segment.. */
40#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC ? \
41 (N_TXTADDR(x) + (x).a_text) \
42 : (unsigned long)(_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
43
44#define N_TRSIZE(a) ((a).a_trsize)
45#define N_DRSIZE(a) ((a).a_drsize)
46#define N_SYMSIZE(a) ((a).a_syms)
47
48#ifndef __ASSEMBLY__
49
50/*
51 * Sparc relocation types
52 */
53enum reloc_type
54{
55 RELOC_8,
56 RELOC_16,
57 RELOC_32, /* simplest relocs */
58 RELOC_DISP8,
59 RELOC_DISP16,
60 RELOC_DISP32, /* Disp's (pc-rel) */
61 RELOC_WDISP30,
62 RELOC_WDISP22, /* SR word disp's */
63 RELOC_HI22,
64 RELOC_22, /* SR 22-bit relocs */
65 RELOC_13,
66 RELOC_LO10, /* SR 13&10-bit relocs */
67 RELOC_SFA_BASE,
68 RELOC_SFA_OFF13, /* SR S.F.A. relocs */
69 RELOC_BASE10,
70 RELOC_BASE13,
71 RELOC_BASE22, /* base_relative pic */
72 RELOC_PC10,
73 RELOC_PC22, /* special pc-rel pic */
74 RELOC_JMP_TBL, /* jmp_tbl_rel in pic */
75 RELOC_SEGOFF16, /* ShLib offset-in-seg */
76 RELOC_GLOB_DAT,
77 RELOC_JMP_SLOT,
78 RELOC_RELATIVE /* rtld relocs */
79};
80
81/*
82 * Format of a relocation datum.
83 */
84struct relocation_info /* used when header.a_machtype == M_SPARC */
85{
86 unsigned int r_address; /* relocation addr */
87 unsigned int r_index:24; /* segment index or symbol index */
88 unsigned int r_extern:1; /* if F, r_index==SEG#; if T, SYM idx */
89 int r_pad:2; /* <unused> */
90 enum reloc_type r_type:5; /* type of relocation to perform */
91 int r_addend; /* addend for relocation value */
92};
93
94#define N_RELOCATION_INFO_DECLARED 1
95
96#ifdef __KERNEL__
97
98#define STACK_TOP (test_thread_flag(TIF_32BIT) ? 0xf0000000 : 0x80000000000L)
99
100#endif
101
102#endif /* !(__ASSEMBLY__) */
103
104#endif /* !(__SPARC64_A_OUT_H__) */
diff --git a/include/asm-sparc64/agp.h b/include/asm-sparc64/agp.h
new file mode 100644
index 000000000000..ba05bdf9a211
--- /dev/null
+++ b/include/asm-sparc64/agp.h
@@ -0,0 +1,11 @@
1#ifndef AGP_H
2#define AGP_H 1
3
4/* dummy for now */
5
6#define map_page_into_agp(page)
7#define unmap_page_from_agp(page)
8#define flush_agp_mappings()
9#define flush_agp_cache() mb()
10
11#endif
diff --git a/include/asm-sparc64/apb.h b/include/asm-sparc64/apb.h
new file mode 100644
index 000000000000..80f0df289a66
--- /dev/null
+++ b/include/asm-sparc64/apb.h
@@ -0,0 +1,36 @@
1/* $Id: apb.h,v 1.2 1998/04/01 20:41:49 ecd Exp $
2 * apb.h: Advanced PCI Bridge Configuration Registers and Bits
3 *
4 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
5 */
6
7#ifndef _SPARC64_APB_H
8#define _SPARC64_APB_H
9
10#define APB_TICK_REGISTER 0xb0
11#define APB_INT_ACK 0xb8
12#define APB_PRIMARY_MASTER_RETRY_LIMIT 0xc0
13#define APB_DMA_ASFR 0xc8
14#define APB_DMA_AFAR 0xd0
15#define APB_PIO_TARGET_RETRY_LIMIT 0xd8
16#define APB_PIO_TARGET_LATENCY_TIMER 0xd9
17#define APB_DMA_TARGET_RETRY_LIMIT 0xda
18#define APB_DMA_TARGET_LATENCY_TIMER 0xdb
19#define APB_SECONDARY_MASTER_RETRY_LIMIT 0xdc
20#define APB_SECONDARY_CONTROL 0xdd
21#define APB_IO_ADDRESS_MAP 0xde
22#define APB_MEM_ADDRESS_MAP 0xdf
23
24#define APB_PCI_CONTROL_LOW 0xe0
25# define APB_PCI_CTL_LOW_ARB_PARK (1 << 21)
26# define APB_PCI_CTL_LOW_ERRINT_EN (1 << 8)
27
28#define APB_PCI_CONTROL_HIGH 0xe4
29# define APB_PCI_CTL_HIGH_SERR (1 << 2)
30# define APB_PCI_CTL_HIGH_ARBITER_EN (1 << 0)
31
32#define APB_PIO_ASFR 0xe8
33#define APB_PIO_AFAR 0xf0
34#define APB_DIAG_REGISTER 0xf8
35
36#endif /* !(_SPARC64_APB_H) */
diff --git a/include/asm-sparc64/asi.h b/include/asm-sparc64/asi.h
new file mode 100644
index 000000000000..534855660f2a
--- /dev/null
+++ b/include/asm-sparc64/asi.h
@@ -0,0 +1,145 @@
1/* $Id: asi.h,v 1.5 2001/03/29 11:47:47 davem Exp $ */
2#ifndef _SPARC64_ASI_H
3#define _SPARC64_ASI_H
4
5/* asi.h: Address Space Identifier values for the V9.
6 *
7 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
8 */
9
10/* V9 Architecture mandary ASIs. */
11#define ASI_N 0x04 /* Nucleus */
12#define ASI_NL 0x0c /* Nucleus, little endian */
13#define ASI_AIUP 0x10 /* Primary, user */
14#define ASI_AIUS 0x11 /* Secondary, user */
15#define ASI_AIUPL 0x18 /* Primary, user, little endian */
16#define ASI_AIUSL 0x19 /* Secondary, user, little endian */
17#define ASI_P 0x80 /* Primary, implicit */
18#define ASI_S 0x81 /* Secondary, implicit */
19#define ASI_PNF 0x82 /* Primary, no fault */
20#define ASI_SNF 0x83 /* Secondary, no fault */
21#define ASI_PL 0x88 /* Primary, implicit, l-endian */
22#define ASI_SL 0x89 /* Secondary, implicit, l-endian */
23#define ASI_PNFL 0x8a /* Primary, no fault, l-endian */
24#define ASI_SNFL 0x8b /* Secondary, no fault, l-endian */
25
26/* SpitFire and later extended ASIs. The "(III)" marker designates
27 * UltraSparc-III and later specific ASIs. The "(CMT)" marker designates
28 * Chip Multi Threading specific ASIs.
29 */
30#define ASI_PHYS_USE_EC 0x14 /* PADDR, E-cachable */
31#define ASI_PHYS_BYPASS_EC_E 0x15 /* PADDR, E-bit */
32#define ASI_PHYS_USE_EC_L 0x1c /* PADDR, E-cachable, little endian*/
33#define ASI_PHYS_BYPASS_EC_E_L 0x1d /* PADDR, E-bit, little endian */
34#define ASI_NUCLEUS_QUAD_LDD 0x24 /* Cachable, qword load */
35#define ASI_NUCLEUS_QUAD_LDD_L 0x2c /* Cachable, qword load, l-endian */
36#define ASI_PCACHE_DATA_STATUS 0x30 /* (III) PCache data stat RAM diag */
37#define ASI_PCACHE_DATA 0x31 /* (III) PCache data RAM diag */
38#define ASI_PCACHE_TAG 0x32 /* (III) PCache tag RAM diag */
39#define ASI_PCACHE_SNOOP_TAG 0x33 /* (III) PCache snoop tag RAM diag */
40#define ASI_QUAD_LDD_PHYS 0x34 /* (III+) PADDR, qword load */
41#define ASI_WCACHE_VALID_BITS 0x38 /* (III) WCache Valid Bits diag */
42#define ASI_WCACHE_DATA 0x39 /* (III) WCache data RAM diag */
43#define ASI_WCACHE_TAG 0x3a /* (III) WCache tag RAM diag */
44#define ASI_WCACHE_SNOOP_TAG 0x3b /* (III) WCache snoop tag RAM diag */
45#define ASI_QUAD_LDD_PHYS_L 0x3c /* (III+) PADDR, qw-load, l-endian */
46#define ASI_SRAM_FAST_INIT 0x40 /* (III+) Fast SRAM init */
47#define ASI_CORE_AVAILABLE 0x41 /* (CMT) LP Available */
48#define ASI_CORE_ENABLE_STAT 0x41 /* (CMT) LP Enable Status */
49#define ASI_CORE_ENABLE 0x41 /* (CMT) LP Enable RW */
50#define ASI_XIR_STEERING 0x41 /* (CMT) XIR Steering RW */
51#define ASI_CORE_RUNNING_RW 0x41 /* (CMT) LP Running RW */
52#define ASI_CORE_RUNNING_W1S 0x41 /* (CMT) LP Running Write-One Set */
53#define ASI_CORE_RUNNING_W1C 0x41 /* (CMT) LP Running Write-One Clr */
54#define ASI_CORE_RUNNING_STAT 0x41 /* (CMT) LP Running Status */
55#define ASI_CMT_ERROR_STEERING 0x41 /* (CMT) Error Steering RW */
56#define ASI_DCACHE_INVALIDATE 0x42 /* (III) DCache Invalidate diag */
57#define ASI_DCACHE_UTAG 0x43 /* (III) DCache uTag diag */
58#define ASI_DCACHE_SNOOP_TAG 0x44 /* (III) DCache snoop tag RAM diag */
59#define ASI_LSU_CONTROL 0x45 /* Load-store control unit */
60#define ASI_DCU_CONTROL_REG 0x45 /* (III) DCache Unit Control reg */
61#define ASI_DCACHE_DATA 0x46 /* DCache data-ram diag access */
62#define ASI_DCACHE_TAG 0x47 /* Dcache tag/valid ram diag access*/
63#define ASI_INTR_DISPATCH_STAT 0x48 /* IRQ vector dispatch status */
64#define ASI_INTR_RECEIVE 0x49 /* IRQ vector receive status */
65#define ASI_UPA_CONFIG 0x4a /* UPA config space */
66#define ASI_JBUS_CONFIG 0x4a /* (IIIi) JBUS Config Register */
67#define ASI_SAFARI_CONFIG 0x4a /* (III) Safari Config Register */
68#define ASI_SAFARI_ADDRESS 0x4a /* (III) Safari Address Register */
69#define ASI_ESTATE_ERROR_EN 0x4b /* E-cache error enable space */
70#define ASI_AFSR 0x4c /* Async fault status register */
71#define ASI_AFAR 0x4d /* Async fault address register */
72#define ASI_EC_TAG_DATA 0x4e /* E-cache tag/valid ram diag acc */
73#define ASI_IMMU 0x50 /* Insn-MMU main register space */
74#define ASI_IMMU_TSB_8KB_PTR 0x51 /* Insn-MMU 8KB TSB pointer reg */
75#define ASI_IMMU_TSB_64KB_PTR 0x52 /* Insn-MMU 64KB TSB pointer reg */
76#define ASI_ITLB_DATA_IN 0x54 /* Insn-MMU TLB data in reg */
77#define ASI_ITLB_DATA_ACCESS 0x55 /* Insn-MMU TLB data access reg */
78#define ASI_ITLB_TAG_READ 0x56 /* Insn-MMU TLB tag read reg */
79#define ASI_IMMU_DEMAP 0x57 /* Insn-MMU TLB demap */
80#define ASI_DMMU 0x58 /* Data-MMU main register space */
81#define ASI_DMMU_TSB_8KB_PTR 0x59 /* Data-MMU 8KB TSB pointer reg */
82#define ASI_DMMU_TSB_64KB_PTR 0x5a /* Data-MMU 16KB TSB pointer reg */
83#define ASI_DMMU_TSB_DIRECT_PTR 0x5b /* Data-MMU TSB direct pointer reg */
84#define ASI_DTLB_DATA_IN 0x5c /* Data-MMU TLB data in reg */
85#define ASI_DTLB_DATA_ACCESS 0x5d /* Data-MMU TLB data access reg */
86#define ASI_DTLB_TAG_READ 0x5e /* Data-MMU TLB tag read reg */
87#define ASI_DMMU_DEMAP 0x5f /* Data-MMU TLB demap */
88#define ASI_IIU_INST_TRAP 0x60 /* (III) Instruction Breakpoint */
89#define ASI_INTR_ID 0x63 /* (CMT) Interrupt ID register */
90#define ASI_CORE_ID 0x63 /* (CMT) LP ID register */
91#define ASI_CESR_ID 0x63 /* (CMT) CESR ID register */
92#define ASI_IC_INSTR 0x66 /* Insn cache instrucion ram diag */
93#define ASI_IC_TAG 0x67 /* Insn cache tag/valid ram diag */
94#define ASI_IC_STAG 0x68 /* (III) Insn cache snoop tag ram */
95#define ASI_IC_PRE_DECODE 0x6e /* Insn cache pre-decode ram diag */
96#define ASI_IC_NEXT_FIELD 0x6f /* Insn cache next-field ram diag */
97#define ASI_BRPRED_ARRAY 0x6f /* (III) Branch Prediction RAM diag*/
98#define ASI_BLK_AIUP 0x70 /* Primary, user, block load/store */
99#define ASI_BLK_AIUS 0x71 /* Secondary, user, block ld/st */
100#define ASI_MCU_CTRL_REG 0x72 /* (III) Memory controller regs */
101#define ASI_EC_DATA 0x74 /* (III) E-cache data staging reg */
102#define ASI_EC_CTRL 0x75 /* (III) E-cache control reg */
103#define ASI_EC_W 0x76 /* E-cache diag write access */
104#define ASI_UDB_ERROR_W 0x77 /* External UDB error regs W */
105#define ASI_UDB_CONTROL_W 0x77 /* External UDB control regs W */
106#define ASI_INTR_W 0x77 /* IRQ vector dispatch write */
107#define ASI_INTR_DATAN_W 0x77 /* (III) Out irq vector data reg N */
108#define ASI_INTR_DISPATCH_W 0x77 /* (III) Interrupt vector dispatch */
109#define ASI_BLK_AIUPL 0x78 /* Primary, user, little, blk ld/st*/
110#define ASI_BLK_AIUSL 0x79 /* Secondary, user, little, blk ld/st*/
111#define ASI_EC_R 0x7e /* E-cache diag read access */
112#define ASI_UDBH_ERROR_R 0x7f /* External UDB error regs rd hi */
113#define ASI_UDBL_ERROR_R 0x7f /* External UDB error regs rd low */
114#define ASI_UDBH_CONTROL_R 0x7f /* External UDB control regs rd hi */
115#define ASI_UDBL_CONTROL_R 0x7f /* External UDB control regs rd low*/
116#define ASI_INTR_R 0x7f /* IRQ vector dispatch read */
117#define ASI_INTR_DATAN_R 0x7f /* (III) In irq vector data reg N */
118#define ASI_PST8_P 0xc0 /* Primary, 8 8-bit, partial */
119#define ASI_PST8_S 0xc1 /* Secondary, 8 8-bit, partial */
120#define ASI_PST16_P 0xc2 /* Primary, 4 16-bit, partial */
121#define ASI_PST16_S 0xc3 /* Secondary, 4 16-bit, partial */
122#define ASI_PST32_P 0xc4 /* Primary, 2 32-bit, partial */
123#define ASI_PST32_S 0xc5 /* Secondary, 2 32-bit, partial */
124#define ASI_PST8_PL 0xc8 /* Primary, 8 8-bit, partial, L */
125#define ASI_PST8_SL 0xc9 /* Secondary, 8 8-bit, partial, L */
126#define ASI_PST16_PL 0xca /* Primary, 4 16-bit, partial, L */
127#define ASI_PST16_SL 0xcb /* Secondary, 4 16-bit, partial, L */
128#define ASI_PST32_PL 0xcc /* Primary, 2 32-bit, partial, L */
129#define ASI_PST32_SL 0xcd /* Secondary, 2 32-bit, partial, L */
130#define ASI_FL8_P 0xd0 /* Primary, 1 8-bit, fpu ld/st */
131#define ASI_FL8_S 0xd1 /* Secondary, 1 8-bit, fpu ld/st */
132#define ASI_FL16_P 0xd2 /* Primary, 1 16-bit, fpu ld/st */
133#define ASI_FL16_S 0xd3 /* Secondary, 1 16-bit, fpu ld/st */
134#define ASI_FL8_PL 0xd8 /* Primary, 1 8-bit, fpu ld/st, L */
135#define ASI_FL8_SL 0xd9 /* Secondary, 1 8-bit, fpu ld/st, L*/
136#define ASI_FL16_PL 0xda /* Primary, 1 16-bit, fpu ld/st, L */
137#define ASI_FL16_SL 0xdb /* Secondary, 1 16-bit, fpu ld/st,L*/
138#define ASI_BLK_COMMIT_P 0xe0 /* Primary, blk store commit */
139#define ASI_BLK_COMMIT_S 0xe1 /* Secondary, blk store commit */
140#define ASI_BLK_P 0xf0 /* Primary, blk ld/st */
141#define ASI_BLK_S 0xf1 /* Secondary, blk ld/st */
142#define ASI_BLK_PL 0xf8 /* Primary, blk ld/st, little */
143#define ASI_BLK_SL 0xf9 /* Secondary, blk ld/st, little */
144
145#endif /* _SPARC64_ASI_H */
diff --git a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h
new file mode 100644
index 000000000000..d80f3379669b
--- /dev/null
+++ b/include/asm-sparc64/atomic.h
@@ -0,0 +1,86 @@
1/* $Id: atomic.h,v 1.22 2001/07/11 23:56:07 davem Exp $
2 * atomic.h: Thankfully the V9 is at least reasonable for this
3 * stuff.
4 *
5 * Copyright (C) 1996, 1997, 2000 David S. Miller (davem@redhat.com)
6 */
7
8#ifndef __ARCH_SPARC64_ATOMIC__
9#define __ARCH_SPARC64_ATOMIC__
10
11#include <linux/config.h>
12#include <linux/types.h>
13
14typedef struct { volatile int counter; } atomic_t;
15typedef struct { volatile __s64 counter; } atomic64_t;
16
17#define ATOMIC_INIT(i) { (i) }
18#define ATOMIC64_INIT(i) { (i) }
19
20#define atomic_read(v) ((v)->counter)
21#define atomic64_read(v) ((v)->counter)
22
23#define atomic_set(v, i) (((v)->counter) = i)
24#define atomic64_set(v, i) (((v)->counter) = i)
25
26extern void atomic_add(int, atomic_t *);
27extern void atomic64_add(int, atomic64_t *);
28extern void atomic_sub(int, atomic_t *);
29extern void atomic64_sub(int, atomic64_t *);
30
31extern int atomic_add_ret(int, atomic_t *);
32extern int atomic64_add_ret(int, atomic64_t *);
33extern int atomic_sub_ret(int, atomic_t *);
34extern int atomic64_sub_ret(int, atomic64_t *);
35
36#define atomic_dec_return(v) atomic_sub_ret(1, v)
37#define atomic64_dec_return(v) atomic64_sub_ret(1, v)
38
39#define atomic_inc_return(v) atomic_add_ret(1, v)
40#define atomic64_inc_return(v) atomic64_add_ret(1, v)
41
42#define atomic_sub_return(i, v) atomic_sub_ret(i, v)
43#define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
44
45#define atomic_add_return(i, v) atomic_add_ret(i, v)
46#define atomic64_add_return(i, v) atomic64_add_ret(i, v)
47
48/*
49 * atomic_inc_and_test - increment and test
50 * @v: pointer of type atomic_t
51 *
52 * Atomically increments @v by 1
53 * and returns true if the result is zero, or false for all
54 * other cases.
55 */
56#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
57
58#define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
59#define atomic64_sub_and_test(i, v) (atomic64_sub_ret(i, v) == 0)
60
61#define atomic_dec_and_test(v) (atomic_sub_ret(1, v) == 0)
62#define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
63
64#define atomic_inc(v) atomic_add(1, v)
65#define atomic64_inc(v) atomic64_add(1, v)
66
67#define atomic_dec(v) atomic_sub(1, v)
68#define atomic64_dec(v) atomic64_sub(1, v)
69
70#define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
71#define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
72
73/* Atomic operations are already serializing */
74#ifdef CONFIG_SMP
75#define smp_mb__before_atomic_dec() membar("#StoreLoad | #LoadLoad")
76#define smp_mb__after_atomic_dec() membar("#StoreLoad | #StoreStore")
77#define smp_mb__before_atomic_inc() membar("#StoreLoad | #LoadLoad")
78#define smp_mb__after_atomic_inc() membar("#StoreLoad | #StoreStore")
79#else
80#define smp_mb__before_atomic_dec() barrier()
81#define smp_mb__after_atomic_dec() barrier()
82#define smp_mb__before_atomic_inc() barrier()
83#define smp_mb__after_atomic_inc() barrier()
84#endif
85
86#endif /* !(__ARCH_SPARC64_ATOMIC__) */
diff --git a/include/asm-sparc64/audioio.h b/include/asm-sparc64/audioio.h
new file mode 100644
index 000000000000..cf16173f521b
--- /dev/null
+++ b/include/asm-sparc64/audioio.h
@@ -0,0 +1,234 @@
1/*
2 * include/asm-sparc/audioio.h
3 *
4 * Sparc Audio Midlayer
5 * Copyright (C) 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu)
6 */
7
8#ifndef _AUDIOIO_H_
9#define _AUDIOIO_H_
10
11/*
12 * SunOS/Solaris /dev/audio interface
13 */
14
15#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
16#include <linux/types.h>
17#include <linux/time.h>
18#include <linux/ioctl.h>
19#endif
20
21/*
22 * This structure contains state information for audio device IO streams.
23 */
24typedef struct audio_prinfo {
25 /*
26 * The following values describe the audio data encoding.
27 */
28 unsigned int sample_rate; /* samples per second */
29 unsigned int channels; /* number of interleaved channels */
30 unsigned int precision; /* bit-width of each sample */
31 unsigned int encoding; /* data encoding method */
32
33 /*
34 * The following values control audio device configuration
35 */
36 unsigned int gain; /* gain level: 0 - 255 */
37 unsigned int port; /* selected I/O port (see below) */
38 unsigned int avail_ports; /* available I/O ports (see below) */
39 unsigned int _xxx[2]; /* Reserved for future use */
40
41 unsigned int buffer_size; /* I/O buffer size */
42
43 /*
44 * The following values describe driver state
45 */
46 unsigned int samples; /* number of samples converted */
47 unsigned int eof; /* End Of File counter (play only) */
48
49 unsigned char pause; /* non-zero for pause, zero to resume */
50 unsigned char error; /* non-zero if overflow/underflow */
51 unsigned char waiting; /* non-zero if a process wants access */
52 unsigned char balance; /* stereo channel balance */
53
54 unsigned short minordev;
55
56 /*
57 * The following values are read-only state flags
58 */
59 unsigned char open; /* non-zero if open access permitted */
60 unsigned char active; /* non-zero if I/O is active */
61} audio_prinfo_t;
62
63
64/*
65 * This structure describes the current state of the audio device.
66 */
67typedef struct audio_info {
68 /*
69 * Per-stream information
70 */
71 audio_prinfo_t play; /* output status information */
72 audio_prinfo_t record; /* input status information */
73
74 /*
75 * Per-unit/channel information
76 */
77 unsigned int monitor_gain; /* input to output mix: 0 - 255 */
78 unsigned char output_muted; /* non-zero if output is muted */
79 unsigned char _xxx[3]; /* Reserved for future use */
80 unsigned int _yyy[3]; /* Reserved for future use */
81} audio_info_t;
82
83
84/*
85 * Audio encoding types
86 */
87#define AUDIO_ENCODING_NONE (0) /* no encoding assigned */
88#define AUDIO_ENCODING_ULAW (1) /* u-law encoding */
89#define AUDIO_ENCODING_ALAW (2) /* A-law encoding */
90#define AUDIO_ENCODING_LINEAR (3) /* Linear PCM encoding */
91#define AUDIO_ENCODING_FLOAT (4) /* IEEE float (-1. <-> +1.) */
92#define AUDIO_ENCODING_DVI (104) /* DVI ADPCM */
93#define AUDIO_ENCODING_LINEAR8 (105) /* 8 bit UNSIGNED */
94#define AUDIO_ENCODING_LINEARLE (106) /* Linear PCM LE encoding */
95
96/*
97 * These ranges apply to record, play, and monitor gain values
98 */
99#define AUDIO_MIN_GAIN (0) /* minimum gain value */
100#define AUDIO_MAX_GAIN (255) /* maximum gain value */
101
102/*
103 * These values apply to the balance field to adjust channel gain values
104 */
105#define AUDIO_LEFT_BALANCE (0) /* left channel only */
106#define AUDIO_MID_BALANCE (32) /* equal left/right channel */
107#define AUDIO_RIGHT_BALANCE (64) /* right channel only */
108#define AUDIO_BALANCE_SHIFT (3)
109
110/*
111 * Generic minimum/maximum limits for number of channels, both modes
112 */
113#define AUDIO_MIN_PLAY_CHANNELS (1)
114#define AUDIO_MAX_PLAY_CHANNELS (4)
115#define AUDIO_MIN_REC_CHANNELS (1)
116#define AUDIO_MAX_REC_CHANNELS (4)
117
118/*
119 * Generic minimum/maximum limits for sample precision
120 */
121#define AUDIO_MIN_PLAY_PRECISION (8)
122#define AUDIO_MAX_PLAY_PRECISION (32)
123#define AUDIO_MIN_REC_PRECISION (8)
124#define AUDIO_MAX_REC_PRECISION (32)
125
126/*
127 * Define some convenient names for typical audio ports
128 */
129/*
130 * output ports (several may be enabled simultaneously)
131 */
132#define AUDIO_SPEAKER 0x01 /* output to built-in speaker */
133#define AUDIO_HEADPHONE 0x02 /* output to headphone jack */
134#define AUDIO_LINE_OUT 0x04 /* output to line out */
135
136/*
137 * input ports (usually only one at a time)
138 */
139#define AUDIO_MICROPHONE 0x01 /* input from microphone */
140#define AUDIO_LINE_IN 0x02 /* input from line in */
141#define AUDIO_CD 0x04 /* input from on-board CD inputs */
142#define AUDIO_INTERNAL_CD_IN AUDIO_CD /* input from internal CDROM */
143#define AUDIO_ANALOG_LOOPBACK 0x40 /* input from output */
144
145
146/*
147 * This macro initializes an audio_info structure to 'harmless' values.
148 * Note that (~0) might not be a harmless value for a flag that was
149 * a signed int.
150 */
151#define AUDIO_INITINFO(i) { \
152 unsigned int *__x__; \
153 for (__x__ = (unsigned int *)(i); \
154 (char *) __x__ < (((char *)(i)) + sizeof (audio_info_t)); \
155 *__x__++ = ~0); \
156}
157
158/*
159 * These allow testing for what the user wants to set
160 */
161#define AUD_INITVALUE (~0)
162#define Modify(X) ((unsigned int)(X) != AUD_INITVALUE)
163#define Modifys(X) ((X) != (unsigned short)AUD_INITVALUE)
164#define Modifyc(X) ((X) != (unsigned char)AUD_INITVALUE)
165
166/*
167 * Parameter for the AUDIO_GETDEV ioctl to determine current
168 * audio devices.
169 */
170#define MAX_AUDIO_DEV_LEN (16)
171typedef struct audio_device {
172 char name[MAX_AUDIO_DEV_LEN];
173 char version[MAX_AUDIO_DEV_LEN];
174 char config[MAX_AUDIO_DEV_LEN];
175} audio_device_t;
176
177
178/*
179 * Ioctl calls for the audio device.
180 */
181
182/*
183 * AUDIO_GETINFO retrieves the current state of the audio device.
184 *
185 * AUDIO_SETINFO copies all fields of the audio_info structure whose
186 * values are not set to the initialized value (-1) to the device state.
187 * It performs an implicit AUDIO_GETINFO to return the new state of the
188 * device. Note that the record.samples and play.samples fields are set
189 * to the last value before the AUDIO_SETINFO took effect. This allows
190 * an application to reset the counters while atomically retrieving the
191 * last value.
192 *
193 * AUDIO_DRAIN suspends the calling process until the write buffers are
194 * empty.
195 *
196 * AUDIO_GETDEV returns a structure of type audio_device_t which contains
197 * three strings. The string "name" is a short identifying string (for
198 * example, the SBus Fcode name string), the string "version" identifies
199 * the current version of the device, and the "config" string identifies
200 * the specific configuration of the audio stream. All fields are
201 * device-dependent -- see the device specific manual pages for details.
202 *
203 * AUDIO_GETDEV_SUNOS returns a number which is an audio device defined
204 * herein (making it not too portable)
205 *
206 * AUDIO_FLUSH stops all playback and recording, clears all queued buffers,
207 * resets error counters, and restarts recording and playback as appropriate
208 * for the current sampling mode.
209 */
210#define AUDIO_GETINFO _IOR('A', 1, audio_info_t)
211#define AUDIO_SETINFO _IOWR('A', 2, audio_info_t)
212#define AUDIO_DRAIN _IO('A', 3)
213#define AUDIO_GETDEV _IOR('A', 4, audio_device_t)
214#define AUDIO_GETDEV_SUNOS _IOR('A', 4, int)
215#define AUDIO_FLUSH _IO('A', 5)
216
217/* Define possible audio hardware configurations for
218 * old SunOS-style AUDIO_GETDEV ioctl */
219#define AUDIO_DEV_UNKNOWN (0) /* not defined */
220#define AUDIO_DEV_AMD (1) /* audioamd device */
221#define AUDIO_DEV_SPEAKERBOX (2) /* dbri device with speakerbox */
222#define AUDIO_DEV_CODEC (3) /* dbri device (internal speaker) */
223#define AUDIO_DEV_CS4231 (5) /* cs4231 device */
224
225/*
226 * The following ioctl sets the audio device into an internal loopback mode,
227 * if the hardware supports this. The argument is TRUE to set loopback,
228 * FALSE to reset to normal operation. If the hardware does not support
229 * internal loopback, the ioctl should fail with EINVAL.
230 * Causes ADC data to be digitally mixed in and sent to the DAC.
231 */
232#define AUDIO_DIAG_LOOPBACK _IOW('A', 101, int)
233
234#endif /* _AUDIOIO_H_ */
diff --git a/include/asm-sparc64/auxio.h b/include/asm-sparc64/auxio.h
new file mode 100644
index 000000000000..5eb01dd47150
--- /dev/null
+++ b/include/asm-sparc64/auxio.h
@@ -0,0 +1,98 @@
1/* $Id: auxio.h,v 1.3 2001/06/05 08:16:34 davem Exp $
2 * auxio.h: Definitions and code for the Auxiliary I/O registers.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 *
6 * Refactoring for unified NCR/PCIO support 2002 Eric Brower (ebrower@usa.net)
7 */
8#ifndef _SPARC64_AUXIO_H
9#define _SPARC64_AUXIO_H
10
11/* AUXIO implementations:
12 * sbus-based NCR89C105 "Slavio"
13 * LED/Floppy (AUX1) register
14 * Power (AUX2) register
15 *
16 * ebus-based auxio on PCIO
17 * LED Auxio Register
18 * Power Auxio Register
19 *
20 * Register definitions from NCR _NCR89C105 Chip Specification_
21 *
22 * SLAVIO AUX1 @ 0x1900000
23 * -------------------------------------------------
24 * | (R) | (R) | D | (R) | E | M | T | L |
25 * -------------------------------------------------
26 * (R) - bit 7:6,4 are reserved and should be masked in s/w
27 * D - Floppy Density Sense (1=high density) R/O
28 * E - Link Test Enable, directly reflected on AT&T 7213 LTE pin
29 * M - Monitor/Mouse Mux, directly reflected on MON_MSE_MUX pin
30 * T - Terminal Count: sends TC pulse to 82077 floppy controller
31 * L - System LED on front panel (0=off, 1=on)
32 */
33#define AUXIO_AUX1_MASK 0xc0 /* Mask bits */
34#define AUXIO_AUX1_FDENS 0x20 /* Floppy Density Sense */
35#define AUXIO_AUX1_LTE 0x08 /* Link Test Enable */
36#define AUXIO_AUX1_MMUX 0x04 /* Monitor/Mouse Mux */
37#define AUXIO_AUX1_FTCNT 0x02 /* Terminal Count, */
38#define AUXIO_AUX1_LED 0x01 /* System LED */
39
40/* SLAVIO AUX2 @ 0x1910000
41 * -------------------------------------------------
42 * | (R) | (R) | D | (R) | (R) | (R) | C | F |
43 * -------------------------------------------------
44 * (R) - bits 7:6,4:2 are reserved and should be masked in s/w
45 * D - Power Failure Detect (1=power fail)
46 * C - Clear Power Failure Detect Int (1=clear)
47 * F - Power Off (1=power off)
48 */
49#define AUXIO_AUX2_MASK 0xdc /* Mask Bits */
50#define AUXIO_AUX2_PFAILDET 0x20 /* Power Fail Detect */
51#define AUXIO_AUX2_PFAILCLR 0x02 /* Clear Pwr Fail Det Intr */
52#define AUXIO_AUX2_PWR_OFF 0x01 /* Power Off */
53
54/* Register definitions from Sun Microsystems _PCIO_ p/n 802-7837
55 *
56 * PCIO LED Auxio @ 0x726000
57 * -------------------------------------------------
58 * | 31:1 Unused | LED |
59 * -------------------------------------------------
60 * Bits 31:1 unused
61 * LED - System LED on front panel (0=off, 1=on)
62 */
63#define AUXIO_PCIO_LED 0x01 /* System LED */
64
65/* PCIO Power Auxio @ 0x724000
66 * -------------------------------------------------
67 * | 31:2 Unused | CPO | SPO |
68 * -------------------------------------------------
69 * Bits 31:2 unused
70 * CPO - Courtesy Power Off (1=off)
71 * SPO - System Power Off (1=off)
72 */
73#define AUXIO_PCIO_CPWR_OFF 0x02 /* Courtesy Power Off */
74#define AUXIO_PCIO_SPWR_OFF 0x01 /* System Power Off */
75
76#ifndef __ASSEMBLY__
77
78#define AUXIO_LTE_ON 1
79#define AUXIO_LTE_OFF 0
80
81/* auxio_set_lte - Set Link Test Enable (TPE Link Detect)
82 *
83 * on - AUXIO_LTE_ON or AUXIO_LTE_OFF
84 */
85extern void auxio_set_lte(int on);
86
87#define AUXIO_LED_ON 1
88#define AUXIO_LED_OFF 0
89
90/* auxio_set_led - Set system front panel LED
91 *
92 * on - AUXIO_LED_ON or AUXIO_LED_OFF
93 */
94extern void auxio_set_led(int on);
95
96#endif /* ifndef __ASSEMBLY__ */
97
98#endif /* !(_SPARC64_AUXIO_H) */
diff --git a/include/asm-sparc64/bbc.h b/include/asm-sparc64/bbc.h
new file mode 100644
index 000000000000..368fce4eedba
--- /dev/null
+++ b/include/asm-sparc64/bbc.h
@@ -0,0 +1,225 @@
1/* $Id: bbc.h,v 1.2 2001/03/26 23:47:18 davem Exp $
2 * bbc.h: Defines for BootBus Controller found on UltraSPARC-III
3 * systems.
4 *
5 * Copyright (C) 2000 David S. Miller (davem@redhat.com)
6 */
7
8#ifndef _SPARC64_BBC_H
9#define _SPARC64_BBC_H
10
11/* Register sizes are indicated by "B" (Byte, 1-byte),
12 * "H" (Half-word, 2 bytes), "W" (Word, 4 bytes) or
13 * "Q" (Quad, 8 bytes) inside brackets.
14 */
15
16#define BBC_AID 0x00 /* [B] Agent ID */
17#define BBC_DEVP 0x01 /* [B] Device Present */
18#define BBC_ARB 0x02 /* [B] Arbitration */
19#define BBC_QUIESCE 0x03 /* [B] Quiesce */
20#define BBC_WDACTION 0x04 /* [B] Watchdog Action */
21#define BBC_SPG 0x06 /* [B] Soft POR Gen */
22#define BBC_SXG 0x07 /* [B] Soft XIR Gen */
23#define BBC_PSRC 0x08 /* [W] POR Source */
24#define BBC_XSRC 0x0c /* [B] XIR Source */
25#define BBC_CSC 0x0d /* [B] Clock Synthesizers Control*/
26#define BBC_ES_CTRL 0x0e /* [H] Energy Star Control */
27#define BBC_ES_ACT 0x10 /* [W] E* Assert Change Time */
28#define BBC_ES_DACT 0x14 /* [B] E* De-Assert Change Time */
29#define BBC_ES_DABT 0x15 /* [B] E* De-Assert Bypass Time */
30#define BBC_ES_ABT 0x16 /* [H] E* Assert Bypass Time */
31#define BBC_ES_PST 0x18 /* [W] E* PLL Settle Time */
32#define BBC_ES_FSL 0x1c /* [W] E* Frequency Switch Latency*/
33#define BBC_EBUST 0x20 /* [Q] EBUS Timing */
34#define BBC_JTAG_CMD 0x28 /* [W] JTAG+ Command */
35#define BBC_JTAG_CTRL 0x2c /* [B] JTAG+ Control */
36#define BBC_I2C_SEL 0x2d /* [B] I2C Selection */
37#define BBC_I2C_0_S1 0x2e /* [B] I2C ctrlr-0 reg S1 */
38#define BBC_I2C_0_S0 0x2f /* [B] I2C ctrlr-0 regs S0,S0',S2,S3*/
39#define BBC_I2C_1_S1 0x30 /* [B] I2C ctrlr-1 reg S1 */
40#define BBC_I2C_1_S0 0x31 /* [B] I2C ctrlr-1 regs S0,S0',S2,S3*/
41#define BBC_KBD_BEEP 0x32 /* [B] Keyboard Beep */
42#define BBC_KBD_BCNT 0x34 /* [W] Keyboard Beep Counter */
43
44#define BBC_REGS_SIZE 0x40
45
46/* There is a 2K scratch ram area at offset 0x80000 but I doubt
47 * we will use it for anything.
48 */
49
50/* Agent ID register. This register shows the Safari Agent ID
51 * for the processors. The value returned depends upon which
52 * cpu is reading the register.
53 */
54#define BBC_AID_ID 0x07 /* Safari ID */
55#define BBC_AID_RESV 0xf8 /* Reserved */
56
57/* Device Present register. One can determine which cpus are actually
58 * present in the machine by interrogating this register.
59 */
60#define BBC_DEVP_CPU0 0x01 /* Processor 0 present */
61#define BBC_DEVP_CPU1 0x02 /* Processor 1 present */
62#define BBC_DEVP_CPU2 0x04 /* Processor 2 present */
63#define BBC_DEVP_CPU3 0x08 /* Processor 3 present */
64#define BBC_DEVP_RESV 0xf0 /* Reserved */
65
66/* Arbitration register. This register is used to block access to
67 * the BBC from a particular cpu.
68 */
69#define BBC_ARB_CPU0 0x01 /* Enable cpu 0 BBC arbitratrion */
70#define BBC_ARB_CPU1 0x02 /* Enable cpu 1 BBC arbitratrion */
71#define BBC_ARB_CPU2 0x04 /* Enable cpu 2 BBC arbitratrion */
72#define BBC_ARB_CPU3 0x08 /* Enable cpu 3 BBC arbitratrion */
73#define BBC_ARB_RESV 0xf0 /* Reserved */
74
75/* Quiesce register. Bus and BBC segments for cpus can be disabled
76 * with this register, ie. for hot plugging.
77 */
78#define BBC_QUIESCE_S02 0x01 /* Quiesce Safari segment for cpu 0 and 2 */
79#define BBC_QUIESCE_S13 0x02 /* Quiesce Safari segment for cpu 1 and 3 */
80#define BBC_QUIESCE_B02 0x04 /* Quiesce BBC segment for cpu 0 and 2 */
81#define BBC_QUIESCE_B13 0x08 /* Quiesce BBC segment for cpu 1 and 3 */
82#define BBC_QUIESCE_FD0 0x10 /* Disable Fatal_Error[0] reporting */
83#define BBC_QUIESCE_FD1 0x20 /* Disable Fatal_Error[1] reporting */
84#define BBC_QUIESCE_FD2 0x40 /* Disable Fatal_Error[2] reporting */
85#define BBC_QUIESCE_FD3 0x80 /* Disable Fatal_Error[3] reporting */
86
87/* Watchdog Action register. When the watchdog device timer expires
88 * a line is enabled to the BBC. The action BBC takes when this line
89 * is asserted can be controlled by this regiser.
90 */
91#define BBC_WDACTION_RST 0x01 /* When set, watchdog causes system reset.
92 * When clear, BBC ignores watchdog signal.
93 */
94#define BBC_WDACTION_RESV 0xfe /* Reserved */
95
96/* Soft_POR_GEN register. The POR (Power On Reset) signal may be asserted
97 * for specific processors or all processors via this register.
98 */
99#define BBC_SPG_CPU0 0x01 /* Assert POR for processor 0 */
100#define BBC_SPG_CPU1 0x02 /* Assert POR for processor 1 */
101#define BBC_SPG_CPU2 0x04 /* Assert POR for processor 2 */
102#define BBC_SPG_CPU3 0x08 /* Assert POR for processor 3 */
103#define BBC_SPG_CPUALL 0x10 /* Reset all processors and reset
104 * the entire system.
105 */
106#define BBC_SPG_RESV 0xe0 /* Reserved */
107
108/* Soft_XIR_GEN register. The XIR (eXternally Initiated Reset) signal
109 * may be asserted to specific processors via this register.
110 */
111#define BBC_SXG_CPU0 0x01 /* Assert XIR for processor 0 */
112#define BBC_SXG_CPU1 0x02 /* Assert XIR for processor 1 */
113#define BBC_SXG_CPU2 0x04 /* Assert XIR for processor 2 */
114#define BBC_SXG_CPU3 0x08 /* Assert XIR for processor 3 */
115#define BBC_SXG_RESV 0xf0 /* Reserved */
116
117/* POR Source register. One may identify the cause of the most recent
118 * reset by reading this register.
119 */
120#define BBC_PSRC_SPG0 0x0001 /* CPU 0 reset via BBC_SPG register */
121#define BBC_PSRC_SPG1 0x0002 /* CPU 1 reset via BBC_SPG register */
122#define BBC_PSRC_SPG2 0x0004 /* CPU 2 reset via BBC_SPG register */
123#define BBC_PSRC_SPG3 0x0008 /* CPU 3 reset via BBC_SPG register */
124#define BBC_PSRC_SPGSYS 0x0010 /* System reset via BBC_SPG register */
125#define BBC_PSRC_JTAG 0x0020 /* System reset via JTAG+ */
126#define BBC_PSRC_BUTTON 0x0040 /* System reset via push-button dongle */
127#define BBC_PSRC_PWRUP 0x0080 /* System reset via power-up */
128#define BBC_PSRC_FE0 0x0100 /* CPU 0 reported Fatal_Error */
129#define BBC_PSRC_FE1 0x0200 /* CPU 1 reported Fatal_Error */
130#define BBC_PSRC_FE2 0x0400 /* CPU 2 reported Fatal_Error */
131#define BBC_PSRC_FE3 0x0800 /* CPU 3 reported Fatal_Error */
132#define BBC_PSRC_FE4 0x1000 /* Schizo reported Fatal_Error */
133#define BBC_PSRC_FE5 0x2000 /* Safari device 5 reported Fatal_Error */
134#define BBC_PSRC_FE6 0x4000 /* CPMS reported Fatal_Error */
135#define BBC_PSRC_SYNTH 0x8000 /* System reset when on-board clock synthesizers
136 * were updated.
137 */
138#define BBC_PSRC_WDT 0x10000 /* System reset via Super I/O watchdog */
139#define BBC_PSRC_RSC 0x20000 /* System reset via RSC remote monitoring
140 * device
141 */
142
143/* XIR Source register. The source of an XIR event sent to a processor may
144 * be determined via this register.
145 */
146#define BBC_XSRC_SXG0 0x01 /* CPU 0 received XIR via Soft_XIR_GEN reg */
147#define BBC_XSRC_SXG1 0x02 /* CPU 1 received XIR via Soft_XIR_GEN reg */
148#define BBC_XSRC_SXG2 0x04 /* CPU 2 received XIR via Soft_XIR_GEN reg */
149#define BBC_XSRC_SXG3 0x08 /* CPU 3 received XIR via Soft_XIR_GEN reg */
150#define BBC_XSRC_JTAG 0x10 /* All CPUs received XIR via JTAG+ */
151#define BBC_XSRC_W_OR_B 0x20 /* All CPUs received XIR either because:
152 * a) Super I/O watchdog fired, or
153 * b) XIR push button was activated
154 */
155#define BBC_XSRC_RESV 0xc0 /* Reserved */
156
157/* Clock Synthesizers Control register. This register provides the big-bang
158 * programming interface to the two clock synthesizers of the machine.
159 */
160#define BBC_CSC_SLOAD 0x01 /* Directly connected to S_LOAD pins */
161#define BBC_CSC_SDATA 0x02 /* Directly connected to S_DATA pins */
162#define BBC_CSC_SCLOCK 0x04 /* Directly connected to S_CLOCK pins */
163#define BBC_CSC_RESV 0x78 /* Reserved */
164#define BBC_CSC_RST 0x80 /* Generate system reset when S_LOAD==1 */
165
166/* Energy Star Control register. This register is used to generate the
167 * clock frequency change trigger to the main system devices (Schizo and
168 * the processors). The transition occurs when bits in this register
169 * go from 0 to 1, only one bit must be set at once else no action
170 * occurs. Basically the sequence of events is:
171 * a) Choose new frequency: full, 1/2 or 1/32
172 * b) Program this desired frequency into the cpus and Schizo.
173 * c) Set the same value in this register.
174 * d) 16 system clocks later, clear this register.
175 */
176#define BBC_ES_CTRL_1_1 0x01 /* Full frequency */
177#define BBC_ES_CTRL_1_2 0x02 /* 1/2 frequency */
178#define BBC_ES_CTRL_1_32 0x20 /* 1/32 frequency */
179#define BBC_ES_RESV 0xdc /* Reserved */
180
181/* Energy Star Assert Change Time register. This determines the number
182 * of BBC clock cycles (which is half the system frequency) between
183 * the detection of FREEZE_ACK being asserted and the assertion of
184 * the CLK_CHANGE_L[2:0] signals.
185 */
186#define BBC_ES_ACT_VAL 0xff
187
188/* Energy Star Assert Bypass Time register. This determines the number
189 * of BBC clock cycles (which is half the system frequency) between
190 * the assertion of the CLK_CHANGE_L[2:0] signals and the assertion of
191 * the ESTAR_PLL_BYPASS signal.
192 */
193#define BBC_ES_ABT_VAL 0xffff
194
195/* Energy Star PLL Settle Time register. This determines the number of
196 * BBC clock cycles (which is half the system frequency) between the
197 * de-assertion of CLK_CHANGE_L[2:0] and the de-assertion of the FREEZE_L
198 * signal.
199 */
200#define BBC_ES_PST_VAL 0xffffffff
201
202/* Energy Star Frequency Switch Latency register. This is the number of
203 * BBC clocks between the de-assertion of CLK_CHANGE_L[2:0] and the first
204 * edge of the Safari clock at the new frequency.
205 */
206#define BBC_ES_FSL_VAL 0xffffffff
207
208/* Keyboard Beep control register. This is a simple enabler for the audio
209 * beep sound.
210 */
211#define BBC_KBD_BEEP_ENABLE 0x01 /* Enable beep */
212#define BBC_KBD_BEEP_RESV 0xfe /* Reserved */
213
214/* Keyboard Beep Counter register. There is a free-running counter inside
215 * the BBC which runs at half the system clock. The bit set in this register
216 * determines when the audio sound is generated. So for example if bit
217 * 10 is set, the audio beep will oscillate at 1/(2**12). The keyboard beep
218 * generator automatically selects a different bit to use if the system clock
219 * is changed via Energy Star.
220 */
221#define BBC_KBD_BCNT_BITS 0x0007fc00
222#define BBC_KBC_BCNT_RESV 0xfff803ff
223
224#endif /* _SPARC64_BBC_H */
225
diff --git a/include/asm-sparc64/bitops.h b/include/asm-sparc64/bitops.h
new file mode 100644
index 000000000000..9d722dc8cca3
--- /dev/null
+++ b/include/asm-sparc64/bitops.h
@@ -0,0 +1,294 @@
1/* $Id: bitops.h,v 1.39 2002/01/30 01:40:00 davem Exp $
2 * bitops.h: Bit string operations on the V9.
3 *
4 * Copyright 1996, 1997 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_BITOPS_H
8#define _SPARC64_BITOPS_H
9
10#include <linux/config.h>
11#include <linux/compiler.h>
12#include <asm/byteorder.h>
13
14extern int test_and_set_bit(unsigned long nr, volatile unsigned long *addr);
15extern int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr);
16extern int test_and_change_bit(unsigned long nr, volatile unsigned long *addr);
17extern void set_bit(unsigned long nr, volatile unsigned long *addr);
18extern void clear_bit(unsigned long nr, volatile unsigned long *addr);
19extern void change_bit(unsigned long nr, volatile unsigned long *addr);
20
21/* "non-atomic" versions... */
22
23static __inline__ void __set_bit(int nr, volatile unsigned long *addr)
24{
25 volatile unsigned long *m = addr + (nr >> 6);
26
27 *m |= (1UL << (nr & 63));
28}
29
30static __inline__ void __clear_bit(int nr, volatile unsigned long *addr)
31{
32 volatile unsigned long *m = addr + (nr >> 6);
33
34 *m &= ~(1UL << (nr & 63));
35}
36
37static __inline__ void __change_bit(int nr, volatile unsigned long *addr)
38{
39 volatile unsigned long *m = addr + (nr >> 6);
40
41 *m ^= (1UL << (nr & 63));
42}
43
44static __inline__ int __test_and_set_bit(int nr, volatile unsigned long *addr)
45{
46 volatile unsigned long *m = addr + (nr >> 6);
47 long old = *m;
48 long mask = (1UL << (nr & 63));
49
50 *m = (old | mask);
51 return ((old & mask) != 0);
52}
53
54static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr)
55{
56 volatile unsigned long *m = addr + (nr >> 6);
57 long old = *m;
58 long mask = (1UL << (nr & 63));
59
60 *m = (old & ~mask);
61 return ((old & mask) != 0);
62}
63
64static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr)
65{
66 volatile unsigned long *m = addr + (nr >> 6);
67 long old = *m;
68 long mask = (1UL << (nr & 63));
69
70 *m = (old ^ mask);
71 return ((old & mask) != 0);
72}
73
74#ifdef CONFIG_SMP
75#define smp_mb__before_clear_bit() membar("#StoreLoad | #LoadLoad")
76#define smp_mb__after_clear_bit() membar("#StoreLoad | #StoreStore")
77#else
78#define smp_mb__before_clear_bit() barrier()
79#define smp_mb__after_clear_bit() barrier()
80#endif
81
82static __inline__ int test_bit(int nr, __const__ volatile unsigned long *addr)
83{
84 return (1UL & ((addr)[nr >> 6] >> (nr & 63))) != 0UL;
85}
86
87/* The easy/cheese version for now. */
88static __inline__ unsigned long ffz(unsigned long word)
89{
90 unsigned long result;
91
92 result = 0;
93 while(word & 1) {
94 result++;
95 word >>= 1;
96 }
97 return result;
98}
99
100/**
101 * __ffs - find first bit in word.
102 * @word: The word to search
103 *
104 * Undefined if no bit exists, so code should check against 0 first.
105 */
106static __inline__ unsigned long __ffs(unsigned long word)
107{
108 unsigned long result = 0;
109
110 while (!(word & 1UL)) {
111 result++;
112 word >>= 1;
113 }
114 return result;
115}
116
117/*
118 * fls: find last bit set.
119 */
120
121#define fls(x) generic_fls(x)
122
123#ifdef __KERNEL__
124
125/*
126 * Every architecture must define this function. It's the fastest
127 * way of searching a 140-bit bitmap where the first 100 bits are
128 * unlikely to be set. It's guaranteed that at least one of the 140
129 * bits is cleared.
130 */
131static inline int sched_find_first_bit(unsigned long *b)
132{
133 if (unlikely(b[0]))
134 return __ffs(b[0]);
135 if (unlikely(((unsigned int)b[1])))
136 return __ffs(b[1]) + 64;
137 if (b[1] >> 32)
138 return __ffs(b[1] >> 32) + 96;
139 return __ffs(b[2]) + 128;
140}
141
142/*
143 * ffs: find first bit set. This is defined the same way as
144 * the libc and compiler builtin ffs routines, therefore
145 * differs in spirit from the above ffz (man ffs).
146 */
147static __inline__ int ffs(int x)
148{
149 if (!x)
150 return 0;
151 return __ffs((unsigned long)x) + 1;
152}
153
154/*
155 * hweightN: returns the hamming weight (i.e. the number
156 * of bits set) of a N-bit word
157 */
158
159#ifdef ULTRA_HAS_POPULATION_COUNT
160
161static __inline__ unsigned int hweight64(unsigned long w)
162{
163 unsigned int res;
164
165 __asm__ ("popc %1,%0" : "=r" (res) : "r" (w));
166 return res;
167}
168
169static __inline__ unsigned int hweight32(unsigned int w)
170{
171 unsigned int res;
172
173 __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffffffff));
174 return res;
175}
176
177static __inline__ unsigned int hweight16(unsigned int w)
178{
179 unsigned int res;
180
181 __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffff));
182 return res;
183}
184
185static __inline__ unsigned int hweight8(unsigned int w)
186{
187 unsigned int res;
188
189 __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xff));
190 return res;
191}
192
193#else
194
195#define hweight64(x) generic_hweight64(x)
196#define hweight32(x) generic_hweight32(x)
197#define hweight16(x) generic_hweight16(x)
198#define hweight8(x) generic_hweight8(x)
199
200#endif
201#endif /* __KERNEL__ */
202
203/**
204 * find_next_bit - find the next set bit in a memory region
205 * @addr: The address to base the search on
206 * @offset: The bitnumber to start searching at
207 * @size: The maximum size to search
208 */
209extern unsigned long find_next_bit(const unsigned long *, unsigned long,
210 unsigned long);
211
212/**
213 * find_first_bit - find the first set bit in a memory region
214 * @addr: The address to start the search at
215 * @size: The maximum size to search
216 *
217 * Returns the bit-number of the first set bit, not the number of the byte
218 * containing a bit.
219 */
220#define find_first_bit(addr, size) \
221 find_next_bit((addr), (size), 0)
222
223/* find_next_zero_bit() finds the first zero bit in a bit string of length
224 * 'size' bits, starting the search at bit 'offset'. This is largely based
225 * on Linus's ALPHA routines, which are pretty portable BTW.
226 */
227
228extern unsigned long find_next_zero_bit(const unsigned long *,
229 unsigned long, unsigned long);
230
231#define find_first_zero_bit(addr, size) \
232 find_next_zero_bit((addr), (size), 0)
233
234#define test_and_set_le_bit(nr,addr) \
235 test_and_set_bit((nr) ^ 0x38, (addr))
236#define test_and_clear_le_bit(nr,addr) \
237 test_and_clear_bit((nr) ^ 0x38, (addr))
238
239static __inline__ int test_le_bit(int nr, __const__ unsigned long * addr)
240{
241 int mask;
242 __const__ unsigned char *ADDR = (__const__ unsigned char *) addr;
243
244 ADDR += nr >> 3;
245 mask = 1 << (nr & 0x07);
246 return ((mask & *ADDR) != 0);
247}
248
249#define find_first_zero_le_bit(addr, size) \
250 find_next_zero_le_bit((addr), (size), 0)
251
252extern unsigned long find_next_zero_le_bit(unsigned long *, unsigned long, unsigned long);
253
254#ifdef __KERNEL__
255
256#define __set_le_bit(nr, addr) \
257 __set_bit((nr) ^ 0x38, (addr))
258#define __clear_le_bit(nr, addr) \
259 __clear_bit((nr) ^ 0x38, (addr))
260#define __test_and_clear_le_bit(nr, addr) \
261 __test_and_clear_bit((nr) ^ 0x38, (addr))
262#define __test_and_set_le_bit(nr, addr) \
263 __test_and_set_bit((nr) ^ 0x38, (addr))
264
265#define ext2_set_bit(nr,addr) \
266 __test_and_set_le_bit((nr),(unsigned long *)(addr))
267#define ext2_set_bit_atomic(lock,nr,addr) \
268 test_and_set_le_bit((nr),(unsigned long *)(addr))
269#define ext2_clear_bit(nr,addr) \
270 __test_and_clear_le_bit((nr),(unsigned long *)(addr))
271#define ext2_clear_bit_atomic(lock,nr,addr) \
272 test_and_clear_le_bit((nr),(unsigned long *)(addr))
273#define ext2_test_bit(nr,addr) \
274 test_le_bit((nr),(unsigned long *)(addr))
275#define ext2_find_first_zero_bit(addr, size) \
276 find_first_zero_le_bit((unsigned long *)(addr), (size))
277#define ext2_find_next_zero_bit(addr, size, off) \
278 find_next_zero_le_bit((unsigned long *)(addr), (size), (off))
279
280/* Bitmap functions for the minix filesystem. */
281#define minix_test_and_set_bit(nr,addr) \
282 test_and_set_bit((nr),(unsigned long *)(addr))
283#define minix_set_bit(nr,addr) \
284 set_bit((nr),(unsigned long *)(addr))
285#define minix_test_and_clear_bit(nr,addr) \
286 test_and_clear_bit((nr),(unsigned long *)(addr))
287#define minix_test_bit(nr,addr) \
288 test_bit((nr),(unsigned long *)(addr))
289#define minix_find_first_zero_bit(addr,size) \
290 find_first_zero_bit((unsigned long *)(addr),(size))
291
292#endif /* __KERNEL__ */
293
294#endif /* defined(_SPARC64_BITOPS_H) */
diff --git a/include/asm-sparc64/bpp.h b/include/asm-sparc64/bpp.h
new file mode 100644
index 000000000000..abe163a50382
--- /dev/null
+++ b/include/asm-sparc64/bpp.h
@@ -0,0 +1,73 @@
1#ifndef _SPARC64_BPP_H
2#define _SPARC64_BPP_H
3
4/*
5 * Copyright (c) 1995 Picture Elements
6 * Stephen Williams
7 * Gus Baldauf
8 *
9 * Linux/SPARC port by Peter Zaitcev.
10 * Integration into SPARC tree by Tom Dyas.
11 */
12
13#include <linux/ioctl.h>
14
15/*
16 * This is a driver that supports IEEE Std 1284-1994 communications
17 * with compliant or compatible devices. It will use whatever features
18 * the device supports, prefering those that are typically faster.
19 *
20 * When the device is opened, it is left in COMPATIBILITY mode, and
21 * writes work like any printer device. The driver only attempt to
22 * negotiate 1284 modes when needed so that plugs can be pulled,
23 * switch boxes switched, etc., without disrupting things. It will
24 * also leave the device in compatibility mode when closed.
25 */
26
27
28
29/*
30 * This driver also supplies ioctls to manually manipulate the
31 * pins. This is great for testing devices, or writing code to deal
32 * with bizzarro-mode of the ACME Special TurboThingy Plus.
33 *
34 * NOTE: These ioctl currently do not interact well with
35 * read/write. Caveat emptor.
36 *
37 * PUT_PINS allows us to assign the sense of all the pins, including
38 * the data pins if being driven by the host. The GET_PINS returns the
39 * pins that the peripheral drives, including data if appropriate.
40 */
41
42# define BPP_PUT_PINS _IOW('B', 1, int)
43# define BPP_GET_PINS _IOR('B', 2, char) /* that's bogus - should've been _IO */
44# define BPP_PUT_DATA _IOW('B', 3, int)
45# define BPP_GET_DATA _IOR('B', 4, char) /* ditto */
46
47/*
48 * Set the data bus to input mode. Disengage the data bin driver and
49 * be prepared to read values from the peripheral. If the arg is 0,
50 * then revert the bus to output mode.
51 */
52# define BPP_SET_INPUT _IOW('B', 5, int)
53
54/*
55 * These bits apply to the PUT operation...
56 */
57# define BPP_PP_nStrobe 0x0001
58# define BPP_PP_nAutoFd 0x0002
59# define BPP_PP_nInit 0x0004
60# define BPP_PP_nSelectIn 0x0008
61
62/*
63 * These apply to the GET operation, which also reads the current value
64 * of the previously put values. A bit mask of these will be returned
65 * as a bit mask in the return code of the ioctl().
66 */
67# define BPP_GP_nAck 0x0100
68# define BPP_GP_Busy 0x0200
69# define BPP_GP_PError 0x0400
70# define BPP_GP_Select 0x0800
71# define BPP_GP_nFault 0x1000
72
73#endif
diff --git a/include/asm-sparc64/bsderrno.h b/include/asm-sparc64/bsderrno.h
new file mode 100644
index 000000000000..52fe880d2af8
--- /dev/null
+++ b/include/asm-sparc64/bsderrno.h
@@ -0,0 +1,94 @@
1/* $Id: bsderrno.h,v 1.1 1996/12/26 13:25:21 davem Exp $
2 * bsderrno.h: Error numbers for NetBSD binary compatibility
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_BSDERRNO_H
8#define _SPARC64_BSDERRNO_H
9
10#define BSD_EPERM 1 /* Operation not permitted */
11#define BSD_ENOENT 2 /* No such file or directory */
12#define BSD_ESRCH 3 /* No such process */
13#define BSD_EINTR 4 /* Interrupted system call */
14#define BSD_EIO 5 /* Input/output error */
15#define BSD_ENXIO 6 /* Device not configured */
16#define BSD_E2BIG 7 /* Argument list too long */
17#define BSD_ENOEXEC 8 /* Exec format error */
18#define BSD_EBADF 9 /* Bad file descriptor */
19#define BSD_ECHILD 10 /* No child processes */
20#define BSD_EDEADLK 11 /* Resource deadlock avoided */
21#define BSD_ENOMEM 12 /* Cannot allocate memory */
22#define BSD_EACCES 13 /* Permission denied */
23#define BSD_EFAULT 14 /* Bad address */
24#define BSD_ENOTBLK 15 /* Block device required */
25#define BSD_EBUSY 16 /* Device busy */
26#define BSD_EEXIST 17 /* File exists */
27#define BSD_EXDEV 18 /* Cross-device link */
28#define BSD_ENODEV 19 /* Operation not supported by device */
29#define BSD_ENOTDIR 20 /* Not a directory */
30#define BSD_EISDIR 21 /* Is a directory */
31#define BSD_EINVAL 22 /* Invalid argument */
32#define BSD_ENFILE 23 /* Too many open files in system */
33#define BSD_EMFILE 24 /* Too many open files */
34#define BSD_ENOTTY 25 /* Inappropriate ioctl for device */
35#define BSD_ETXTBSY 26 /* Text file busy */
36#define BSD_EFBIG 27 /* File too large */
37#define BSD_ENOSPC 28 /* No space left on device */
38#define BSD_ESPIPE 29 /* Illegal seek */
39#define BSD_EROFS 30 /* Read-only file system */
40#define BSD_EMLINK 31 /* Too many links */
41#define BSD_EPIPE 32 /* Broken pipe */
42#define BSD_EDOM 33 /* Numerical argument out of domain */
43#define BSD_ERANGE 34 /* Result too large */
44#define BSD_EAGAIN 35 /* Resource temporarily unavailable */
45#define BSD_EWOULDBLOCK EAGAIN /* Operation would block */
46#define BSD_EINPROGRESS 36 /* Operation now in progress */
47#define BSD_EALREADY 37 /* Operation already in progress */
48#define BSD_ENOTSOCK 38 /* Socket operation on non-socket */
49#define BSD_EDESTADDRREQ 39 /* Destination address required */
50#define BSD_EMSGSIZE 40 /* Message too long */
51#define BSD_EPROTOTYPE 41 /* Protocol wrong type for socket */
52#define BSD_ENOPROTOOPT 42 /* Protocol not available */
53#define BSD_EPROTONOSUPPORT 43 /* Protocol not supported */
54#define BSD_ESOCKTNOSUPPORT 44 /* Socket type not supported */
55#define BSD_EOPNOTSUPP 45 /* Operation not supported */
56#define BSD_EPFNOSUPPORT 46 /* Protocol family not supported */
57#define BSD_EAFNOSUPPORT 47 /* Address family not supported by protocol family */
58#define BSD_EADDRINUSE 48 /* Address already in use */
59#define BSD_EADDRNOTAVAIL 49 /* Can't assign requested address */
60#define BSD_ENETDOWN 50 /* Network is down */
61#define BSD_ENETUNREACH 51 /* Network is unreachable */
62#define BSD_ENETRESET 52 /* Network dropped connection on reset */
63#define BSD_ECONNABORTED 53 /* Software caused connection abort */
64#define BSD_ECONNRESET 54 /* Connection reset by peer */
65#define BSD_ENOBUFS 55 /* No buffer space available */
66#define BSD_EISCONN 56 /* Socket is already connected */
67#define BSD_ENOTCONN 57 /* Socket is not connected */
68#define BSD_ESHUTDOWN 58 /* Can't send after socket shutdown */
69#define BSD_ETOOMANYREFS 59 /* Too many references: can't splice */
70#define BSD_ETIMEDOUT 60 /* Operation timed out */
71#define BSD_ECONNREFUSED 61 /* Connection refused */
72#define BSD_ELOOP 62 /* Too many levels of symbolic links */
73#define BSD_ENAMETOOLONG 63 /* File name too long */
74#define BSD_EHOSTDOWN 64 /* Host is down */
75#define BSD_EHOSTUNREACH 65 /* No route to host */
76#define BSD_ENOTEMPTY 66 /* Directory not empty */
77#define BSD_EPROCLIM 67 /* Too many processes */
78#define BSD_EUSERS 68 /* Too many users */
79#define BSD_EDQUOT 69 /* Disc quota exceeded */
80#define BSD_ESTALE 70 /* Stale NFS file handle */
81#define BSD_EREMOTE 71 /* Too many levels of remote in path */
82#define BSD_EBADRPC 72 /* RPC struct is bad */
83#define BSD_ERPCMISMATCH 73 /* RPC version wrong */
84#define BSD_EPROGUNAVAIL 74 /* RPC prog. not avail */
85#define BSD_EPROGMISMATCH 75 /* Program version wrong */
86#define BSD_EPROCUNAVAIL 76 /* Bad procedure for program */
87#define BSD_ENOLCK 77 /* No locks available */
88#define BSD_ENOSYS 78 /* Function not implemented */
89#define BSD_EFTYPE 79 /* Inappropriate file type or format */
90#define BSD_EAUTH 80 /* Authentication error */
91#define BSD_ENEEDAUTH 81 /* Need authenticator */
92#define BSD_ELAST 81 /* Must be equal largest errno */
93
94#endif /* !(_SPARC64_BSDERRNO_H) */
diff --git a/include/asm-sparc64/bug.h b/include/asm-sparc64/bug.h
new file mode 100644
index 000000000000..25c5b1dfe378
--- /dev/null
+++ b/include/asm-sparc64/bug.h
@@ -0,0 +1,19 @@
1#ifndef _SPARC64_BUG_H
2#define _SPARC64_BUG_H
3
4#include <linux/compiler.h>
5
6#ifdef CONFIG_DEBUG_BUGVERBOSE
7extern void do_BUG(const char *file, int line);
8#define BUG() do { \
9 do_BUG(__FILE__, __LINE__); \
10 __builtin_trap(); \
11} while (0)
12#else
13#define BUG() __builtin_trap()
14#endif
15
16#define HAVE_ARCH_BUG
17#include <asm-generic/bug.h>
18
19#endif
diff --git a/include/asm-sparc64/bugs.h b/include/asm-sparc64/bugs.h
new file mode 100644
index 000000000000..360dd04ed8e4
--- /dev/null
+++ b/include/asm-sparc64/bugs.h
@@ -0,0 +1,16 @@
1/* $Id: bugs.h,v 1.1 1996/12/26 13:25:20 davem Exp $
2 * include/asm-sparc64/bugs.h: Sparc probes for various bugs.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#include <linux/config.h>
8
9extern unsigned long loops_per_jiffy;
10
11static void __init check_bugs(void)
12{
13#ifndef CONFIG_SMP
14 cpu_data(0).udelay_val = loops_per_jiffy;
15#endif
16}
diff --git a/include/asm-sparc64/byteorder.h b/include/asm-sparc64/byteorder.h
new file mode 100644
index 000000000000..c69b08af5fe0
--- /dev/null
+++ b/include/asm-sparc64/byteorder.h
@@ -0,0 +1,50 @@
1/* $Id: byteorder.h,v 1.8 1997/12/18 02:44:14 ecd Exp $ */
2#ifndef _SPARC64_BYTEORDER_H
3#define _SPARC64_BYTEORDER_H
4
5#include <asm/types.h>
6#include <asm/asi.h>
7
8#ifdef __GNUC__
9
10static __inline__ __u16 ___arch__swab16p(const __u16 *addr)
11{
12 __u16 ret;
13
14 __asm__ __volatile__ ("lduha [%1] %2, %0"
15 : "=r" (ret)
16 : "r" (addr), "i" (ASI_PL));
17 return ret;
18}
19
20static __inline__ __u32 ___arch__swab32p(const __u32 *addr)
21{
22 __u32 ret;
23
24 __asm__ __volatile__ ("lduwa [%1] %2, %0"
25 : "=r" (ret)
26 : "r" (addr), "i" (ASI_PL));
27 return ret;
28}
29
30static __inline__ __u64 ___arch__swab64p(const __u64 *addr)
31{
32 __u64 ret;
33
34 __asm__ __volatile__ ("ldxa [%1] %2, %0"
35 : "=r" (ret)
36 : "r" (addr), "i" (ASI_PL));
37 return ret;
38}
39
40#define __arch__swab16p(x) ___arch__swab16p(x)
41#define __arch__swab32p(x) ___arch__swab32p(x)
42#define __arch__swab64p(x) ___arch__swab64p(x)
43
44#define __BYTEORDER_HAS_U64__
45
46#endif /* __GNUC__ */
47
48#include <linux/byteorder/big_endian.h>
49
50#endif /* _SPARC64_BYTEORDER_H */
diff --git a/include/asm-sparc64/cache.h b/include/asm-sparc64/cache.h
new file mode 100644
index 000000000000..ade5ec3bfd5a
--- /dev/null
+++ b/include/asm-sparc64/cache.h
@@ -0,0 +1,17 @@
1/*
2 * include/asm-sparc64/cache.h
3 */
4#ifndef __ARCH_SPARC64_CACHE_H
5#define __ARCH_SPARC64_CACHE_H
6
7/* bytes per L1 cache line */
8#define L1_CACHE_SHIFT 5
9#define L1_CACHE_BYTES 32 /* Two 16-byte sub-blocks per line. */
10
11#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
12#define L1_CACHE_SHIFT_MAX 5 /* largest L1 which this arch supports */
13
14#define SMP_CACHE_BYTES_SHIFT 6
15#define SMP_CACHE_BYTES (1 << SMP_CACHE_BYTES_SHIFT) /* L2 cache line size. */
16
17#endif
diff --git a/include/asm-sparc64/cacheflush.h b/include/asm-sparc64/cacheflush.h
new file mode 100644
index 000000000000..86f02937ff1b
--- /dev/null
+++ b/include/asm-sparc64/cacheflush.h
@@ -0,0 +1,72 @@
1#ifndef _SPARC64_CACHEFLUSH_H
2#define _SPARC64_CACHEFLUSH_H
3
4#include <linux/config.h>
5#include <asm/page.h>
6
7/* Flushing for D-cache alias handling is only needed if
8 * the page size is smaller than 16K.
9 */
10#if PAGE_SHIFT < 14
11#define DCACHE_ALIASING_POSSIBLE
12#endif
13
14#ifndef __ASSEMBLY__
15
16#include <linux/mm.h>
17
18/* Cache flush operations. */
19
20/* These are the same regardless of whether this is an SMP kernel or not. */
21#define flush_cache_mm(__mm) \
22 do { if ((__mm) == current->mm) flushw_user(); } while(0)
23#define flush_cache_range(vma, start, end) \
24 flush_cache_mm((vma)->vm_mm)
25#define flush_cache_page(vma, page, pfn) \
26 flush_cache_mm((vma)->vm_mm)
27
28/*
29 * On spitfire, the icache doesn't snoop local stores and we don't
30 * use block commit stores (which invalidate icache lines) during
31 * module load, so we need this.
32 */
33extern void flush_icache_range(unsigned long start, unsigned long end);
34extern void __flush_icache_page(unsigned long);
35
36extern void __flush_dcache_page(void *addr, int flush_icache);
37extern void flush_dcache_page_impl(struct page *page);
38#ifdef CONFIG_SMP
39extern void smp_flush_dcache_page_impl(struct page *page, int cpu);
40extern void flush_dcache_page_all(struct mm_struct *mm, struct page *page);
41#else
42#define smp_flush_dcache_page_impl(page,cpu) flush_dcache_page_impl(page)
43#define flush_dcache_page_all(mm,page) flush_dcache_page_impl(page)
44#endif
45
46extern void __flush_dcache_range(unsigned long start, unsigned long end);
47extern void flush_dcache_page(struct page *page);
48
49#define flush_icache_page(vma, pg) do { } while(0)
50#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
51
52#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
53 do { \
54 flush_cache_page(vma, vaddr, page_to_pfn(page));\
55 memcpy(dst, src, len); \
56 } while (0)
57
58#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
59 do { \
60 flush_cache_page(vma, vaddr, page_to_pfn(page));\
61 memcpy(dst, src, len); \
62 } while (0)
63
64#define flush_dcache_mmap_lock(mapping) do { } while (0)
65#define flush_dcache_mmap_unlock(mapping) do { } while (0)
66
67#define flush_cache_vmap(start, end) do { } while (0)
68#define flush_cache_vunmap(start, end) do { } while (0)
69
70#endif /* !__ASSEMBLY__ */
71
72#endif /* _SPARC64_CACHEFLUSH_H */
diff --git a/include/asm-sparc64/chafsr.h b/include/asm-sparc64/chafsr.h
new file mode 100644
index 000000000000..fd1688335ace
--- /dev/null
+++ b/include/asm-sparc64/chafsr.h
@@ -0,0 +1,242 @@
1/* $Id: chafsr.h,v 1.1 2001/03/28 10:56:34 davem Exp $ */
2#ifndef _SPARC64_CHAFSR_H
3#define _SPARC64_CHAFSR_H
4
5/* Cheetah Asynchronous Fault Status register, ASI=0x4C VA<63:0>=0x0 */
6
7/* Comments indicate which processor variants on which the bit definition
8 * is valid. Codes are:
9 * ch --> cheetah
10 * ch+ --> cheetah plus
11 * jp --> jalapeno
12 */
13
14/* All bits of this register except M_SYNDROME and E_SYNDROME are
15 * read, write 1 to clear. M_SYNDROME and E_SYNDROME are read-only.
16 */
17
18/* Software bit set by linux trap handlers to indicate that the trap was
19 * signalled at %tl >= 1.
20 */
21#define CHAFSR_TL1 (1UL << 63UL) /* n/a */
22
23/* Unmapped error from system bus for prefetch queue or
24 * store queue read operation
25 */
26#define CHPAFSR_DTO (1UL << 59UL) /* ch+ */
27
28/* Bus error from system bus for prefetch queue or store queue
29 * read operation
30 */
31#define CHPAFSR_DBERR (1UL << 58UL) /* ch+ */
32
33/* Hardware corrected E-cache Tag ECC error */
34#define CHPAFSR_THCE (1UL << 57UL) /* ch+ */
35/* System interface protocol error, hw timeout caused */
36#define JPAFSR_JETO (1UL << 57UL) /* jp */
37
38/* SW handled correctable E-cache Tag ECC error */
39#define CHPAFSR_TSCE (1UL << 56UL) /* ch+ */
40/* Parity error on system snoop results */
41#define JPAFSR_SCE (1UL << 56UL) /* jp */
42
43/* Uncorrectable E-cache Tag ECC error */
44#define CHPAFSR_TUE (1UL << 55UL) /* ch+ */
45/* System interface protocol error, illegal command detected */
46#define JPAFSR_JEIC (1UL << 55UL) /* jp */
47
48/* Uncorrectable system bus data ECC error due to prefetch
49 * or store fill request
50 */
51#define CHPAFSR_DUE (1UL << 54UL) /* ch+ */
52/* System interface protocol error, illegal ADTYPE detected */
53#define JPAFSR_JEIT (1UL << 54UL) /* jp */
54
55/* Multiple errors of the same type have occurred. This bit is set when
56 * an uncorrectable error or a SW correctable error occurs and the status
57 * bit to report that error is already set. When multiple errors of
58 * different types are indicated by setting multiple status bits.
59 *
60 * This bit is not set if multiple HW corrected errors with the same
61 * status bit occur, only uncorrectable and SW correctable ones have
62 * this behavior.
63 *
64 * This bit is not set when multiple ECC errors happen within a single
65 * 64-byte system bus transaction. Only the first ECC error in a 16-byte
66 * subunit will be logged. All errors in subsequent 16-byte subunits
67 * from the same 64-byte transaction are ignored.
68 */
69#define CHAFSR_ME (1UL << 53UL) /* ch,ch+,jp */
70
71/* Privileged state error has occurred. This is a capture of PSTATE.PRIV
72 * at the time the error is detected.
73 */
74#define CHAFSR_PRIV (1UL << 52UL) /* ch,ch+,jp */
75
76/* The following bits 51 (CHAFSR_PERR) to 33 (CHAFSR_CE) are sticky error
77 * bits and record the most recently detected errors. Bits accumulate
78 * errors that have been detected since the last write to clear the bit.
79 */
80
81/* System interface protocol error. The processor asserts its' ERROR
82 * pin when this event occurs and it also logs a specific cause code
83 * into a JTAG scannable flop.
84 */
85#define CHAFSR_PERR (1UL << 51UL) /* ch,ch+,jp */
86
87/* Internal processor error. The processor asserts its' ERROR
88 * pin when this event occurs and it also logs a specific cause code
89 * into a JTAG scannable flop.
90 */
91#define CHAFSR_IERR (1UL << 50UL) /* ch,ch+,jp */
92
93/* System request parity error on incoming address */
94#define CHAFSR_ISAP (1UL << 49UL) /* ch,ch+,jp */
95
96/* HW Corrected system bus MTAG ECC error */
97#define CHAFSR_EMC (1UL << 48UL) /* ch,ch+ */
98/* Parity error on L2 cache tag SRAM */
99#define JPAFSR_ETP (1UL << 48UL) /* jp */
100
101/* Uncorrectable system bus MTAG ECC error */
102#define CHAFSR_EMU (1UL << 47UL) /* ch,ch+ */
103/* Out of range memory error has occurred */
104#define JPAFSR_OM (1UL << 47UL) /* jp */
105
106/* HW Corrected system bus data ECC error for read of interrupt vector */
107#define CHAFSR_IVC (1UL << 46UL) /* ch,ch+ */
108/* Error due to unsupported store */
109#define JPAFSR_UMS (1UL << 46UL) /* jp */
110
111/* Uncorrectable system bus data ECC error for read of interrupt vector */
112#define CHAFSR_IVU (1UL << 45UL) /* ch,ch+,jp */
113
114/* Unmapped error from system bus */
115#define CHAFSR_TO (1UL << 44UL) /* ch,ch+,jp */
116
117/* Bus error response from system bus */
118#define CHAFSR_BERR (1UL << 43UL) /* ch,ch+,jp */
119
120/* SW Correctable E-cache ECC error for instruction fetch or data access
121 * other than block load.
122 */
123#define CHAFSR_UCC (1UL << 42UL) /* ch,ch+,jp */
124
125/* Uncorrectable E-cache ECC error for instruction fetch or data access
126 * other than block load.
127 */
128#define CHAFSR_UCU (1UL << 41UL) /* ch,ch+,jp */
129
130/* Copyout HW Corrected ECC error */
131#define CHAFSR_CPC (1UL << 40UL) /* ch,ch+,jp */
132
133/* Copyout Uncorrectable ECC error */
134#define CHAFSR_CPU (1UL << 39UL) /* ch,ch+,jp */
135
136/* HW Corrected ECC error from E-cache for writeback */
137#define CHAFSR_WDC (1UL << 38UL) /* ch,ch+,jp */
138
139/* Uncorrectable ECC error from E-cache for writeback */
140#define CHAFSR_WDU (1UL << 37UL) /* ch,ch+,jp */
141
142/* HW Corrected ECC error from E-cache for store merge or block load */
143#define CHAFSR_EDC (1UL << 36UL) /* ch,ch+,jp */
144
145/* Uncorrectable ECC error from E-cache for store merge or block load */
146#define CHAFSR_EDU (1UL << 35UL) /* ch,ch+,jp */
147
148/* Uncorrectable system bus data ECC error for read of memory or I/O */
149#define CHAFSR_UE (1UL << 34UL) /* ch,ch+,jp */
150
151/* HW Corrected system bus data ECC error for read of memory or I/O */
152#define CHAFSR_CE (1UL << 33UL) /* ch,ch+,jp */
153
154/* Uncorrectable ECC error from remote cache/memory */
155#define JPAFSR_RUE (1UL << 32UL) /* jp */
156
157/* Correctable ECC error from remote cache/memory */
158#define JPAFSR_RCE (1UL << 31UL) /* jp */
159
160/* JBUS parity error on returned read data */
161#define JPAFSR_BP (1UL << 30UL) /* jp */
162
163/* JBUS parity error on data for writeback or block store */
164#define JPAFSR_WBP (1UL << 29UL) /* jp */
165
166/* Foreign read to DRAM incurring correctable ECC error */
167#define JPAFSR_FRC (1UL << 28UL) /* jp */
168
169/* Foreign read to DRAM incurring uncorrectable ECC error */
170#define JPAFSR_FRU (1UL << 27UL) /* jp */
171
172#define CHAFSR_ERRORS (CHAFSR_PERR | CHAFSR_IERR | CHAFSR_ISAP | CHAFSR_EMC | \
173 CHAFSR_EMU | CHAFSR_IVC | CHAFSR_IVU | CHAFSR_TO | \
174 CHAFSR_BERR | CHAFSR_UCC | CHAFSR_UCU | CHAFSR_CPC | \
175 CHAFSR_CPU | CHAFSR_WDC | CHAFSR_WDU | CHAFSR_EDC | \
176 CHAFSR_EDU | CHAFSR_UE | CHAFSR_CE)
177#define CHPAFSR_ERRORS (CHPAFSR_DTO | CHPAFSR_DBERR | CHPAFSR_THCE | \
178 CHPAFSR_TSCE | CHPAFSR_TUE | CHPAFSR_DUE | \
179 CHAFSR_PERR | CHAFSR_IERR | CHAFSR_ISAP | CHAFSR_EMC | \
180 CHAFSR_EMU | CHAFSR_IVC | CHAFSR_IVU | CHAFSR_TO | \
181 CHAFSR_BERR | CHAFSR_UCC | CHAFSR_UCU | CHAFSR_CPC | \
182 CHAFSR_CPU | CHAFSR_WDC | CHAFSR_WDU | CHAFSR_EDC | \
183 CHAFSR_EDU | CHAFSR_UE | CHAFSR_CE)
184#define JPAFSR_ERRORS (JPAFSR_JETO | JPAFSR_SCE | JPAFSR_JEIC | \
185 JPAFSR_JEIT | CHAFSR_PERR | CHAFSR_IERR | \
186 CHAFSR_ISAP | JPAFSR_ETP | JPAFSR_OM | \
187 JPAFSR_UMS | CHAFSR_IVU | CHAFSR_TO | \
188 CHAFSR_BERR | CHAFSR_UCC | CHAFSR_UCU | \
189 CHAFSR_CPC | CHAFSR_CPU | CHAFSR_WDC | \
190 CHAFSR_WDU | CHAFSR_EDC | CHAFSR_EDU | \
191 CHAFSR_UE | CHAFSR_CE | JPAFSR_RUE | \
192 JPAFSR_RCE | JPAFSR_BP | JPAFSR_WBP | \
193 JPAFSR_FRC | JPAFSR_FRU)
194
195/* Active JBUS request signal when error occurred */
196#define JPAFSR_JBREQ (0x7UL << 24UL) /* jp */
197#define JPAFSR_JBREQ_SHIFT 24UL
198
199/* L2 cache way information */
200#define JPAFSR_ETW (0x3UL << 22UL) /* jp */
201#define JPAFSR_ETW_SHIFT 22UL
202
203/* System bus MTAG ECC syndrome. This field captures the status of the
204 * first occurrence of the highest-priority error according to the M_SYND
205 * overwrite policy. After the AFSR sticky bit, corresponding to the error
206 * for which the M_SYND is reported, is cleared, the contents of the M_SYND
207 * field will be unchanged by will be unfrozen for further error capture.
208 */
209#define CHAFSR_M_SYNDROME (0xfUL << 16UL) /* ch,ch+,jp */
210#define CHAFSR_M_SYNDROME_SHIFT 16UL
211
212/* Agenid Id of the foreign device causing the UE/CE errors */
213#define JPAFSR_AID (0x1fUL << 9UL) /* jp */
214#define JPAFSR_AID_SHIFT 9UL
215
216/* System bus or E-cache data ECC syndrome. This field captures the status
217 * of the first occurrence of the highest-priority error according to the
218 * E_SYND overwrite policy. After the AFSR sticky bit, corresponding to the
219 * error for which the E_SYND is reported, is cleare, the contents of the E_SYND
220 * field will be unchanged but will be unfrozen for further error capture.
221 */
222#define CHAFSR_E_SYNDROME (0x1ffUL << 0UL) /* ch,ch+,jp */
223#define CHAFSR_E_SYNDROME_SHIFT 0UL
224
225/* The AFSR must be explicitly cleared by software, it is not cleared automatically
226 * by a read. Writes to bits <51:33> with bits set will clear the corresponding
227 * bits in the AFSR. Bits associated with disrupting traps must be cleared before
228 * interrupts are re-enabled to prevent multiple traps for the same error. I.e.
229 * PSTATE.IE and AFSR bits control delivery of disrupting traps.
230 *
231 * Since there is only one AFAR, when multiple events have been logged by the
232 * bits in the AFSR, at most one of these events will have its status captured
233 * in the AFAR. The highest priority of those event bits will get AFAR logging.
234 * The AFAR will be unlocked and available to capture the address of another event
235 * as soon as the one bit in AFSR that corresponds to the event logged in AFAR is
236 * cleared. For example, if AFSR.CE is detected, then AFSR.UE (which overwrites
237 * the AFAR), and AFSR.UE is cleared by not AFSR.CE, then the AFAR will be unlocked
238 * and ready for another event, even though AFSR.CE is still set. The same rules
239 * also apply to the M_SYNDROME and E_SYNDROME fields of the AFSR.
240 */
241
242#endif /* _SPARC64_CHAFSR_H */
diff --git a/include/asm-sparc64/checksum.h b/include/asm-sparc64/checksum.h
new file mode 100644
index 000000000000..dc8bed246fc9
--- /dev/null
+++ b/include/asm-sparc64/checksum.h
@@ -0,0 +1,173 @@
1/* $Id: checksum.h,v 1.19 2002/02/09 19:49:31 davem Exp $ */
2#ifndef __SPARC64_CHECKSUM_H
3#define __SPARC64_CHECKSUM_H
4
5/* checksum.h: IP/UDP/TCP checksum routines on the V9.
6 *
7 * Copyright(C) 1995 Linus Torvalds
8 * Copyright(C) 1995 Miguel de Icaza
9 * Copyright(C) 1996 David S. Miller
10 * Copyright(C) 1996 Eddie C. Dost
11 * Copyright(C) 1997 Jakub Jelinek
12 *
13 * derived from:
14 * Alpha checksum c-code
15 * ix86 inline assembly
16 * RFC1071 Computing the Internet Checksum
17 */
18
19#include <linux/in6.h>
20#include <asm/uaccess.h>
21
22/* computes the checksum of a memory block at buff, length len,
23 * and adds in "sum" (32-bit)
24 *
25 * returns a 32-bit number suitable for feeding into itself
26 * or csum_tcpudp_magic
27 *
28 * this function must be called with even lengths, except
29 * for the last fragment, which may be odd
30 *
31 * it's best to have buff aligned on a 32-bit boundary
32 */
33extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum);
34
35/* the same as csum_partial, but copies from user space while it
36 * checksums
37 *
38 * here even more important to align src and dst on a 32-bit (or even
39 * better 64-bit) boundary
40 */
41extern unsigned int csum_partial_copy_nocheck(const unsigned char *src,
42 unsigned char *dst,
43 int len, unsigned int sum);
44
45extern long __csum_partial_copy_from_user(const unsigned char __user *src,
46 unsigned char *dst, int len,
47 unsigned int sum);
48
49static inline unsigned int
50csum_partial_copy_from_user(const unsigned char __user *src,
51 unsigned char *dst, int len,
52 unsigned int sum, int *err)
53{
54 long ret = __csum_partial_copy_from_user(src, dst, len, sum);
55 if (ret < 0)
56 *err = -EFAULT;
57 return (unsigned int) ret;
58}
59
60/*
61 * Copy and checksum to user
62 */
63#define HAVE_CSUM_COPY_USER
64extern long __csum_partial_copy_to_user(const unsigned char *src,
65 unsigned char __user *dst, int len,
66 unsigned int sum);
67
68static inline unsigned int
69csum_and_copy_to_user(const unsigned char *src,
70 unsigned char __user *dst, int len,
71 unsigned int sum, int *err)
72{
73 long ret = __csum_partial_copy_to_user(src, dst, len, sum);
74 if (ret < 0)
75 *err = -EFAULT;
76 return (unsigned int) ret;
77}
78
79/* ihl is always 5 or greater, almost always is 5, and iph is word aligned
80 * the majority of the time.
81 */
82extern unsigned short ip_fast_csum(__const__ unsigned char *iph,
83 unsigned int ihl);
84
85/* Fold a partial checksum without adding pseudo headers. */
86static inline unsigned short csum_fold(unsigned int sum)
87{
88 unsigned int tmp;
89
90 __asm__ __volatile__(
91" addcc %0, %1, %1\n"
92" srl %1, 16, %1\n"
93" addc %1, %%g0, %1\n"
94" xnor %%g0, %1, %0\n"
95 : "=&r" (sum), "=r" (tmp)
96 : "0" (sum), "1" (sum<<16)
97 : "cc");
98 return (sum & 0xffff);
99}
100
101static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
102 unsigned long daddr,
103 unsigned int len,
104 unsigned short proto,
105 unsigned int sum)
106{
107 __asm__ __volatile__(
108" addcc %1, %0, %0\n"
109" addccc %2, %0, %0\n"
110" addccc %3, %0, %0\n"
111" addc %0, %%g0, %0\n"
112 : "=r" (sum), "=r" (saddr)
113 : "r" (daddr), "r" ((proto<<16)+len), "0" (sum), "1" (saddr)
114 : "cc");
115 return sum;
116}
117
118/*
119 * computes the checksum of the TCP/UDP pseudo-header
120 * returns a 16-bit checksum, already complemented
121 */
122static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
123 unsigned long daddr,
124 unsigned short len,
125 unsigned short proto,
126 unsigned int sum)
127{
128 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
129}
130
131#define _HAVE_ARCH_IPV6_CSUM
132
133static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
134 struct in6_addr *daddr,
135 __u32 len,
136 unsigned short proto,
137 unsigned int sum)
138{
139 __asm__ __volatile__ (
140" addcc %3, %4, %%g7\n"
141" addccc %5, %%g7, %%g7\n"
142" lduw [%2 + 0x0c], %%g2\n"
143" lduw [%2 + 0x08], %%g3\n"
144" addccc %%g2, %%g7, %%g7\n"
145" lduw [%2 + 0x04], %%g2\n"
146" addccc %%g3, %%g7, %%g7\n"
147" lduw [%2 + 0x00], %%g3\n"
148" addccc %%g2, %%g7, %%g7\n"
149" lduw [%1 + 0x0c], %%g2\n"
150" addccc %%g3, %%g7, %%g7\n"
151" lduw [%1 + 0x08], %%g3\n"
152" addccc %%g2, %%g7, %%g7\n"
153" lduw [%1 + 0x04], %%g2\n"
154" addccc %%g3, %%g7, %%g7\n"
155" lduw [%1 + 0x00], %%g3\n"
156" addccc %%g2, %%g7, %%g7\n"
157" addccc %%g3, %%g7, %0\n"
158" addc 0, %0, %0\n"
159 : "=&r" (sum)
160 : "r" (saddr), "r" (daddr), "r"(htonl(len)),
161 "r"(htonl(proto)), "r"(sum)
162 : "g2", "g3", "g7", "cc");
163
164 return csum_fold(sum);
165}
166
167/* this routine is used for miscellaneous IP-like checksums, mainly in icmp.c */
168static inline unsigned short ip_compute_csum(unsigned char * buff, int len)
169{
170 return csum_fold(csum_partial(buff, len, 0));
171}
172
173#endif /* !(__SPARC64_CHECKSUM_H) */
diff --git a/include/asm-sparc64/chmctrl.h b/include/asm-sparc64/chmctrl.h
new file mode 100644
index 000000000000..53047f9f6423
--- /dev/null
+++ b/include/asm-sparc64/chmctrl.h
@@ -0,0 +1,184 @@
1/* $Id: chmctrl.h,v 1.1 2001/03/29 11:43:28 davem Exp $ */
2#ifndef _SPARC64_CHMCTRL_H
3#define _SPARC64_CHMCTRL_H
4
5/* Cheetah memory controller programmable registers. */
6#define CHMCTRL_TCTRL1 0x00 /* Memory Timing Control I */
7#define CHMCTRL_TCTRL2 0x08 /* Memory Timing Control II */
8#define CHMCTRL_TCTRL3 0x38 /* Memory Timing Control III */
9#define CHMCTRL_TCTRL4 0x40 /* Memory Timing Control IV */
10#define CHMCTRL_DECODE1 0x10 /* Memory Address Decode I */
11#define CHMCTRL_DECODE2 0x18 /* Memory Address Decode II */
12#define CHMCTRL_DECODE3 0x20 /* Memory Address Decode III */
13#define CHMCTRL_DECODE4 0x28 /* Memory Address Decode IV */
14#define CHMCTRL_MACTRL 0x30 /* Memory Address Control */
15
16/* Memory Timing Control I */
17#define TCTRL1_SDRAMCTL_DLY 0xf000000000000000UL
18#define TCTRL1_SDRAMCTL_DLY_SHIFT 60
19#define TCTRL1_SDRAMCLK_DLY 0x0e00000000000000UL
20#define TCTRL1_SDRAMCLK_DLY_SHIFT 57
21#define TCTRL1_R 0x0100000000000000UL
22#define TCTRL1_R_SHIFT 56
23#define TCTRL1_AUTORFR_CYCLE 0x00fe000000000000UL
24#define TCTRL1_AUTORFR_CYCLE_SHIFT 49
25#define TCTRL1_RD_WAIT 0x0001f00000000000UL
26#define TCTRL1_RD_WAIT_SHIFT 44
27#define TCTRL1_PC_CYCLE 0x00000fc000000000UL
28#define TCTRL1_PC_CYCLE_SHIFT 38
29#define TCTRL1_WR_MORE_RAS_PW 0x0000003f00000000UL
30#define TCTRL1_WR_MORE_RAS_PW_SHIFT 32
31#define TCTRL1_RD_MORE_RAW_PW 0x00000000fc000000UL
32#define TCTRL1_RD_MORE_RAS_PW_SHIFT 26
33#define TCTRL1_ACT_WR_DLY 0x0000000003f00000UL
34#define TCTRL1_ACT_WR_DLY_SHIFT 20
35#define TCTRL1_ACT_RD_DLY 0x00000000000fc000UL
36#define TCTRL1_ACT_RD_DLY_SHIFT 14
37#define TCTRL1_BANK_PRESENT 0x0000000000003000UL
38#define TCTRL1_BANK_PRESENT_SHIFT 12
39#define TCTRL1_RFR_INT 0x0000000000000ff8UL
40#define TCTRL1_RFR_INT_SHIFT 3
41#define TCTRL1_SET_MODE_REG 0x0000000000000004UL
42#define TCTRL1_SET_MODE_REG_SHIFT 2
43#define TCTRL1_RFR_ENABLE 0x0000000000000002UL
44#define TCTRL1_RFR_ENABLE_SHIFT 1
45#define TCTRL1_PRECHG_ALL 0x0000000000000001UL
46#define TCTRL1_PRECHG_ALL_SHIFT 0
47
48/* Memory Timing Control II */
49#define TCTRL2_WR_MSEL_DLY 0xfc00000000000000UL
50#define TCTRL2_WR_MSEL_DLY_SHIFT 58
51#define TCTRL2_RD_MSEL_DLY 0x03f0000000000000UL
52#define TCTRL2_RD_MSEL_DLY_SHIFT 52
53#define TCTRL2_WRDATA_THLD 0x000c000000000000UL
54#define TCTRL2_WRDATA_THLD_SHIFT 50
55#define TCTRL2_RDWR_RD_TI_DLY 0x0003f00000000000UL
56#define TCTRL2_RDWR_RD_TI_DLY_SHIFT 44
57#define TCTRL2_AUTOPRECHG_ENBL 0x0000080000000000UL
58#define TCTRL2_AUTOPRECHG_ENBL_SHIFT 43
59#define TCTRL2_RDWR_PI_MORE_DLY 0x000007c000000000UL
60#define TCTRL2_RDWR_PI_MORE_DLY_SHIFT 38
61#define TCTRL2_RDWR_1_DLY 0x0000003f00000000UL
62#define TCTRL2_RDWR_1_DLY_SHIFT 32
63#define TCTRL2_WRWR_PI_MORE_DLY 0x00000000f8000000UL
64#define TCTRL2_WRWR_PI_MORE_DLY_SHIFT 27
65#define TCTRL2_WRWR_1_DLY 0x0000000007e00000UL
66#define TCTRL2_WRWR_1_DLY_SHIFT 21
67#define TCTRL2_RDWR_RD_PI_MORE_DLY 0x00000000001f0000UL
68#define TCTRL2_RDWR_RD_PI_MORE_DLY_SHIFT 16
69#define TCTRL2_R 0x0000000000008000UL
70#define TCTRL2_R_SHIFT 15
71#define TCTRL2_SDRAM_MODE_REG_DATA 0x0000000000007fffUL
72#define TCTRL2_SDRAM_MODE_REG_DATA_SHIFT 0
73
74/* Memory Timing Control III */
75#define TCTRL3_SDRAM_CTL_DLY 0xf000000000000000UL
76#define TCTRL3_SDRAM_CTL_DLY_SHIFT 60
77#define TCTRL3_SDRAM_CLK_DLY 0x0e00000000000000UL
78#define TCTRL3_SDRAM_CLK_DLY_SHIFT 57
79#define TCTRL3_R 0x0100000000000000UL
80#define TCTRL3_R_SHIFT 56
81#define TCTRL3_AUTO_RFR_CYCLE 0x00fe000000000000UL
82#define TCTRL3_AUTO_RFR_CYCLE_SHIFT 49
83#define TCTRL3_RD_WAIT 0x0001f00000000000UL
84#define TCTRL3_RD_WAIT_SHIFT 44
85#define TCTRL3_PC_CYCLE 0x00000fc000000000UL
86#define TCTRL3_PC_CYCLE_SHIFT 38
87#define TCTRL3_WR_MORE_RAW_PW 0x0000003f00000000UL
88#define TCTRL3_WR_MORE_RAW_PW_SHIFT 32
89#define TCTRL3_RD_MORE_RAW_PW 0x00000000fc000000UL
90#define TCTRL3_RD_MORE_RAW_PW_SHIFT 26
91#define TCTRL3_ACT_WR_DLY 0x0000000003f00000UL
92#define TCTRL3_ACT_WR_DLY_SHIFT 20
93#define TCTRL3_ACT_RD_DLY 0x00000000000fc000UL
94#define TCTRL3_ACT_RD_DLY_SHIFT 14
95#define TCTRL3_BANK_PRESENT 0x0000000000003000UL
96#define TCTRL3_BANK_PRESENT_SHIFT 12
97#define TCTRL3_RFR_INT 0x0000000000000ff8UL
98#define TCTRL3_RFR_INT_SHIFT 3
99#define TCTRL3_SET_MODE_REG 0x0000000000000004UL
100#define TCTRL3_SET_MODE_REG_SHIFT 2
101#define TCTRL3_RFR_ENABLE 0x0000000000000002UL
102#define TCTRL3_RFR_ENABLE_SHIFT 1
103#define TCTRL3_PRECHG_ALL 0x0000000000000001UL
104#define TCTRL3_PRECHG_ALL_SHIFT 0
105
106/* Memory Timing Control IV */
107#define TCTRL4_WR_MSEL_DLY 0xfc00000000000000UL
108#define TCTRL4_WR_MSEL_DLY_SHIFT 58
109#define TCTRL4_RD_MSEL_DLY 0x03f0000000000000UL
110#define TCTRL4_RD_MSEL_DLY_SHIFT 52
111#define TCTRL4_WRDATA_THLD 0x000c000000000000UL
112#define TCTRL4_WRDATA_THLD_SHIFT 50
113#define TCTRL4_RDWR_RD_RI_DLY 0x0003f00000000000UL
114#define TCTRL4_RDWR_RD_RI_DLY_SHIFT 44
115#define TCTRL4_AUTO_PRECHG_ENBL 0x0000080000000000UL
116#define TCTRL4_AUTO_PRECHG_ENBL_SHIFT 43
117#define TCTRL4_RD_WR_PI_MORE_DLY 0x000007c000000000UL
118#define TCTRL4_RD_WR_PI_MORE_DLY_SHIFT 38
119#define TCTRL4_RD_WR_TI_DLY 0x0000003f00000000UL
120#define TCTRL4_RD_WR_TI_DLY_SHIFT 32
121#define TCTRL4_WR_WR_PI_MORE_DLY 0x00000000f8000000UL
122#define TCTRL4_WR_WR_PI_MORE_DLY_SHIFT 27
123#define TCTRL4_WR_WR_TI_DLY 0x0000000007e00000UL
124#define TCTRL4_WR_WR_TI_DLY_SHIFT 21
125#define TCTRL4_RDWR_RD_PI_MORE_DLY 0x00000000001f000UL0
126#define TCTRL4_RDWR_RD_PI_MORE_DLY_SHIFT 16
127#define TCTRL4_R 0x0000000000008000UL
128#define TCTRL4_R_SHIFT 15
129#define TCTRL4_SDRAM_MODE_REG_DATA 0x0000000000007fffUL
130#define TCTRL4_SDRAM_MODE_REG_DATA_SHIFT 0
131
132/* All 4 memory address decoding registers have the
133 * same layout.
134 */
135#define MEM_DECODE_VALID 0x8000000000000000UL /* Valid */
136#define MEM_DECODE_VALID_SHIFT 63
137#define MEM_DECODE_UK 0x001ffe0000000000UL /* Upper mask */
138#define MEM_DECODE_UK_SHIFT 41
139#define MEM_DECODE_UM 0x0000001ffff00000UL /* Upper match */
140#define MEM_DECODE_UM_SHIFT 20
141#define MEM_DECODE_LK 0x000000000003c000UL /* Lower mask */
142#define MEM_DECODE_LK_SHIFT 14
143#define MEM_DECODE_LM 0x0000000000000f00UL /* Lower match */
144#define MEM_DECODE_LM_SHIFT 8
145
146#define PA_UPPER_BITS 0x000007fffc000000UL
147#define PA_UPPER_BITS_SHIFT 26
148#define PA_LOWER_BITS 0x00000000000003c0UL
149#define PA_LOWER_BITS_SHIFT 6
150
151#define MACTRL_R0 0x8000000000000000UL
152#define MACTRL_R0_SHIFT 63
153#define MACTRL_ADDR_LE_PW 0x7000000000000000UL
154#define MACTRL_ADDR_LE_PW_SHIFT 60
155#define MACTRL_CMD_PW 0x0f00000000000000UL
156#define MACTRL_CMD_PW_SHIFT 56
157#define MACTRL_HALF_MODE_WR_MSEL_DLY 0x00fc000000000000UL
158#define MACTRL_HALF_MODE_WR_MSEL_DLY_SHIFT 50
159#define MACTRL_HALF_MODE_RD_MSEL_DLY 0x0003f00000000000UL
160#define MACTRL_HALF_MODE_RD_MSEL_DLY_SHIFT 44
161#define MACTRL_HALF_MODE_SDRAM_CTL_DLY 0x00000f0000000000UL
162#define MACTRL_HALF_MODE_SDRAM_CTL_DLY_SHIFT 40
163#define MACTRL_HALF_MODE_SDRAM_CLK_DLY 0x000000e000000000UL
164#define MACTRL_HALF_MODE_SDRAM_CLK_DLY_SHIFT 37
165#define MACTRL_R1 0x0000001000000000UL
166#define MACTRL_R1_SHIFT 36
167#define MACTRL_BANKSEL_N_ROWADDR_SIZE_B3 0x0000000f00000000UL
168#define MACTRL_BANKSEL_N_ROWADDR_SIZE_B3_SHIFT 32
169#define MACTRL_ENC_INTLV_B3 0x00000000f8000000UL
170#define MACTRL_ENC_INTLV_B3_SHIFT 27
171#define MACTRL_BANKSEL_N_ROWADDR_SIZE_B2 0x0000000007800000UL
172#define MACTRL_BANKSEL_N_ROWADDR_SIZE_B2_SHIFT 23
173#define MACTRL_ENC_INTLV_B2 0x00000000007c0000UL
174#define MACTRL_ENC_INTLV_B2_SHIFT 18
175#define MACTRL_BANKSEL_N_ROWADDR_SIZE_B1 0x000000000003c000UL
176#define MACTRL_BANKSEL_N_ROWADDR_SIZE_B1_SHIFT 14
177#define MACTRL_ENC_INTLV_B1 0x0000000000003e00UL
178#define MACTRL_ENC_INTLV_B1_SHIFT 9
179#define MACTRL_BANKSEL_N_ROWADDR_SIZE_B0 0x00000000000001e0UL
180#define MACTRL_BANKSEL_N_ROWADDR_SIZE_B0_SHIFT 5
181#define MACTRL_ENC_INTLV_B0 0x000000000000001fUL
182#define MACTRL_ENC_INTLV_B0_SHIFT 0
183
184#endif /* _SPARC64_CHMCTRL_H */
diff --git a/include/asm-sparc64/cmt.h b/include/asm-sparc64/cmt.h
new file mode 100644
index 000000000000..870db5928577
--- /dev/null
+++ b/include/asm-sparc64/cmt.h
@@ -0,0 +1,59 @@
1#ifndef _SPARC64_CMT_H
2#define _SPARC64_CMT_H
3
4/* cmt.h: Chip Multi-Threading register definitions
5 *
6 * Copyright (C) 2004 David S. Miller (davem@redhat.com)
7 */
8
9/* ASI_CORE_ID - private */
10#define LP_ID 0x0000000000000010UL
11#define LP_ID_MAX 0x00000000003f0000UL
12#define LP_ID_ID 0x000000000000003fUL
13
14/* ASI_INTR_ID - private */
15#define LP_INTR_ID 0x0000000000000000UL
16#define LP_INTR_ID_ID 0x00000000000003ffUL
17
18/* ASI_CESR_ID - private */
19#define CESR_ID 0x0000000000000040UL
20#define CESR_ID_ID 0x00000000000000ffUL
21
22/* ASI_CORE_AVAILABLE - shared */
23#define LP_AVAIL 0x0000000000000000UL
24#define LP_AVAIL_1 0x0000000000000002UL
25#define LP_AVAIL_0 0x0000000000000001UL
26
27/* ASI_CORE_ENABLE_STATUS - shared */
28#define LP_ENAB_STAT 0x0000000000000010UL
29#define LP_ENAB_STAT_1 0x0000000000000002UL
30#define LP_ENAB_STAT_0 0x0000000000000001UL
31
32/* ASI_CORE_ENABLE - shared */
33#define LP_ENAB 0x0000000000000020UL
34#define LP_ENAB_1 0x0000000000000002UL
35#define LP_ENAB_0 0x0000000000000001UL
36
37/* ASI_CORE_RUNNING - shared */
38#define LP_RUNNING_RW 0x0000000000000050UL
39#define LP_RUNNING_W1S 0x0000000000000060UL
40#define LP_RUNNING_W1C 0x0000000000000068UL
41#define LP_RUNNING_1 0x0000000000000002UL
42#define LP_RUNNING_0 0x0000000000000001UL
43
44/* ASI_CORE_RUNNING_STAT - shared */
45#define LP_RUN_STAT 0x0000000000000058UL
46#define LP_RUN_STAT_1 0x0000000000000002UL
47#define LP_RUN_STAT_0 0x0000000000000001UL
48
49/* ASI_XIR_STEERING - shared */
50#define LP_XIR_STEER 0x0000000000000030UL
51#define LP_XIR_STEER_1 0x0000000000000002UL
52#define LP_XIR_STEER_0 0x0000000000000001UL
53
54/* ASI_CMT_ERROR_STEERING - shared */
55#define CMT_ER_STEER 0x0000000000000040UL
56#define CMT_ER_STEER_1 0x0000000000000002UL
57#define CMT_ER_STEER_0 0x0000000000000001UL
58
59#endif /* _SPARC64_CMT_H */
diff --git a/include/asm-sparc64/compat.h b/include/asm-sparc64/compat.h
new file mode 100644
index 000000000000..2950279dd776
--- /dev/null
+++ b/include/asm-sparc64/compat.h
@@ -0,0 +1,201 @@
1#ifndef _ASM_SPARC64_COMPAT_H
2#define _ASM_SPARC64_COMPAT_H
3/*
4 * Architecture specific compatibility types
5 */
6#include <linux/types.h>
7
8#define COMPAT_USER_HZ 100
9
10typedef u32 compat_size_t;
11typedef s32 compat_ssize_t;
12typedef s32 compat_time_t;
13typedef s32 compat_clock_t;
14typedef s32 compat_pid_t;
15typedef u16 compat_uid_t;
16typedef u16 compat_gid_t;
17typedef u16 compat_mode_t;
18typedef u32 compat_ino_t;
19typedef u16 compat_dev_t;
20typedef s32 compat_off_t;
21typedef s64 compat_loff_t;
22typedef s16 compat_nlink_t;
23typedef u16 compat_ipc_pid_t;
24typedef s32 compat_daddr_t;
25typedef u32 compat_caddr_t;
26typedef __kernel_fsid_t compat_fsid_t;
27typedef s32 compat_key_t;
28
29typedef s32 compat_int_t;
30typedef s32 compat_long_t;
31typedef u32 compat_uint_t;
32typedef u32 compat_ulong_t;
33
34struct compat_timespec {
35 compat_time_t tv_sec;
36 s32 tv_nsec;
37};
38
39struct compat_timeval {
40 compat_time_t tv_sec;
41 s32 tv_usec;
42};
43
44struct compat_stat {
45 compat_dev_t st_dev;
46 compat_ino_t st_ino;
47 compat_mode_t st_mode;
48 compat_nlink_t st_nlink;
49 compat_uid_t st_uid;
50 compat_gid_t st_gid;
51 compat_dev_t st_rdev;
52 compat_off_t st_size;
53 compat_time_t st_atime;
54 u32 __unused1;
55 compat_time_t st_mtime;
56 u32 __unused2;
57 compat_time_t st_ctime;
58 u32 __unused3;
59 compat_off_t st_blksize;
60 compat_off_t st_blocks;
61 u32 __unused4[2];
62};
63
64struct compat_flock {
65 short l_type;
66 short l_whence;
67 compat_off_t l_start;
68 compat_off_t l_len;
69 compat_pid_t l_pid;
70 short __unused;
71};
72
73#define F_GETLK64 12
74#define F_SETLK64 13
75#define F_SETLKW64 14
76
77struct compat_flock64 {
78 short l_type;
79 short l_whence;
80 compat_loff_t l_start;
81 compat_loff_t l_len;
82 compat_pid_t l_pid;
83 short __unused;
84};
85
86struct compat_statfs {
87 int f_type;
88 int f_bsize;
89 int f_blocks;
90 int f_bfree;
91 int f_bavail;
92 int f_files;
93 int f_ffree;
94 compat_fsid_t f_fsid;
95 int f_namelen; /* SunOS ignores this field. */
96 int f_frsize;
97 int f_spare[5];
98};
99
100#define COMPAT_RLIM_INFINITY 0x7fffffff
101
102typedef u32 compat_old_sigset_t;
103
104#define _COMPAT_NSIG 64
105#define _COMPAT_NSIG_BPW 32
106
107typedef u32 compat_sigset_word;
108
109#define COMPAT_OFF_T_MAX 0x7fffffff
110#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
111
112/*
113 * A pointer passed in from user mode. This should not
114 * be used for syscall parameters, just declare them
115 * as pointers because the syscall entry code will have
116 * appropriately comverted them already.
117 */
118typedef u32 compat_uptr_t;
119
120static inline void __user *compat_ptr(compat_uptr_t uptr)
121{
122 return (void __user *)(unsigned long)uptr;
123}
124
125static inline compat_uptr_t ptr_to_compat(void __user *uptr)
126{
127 return (u32)(unsigned long)uptr;
128}
129
130static __inline__ void __user *compat_alloc_user_space(long len)
131{
132 struct pt_regs *regs = current_thread_info()->kregs;
133 unsigned long usp = regs->u_regs[UREG_I6];
134
135 if (!(test_thread_flag(TIF_32BIT)))
136 usp += STACK_BIAS;
137 else
138 usp &= 0xffffffffUL;
139
140 return (void __user *) (usp - len);
141}
142
143struct compat_ipc64_perm {
144 compat_key_t key;
145 __kernel_uid_t uid;
146 __kernel_gid_t gid;
147 __kernel_uid_t cuid;
148 __kernel_gid_t cgid;
149 unsigned short __pad1;
150 compat_mode_t mode;
151 unsigned short __pad2;
152 unsigned short seq;
153 unsigned long __unused1; /* yes they really are 64bit pads */
154 unsigned long __unused2;
155};
156
157struct compat_semid64_ds {
158 struct compat_ipc64_perm sem_perm;
159 unsigned int __pad1;
160 compat_time_t sem_otime;
161 unsigned int __pad2;
162 compat_time_t sem_ctime;
163 u32 sem_nsems;
164 u32 __unused1;
165 u32 __unused2;
166};
167
168struct compat_msqid64_ds {
169 struct compat_ipc64_perm msg_perm;
170 unsigned int __pad1;
171 compat_time_t msg_stime;
172 unsigned int __pad2;
173 compat_time_t msg_rtime;
174 unsigned int __pad3;
175 compat_time_t msg_ctime;
176 unsigned int msg_cbytes;
177 unsigned int msg_qnum;
178 unsigned int msg_qbytes;
179 compat_pid_t msg_lspid;
180 compat_pid_t msg_lrpid;
181 unsigned int __unused1;
182 unsigned int __unused2;
183};
184
185struct compat_shmid64_ds {
186 struct compat_ipc64_perm shm_perm;
187 unsigned int __pad1;
188 compat_time_t shm_atime;
189 unsigned int __pad2;
190 compat_time_t shm_dtime;
191 unsigned int __pad3;
192 compat_time_t shm_ctime;
193 compat_size_t shm_segsz;
194 compat_pid_t shm_cpid;
195 compat_pid_t shm_lpid;
196 unsigned int shm_nattch;
197 unsigned int __unused1;
198 unsigned int __unused2;
199};
200
201#endif /* _ASM_SPARC64_COMPAT_H */
diff --git a/include/asm-sparc64/const.h b/include/asm-sparc64/const.h
new file mode 100644
index 000000000000..8ad902b2ce04
--- /dev/null
+++ b/include/asm-sparc64/const.h
@@ -0,0 +1,19 @@
1/* const.h: Macros for dealing with constants. */
2
3#ifndef _SPARC64_CONST_H
4#define _SPARC64_CONST_H
5
6/* Some constant macros are used in both assembler and
7 * C code. Therefore we cannot annotate them always with
8 * 'UL' and other type specificers unilaterally. We
9 * use the following macros to deal with this.
10 */
11
12#ifdef __ASSEMBLY__
13#define _AC(X,Y) X
14#else
15#define _AC(X,Y) (X##Y)
16#endif
17
18
19#endif /* !(_SPARC64_CONST_H) */
diff --git a/include/asm-sparc64/cpudata.h b/include/asm-sparc64/cpudata.h
new file mode 100644
index 000000000000..cc7198aaac50
--- /dev/null
+++ b/include/asm-sparc64/cpudata.h
@@ -0,0 +1,31 @@
1/* cpudata.h: Per-cpu parameters.
2 *
3 * Copyright (C) 2003 David S. Miller (davem@redhat.com)
4 */
5
6#ifndef _SPARC64_CPUDATA_H
7#define _SPARC64_CPUDATA_H
8
9#include <linux/percpu.h>
10
11typedef struct {
12 /* Dcache line 1 */
13 unsigned int __pad0; /* bh_count moved to irq_stat for consistency. KAO */
14 unsigned int multiplier;
15 unsigned int counter;
16 unsigned int idle_volume;
17 unsigned long clock_tick; /* %tick's per second */
18 unsigned long udelay_val;
19
20 /* Dcache line 2 */
21 unsigned int pgcache_size;
22 unsigned int __pad1;
23 unsigned long *pte_cache[2];
24 unsigned long *pgd_cache;
25} cpuinfo_sparc;
26
27DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
28#define cpu_data(__cpu) per_cpu(__cpu_data, (__cpu))
29#define local_cpu_data() __get_cpu_var(__cpu_data)
30
31#endif /* _SPARC64_CPUDATA_H */
diff --git a/include/asm-sparc64/cputime.h b/include/asm-sparc64/cputime.h
new file mode 100644
index 000000000000..dec2fc7a36f8
--- /dev/null
+++ b/include/asm-sparc64/cputime.h
@@ -0,0 +1,6 @@
1#ifndef __SPARC64_CPUTIME_H
2#define __SPARC64_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __SPARC64_CPUTIME_H */
diff --git a/include/asm-sparc64/current.h b/include/asm-sparc64/current.h
new file mode 100644
index 000000000000..6c21e4ee2475
--- /dev/null
+++ b/include/asm-sparc64/current.h
@@ -0,0 +1,8 @@
1#ifndef _SPARC64_CURRENT_H
2#define _SPARC64_CURRENT_H
3
4#include <linux/thread_info.h>
5
6register struct task_struct *current asm("g4");
7
8#endif /* !(_SPARC64_CURRENT_H) */
diff --git a/include/asm-sparc64/dcr.h b/include/asm-sparc64/dcr.h
new file mode 100644
index 000000000000..e9a3f305815d
--- /dev/null
+++ b/include/asm-sparc64/dcr.h
@@ -0,0 +1,15 @@
1/* $Id: dcr.h,v 1.4 2001/03/09 17:56:37 davem Exp $ */
2#ifndef _SPARC64_DCR_H
3#define _SPARC64_DCR_H
4
5/* UltraSparc-III/III+ Dispatch Control Register, ASR 0x12 */
6#define DCR_DPE 0x0000000000001000 /* III+: D$ Parity Error Enable */
7#define DCR_OBS 0x0000000000000fc0 /* Observability Bus Controls */
8#define DCR_BPE 0x0000000000000020 /* Branch Predict Enable */
9#define DCR_RPE 0x0000000000000010 /* Return Address Prediction Enable */
10#define DCR_SI 0x0000000000000008 /* Single Instruction Disable */
11#define DCR_IPE 0x0000000000000004 /* III+: I$ Parity Error Enable */
12#define DCR_IFPOE 0x0000000000000002 /* IRQ FP Operation Enable */
13#define DCR_MS 0x0000000000000001 /* Multi-Scalar dispatch */
14
15#endif /* _SPARC64_DCR_H */
diff --git a/include/asm-sparc64/dcu.h b/include/asm-sparc64/dcu.h
new file mode 100644
index 000000000000..ecbed2ae548f
--- /dev/null
+++ b/include/asm-sparc64/dcu.h
@@ -0,0 +1,26 @@
1/* $Id: dcu.h,v 1.2 2001/03/01 23:23:33 davem Exp $ */
2#ifndef _SPARC64_DCU_H
3#define _SPARC64_DCU_H
4
5/* UltraSparc-III Data Cache Unit Control Register */
6#define DCU_CP 0x0002000000000000 /* Physical Cache Enable w/o mmu*/
7#define DCU_CV 0x0001000000000000 /* Virtual Cache Enable w/o mmu */
8#define DCU_ME 0x0000800000000000 /* NC-store Merging Enable */
9#define DCU_RE 0x0000400000000000 /* RAW bypass Enable */
10#define DCU_PE 0x0000200000000000 /* PCache Enable */
11#define DCU_HPE 0x0000100000000000 /* HW prefetch Enable */
12#define DCU_SPE 0x0000080000000000 /* SW prefetch Enable */
13#define DCU_SL 0x0000040000000000 /* Secondary load steering Enab */
14#define DCU_WE 0x0000020000000000 /* WCache enable */
15#define DCU_PM 0x000001fe00000000 /* PA Watchpoint Byte Mask */
16#define DCU_VM 0x00000001fe000000 /* VA Watchpoint Byte Mask */
17#define DCU_PR 0x0000000001000000 /* PA Watchpoint Read Enable */
18#define DCU_PW 0x0000000000800000 /* PA Watchpoint Write Enable */
19#define DCU_VR 0x0000000000400000 /* VA Watchpoint Read Enable */
20#define DCU_VW 0x0000000000200000 /* VA Watchpoint Write Enable */
21#define DCU_DM 0x0000000000000008 /* DMMU Enable */
22#define DCU_IM 0x0000000000000004 /* IMMU Enable */
23#define DCU_DC 0x0000000000000002 /* Data Cache Enable */
24#define DCU_IC 0x0000000000000001 /* Instruction Cache Enable */
25
26#endif /* _SPARC64_DCU_H */
diff --git a/include/asm-sparc64/delay.h b/include/asm-sparc64/delay.h
new file mode 100644
index 000000000000..2901ea0c342d
--- /dev/null
+++ b/include/asm-sparc64/delay.h
@@ -0,0 +1,38 @@
1/* delay.h: Linux delay routines on sparc64.
2 *
3 * Copyright (C) 1996, 2004 David S. Miller (davem@davemloft.net).
4 *
5 * Based heavily upon x86 variant which is:
6 * Copyright (C) 1993 Linus Torvalds
7 *
8 * Delay routines calling functions in arch/sparc64/lib/delay.c
9 */
10
11#ifndef __SPARC64_DELAY_H
12#define __SPARC64_DELAY_H
13
14#include <linux/config.h>
15#include <linux/param.h>
16#include <asm/cpudata.h>
17
18#ifndef __ASSEMBLY__
19
20extern void __bad_udelay(void);
21extern void __bad_ndelay(void);
22
23extern void __udelay(unsigned long usecs);
24extern void __ndelay(unsigned long nsecs);
25extern void __const_udelay(unsigned long usecs);
26extern void __delay(unsigned long loops);
27
28#define udelay(n) (__builtin_constant_p(n) ? \
29 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
30 __udelay(n))
31
32#define ndelay(n) (__builtin_constant_p(n) ? \
33 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
34 __ndelay(n))
35
36#endif /* !__ASSEMBLY__ */
37
38#endif /* defined(__SPARC64_DELAY_H) */
diff --git a/include/asm-sparc64/display7seg.h b/include/asm-sparc64/display7seg.h
new file mode 100644
index 000000000000..955a3502218e
--- /dev/null
+++ b/include/asm-sparc64/display7seg.h
@@ -0,0 +1,79 @@
1/* $Id: display7seg.h,v 1.2 2000/08/02 06:22:35 davem Exp $
2 *
3 * display7seg - Driver interface for the 7-segment display
4 * present on Sun Microsystems CP1400 and CP1500
5 *
6 * Copyright (c) 2000 Eric Brower <ebrower@usa.net>
7 *
8 */
9
10#ifndef __display7seg_h__
11#define __display7seg_h__
12
13#define D7S_IOC 'p'
14
15#define D7SIOCRD _IOR(D7S_IOC, 0x45, int) /* Read device state */
16#define D7SIOCWR _IOW(D7S_IOC, 0x46, int) /* Write device state */
17#define D7SIOCTM _IO (D7S_IOC, 0x47) /* Translate mode (FLIP)*/
18
19/*
20 * ioctl flag definitions
21 *
22 * POINT - Toggle decimal point (0=absent 1=present)
23 * ALARM - Toggle alarm LED (0=green 1=red)
24 * FLIP - Toggle inverted mode (0=normal 1=flipped)
25 * bits 0-4 - Character displayed (see definitions below)
26 *
27 * Display segments are defined as follows,
28 * subject to D7S_FLIP register state:
29 *
30 * a
31 * ---
32 * f| |b
33 * -g-
34 * e| |c
35 * ---
36 * d
37 */
38
39#define D7S_POINT (1 << 7) /* Decimal point*/
40#define D7S_ALARM (1 << 6) /* Alarm LED */
41#define D7S_FLIP (1 << 5) /* Flip display */
42
43#define D7S_0 0x00 /* Numerals 0-9 */
44#define D7S_1 0x01
45#define D7S_2 0x02
46#define D7S_3 0x03
47#define D7S_4 0x04
48#define D7S_5 0x05
49#define D7S_6 0x06
50#define D7S_7 0x07
51#define D7S_8 0x08
52#define D7S_9 0x09
53#define D7S_A 0x0A /* Letters A-F, H, L, P */
54#define D7S_B 0x0B
55#define D7S_C 0x0C
56#define D7S_D 0x0D
57#define D7S_E 0x0E
58#define D7S_F 0x0F
59#define D7S_H 0x10
60#define D7S_E2 0x11
61#define D7S_L 0x12
62#define D7S_P 0x13
63#define D7S_SEGA 0x14 /* Individual segments */
64#define D7S_SEGB 0x15
65#define D7S_SEGC 0x16
66#define D7S_SEGD 0x17
67#define D7S_SEGE 0x18
68#define D7S_SEGF 0x19
69#define D7S_SEGG 0x1A
70#define D7S_SEGABFG 0x1B /* Segment groupings */
71#define D7S_SEGCDEG 0x1C
72#define D7S_SEGBCEF 0x1D
73#define D7S_SEGADG 0x1E
74#define D7S_BLANK 0x1F /* Clear all segments */
75
76#define D7S_MIN_VAL 0x0
77#define D7S_MAX_VAL 0x1F
78
79#endif /* ifndef __display7seg_h__ */
diff --git a/include/asm-sparc64/div64.h b/include/asm-sparc64/div64.h
new file mode 100644
index 000000000000..6cd978cefb28
--- /dev/null
+++ b/include/asm-sparc64/div64.h
@@ -0,0 +1 @@
#include <asm-generic/div64.h>
diff --git a/include/asm-sparc64/dma-mapping.h b/include/asm-sparc64/dma-mapping.h
new file mode 100644
index 000000000000..1c5da41653a4
--- /dev/null
+++ b/include/asm-sparc64/dma-mapping.h
@@ -0,0 +1,27 @@
1#ifndef _ASM_SPARC64_DMA_MAPPING_H
2#define _ASM_SPARC64_DMA_MAPPING_H
3
4#include <linux/config.h>
5
6#ifdef CONFIG_PCI
7#include <asm-generic/dma-mapping.h>
8#else
9
10struct device;
11
12static inline void *dma_alloc_coherent(struct device *dev, size_t size,
13 dma_addr_t *dma_handle, int flag)
14{
15 BUG();
16 return NULL;
17}
18
19static inline void dma_free_coherent(struct device *dev, size_t size,
20 void *vaddr, dma_addr_t dma_handle)
21{
22 BUG();
23}
24
25#endif /* PCI */
26
27#endif /* _ASM_SPARC64_DMA_MAPPING_H */
diff --git a/include/asm-sparc64/dma.h b/include/asm-sparc64/dma.h
new file mode 100644
index 000000000000..1aab3c8dce2b
--- /dev/null
+++ b/include/asm-sparc64/dma.h
@@ -0,0 +1,221 @@
1/* $Id: dma.h,v 1.21 2001/12/13 04:16:52 davem Exp $
2 * include/asm-sparc64/dma.h
3 *
4 * Copyright 1996 (C) David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _ASM_SPARC64_DMA_H
8#define _ASM_SPARC64_DMA_H
9
10#include <linux/config.h>
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/spinlock.h>
14
15#include <asm/sbus.h>
16#include <asm/delay.h>
17#include <asm/oplib.h>
18
19extern spinlock_t dma_spin_lock;
20
21#define claim_dma_lock() \
22({ unsigned long flags; \
23 spin_lock_irqsave(&dma_spin_lock, flags); \
24 flags; \
25})
26
27#define release_dma_lock(__flags) \
28 spin_unlock_irqrestore(&dma_spin_lock, __flags);
29
30/* These are irrelevant for Sparc DMA, but we leave it in so that
31 * things can compile.
32 */
33#define MAX_DMA_CHANNELS 8
34#define DMA_MODE_READ 1
35#define DMA_MODE_WRITE 2
36#define MAX_DMA_ADDRESS (~0UL)
37
38/* Useful constants */
39#define SIZE_16MB (16*1024*1024)
40#define SIZE_64K (64*1024)
41
42/* SBUS DMA controller reg offsets */
43#define DMA_CSR 0x00UL /* rw DMA control/status register 0x00 */
44#define DMA_ADDR 0x04UL /* rw DMA transfer address register 0x04 */
45#define DMA_COUNT 0x08UL /* rw DMA transfer count register 0x08 */
46#define DMA_TEST 0x0cUL /* rw DMA test/debug register 0x0c */
47
48/* DVMA chip revisions */
49enum dvma_rev {
50 dvmarev0,
51 dvmaesc1,
52 dvmarev1,
53 dvmarev2,
54 dvmarev3,
55 dvmarevplus,
56 dvmahme
57};
58
59#define DMA_HASCOUNT(rev) ((rev)==dvmaesc1)
60
61/* Linux DMA information structure, filled during probe. */
62struct sbus_dma {
63 struct sbus_dma *next;
64 struct sbus_dev *sdev;
65 void __iomem *regs;
66
67 /* Status, misc info */
68 int node; /* Prom node for this DMA device */
69 int running; /* Are we doing DMA now? */
70 int allocated; /* Are we "owned" by anyone yet? */
71
72 /* Transfer information. */
73 u32 addr; /* Start address of current transfer */
74 int nbytes; /* Size of current transfer */
75 int realbytes; /* For splitting up large transfers, etc. */
76
77 /* DMA revision */
78 enum dvma_rev revision;
79};
80
81extern struct sbus_dma *dma_chain;
82
83/* Broken hardware... */
84#define DMA_ISBROKEN(dma) ((dma)->revision == dvmarev1)
85#define DMA_ISESC1(dma) ((dma)->revision == dvmaesc1)
86
87/* Main routines in dma.c */
88extern void dvma_init(struct sbus_bus *);
89
90/* Fields in the cond_reg register */
91/* First, the version identification bits */
92#define DMA_DEVICE_ID 0xf0000000 /* Device identification bits */
93#define DMA_VERS0 0x00000000 /* Sunray DMA version */
94#define DMA_ESCV1 0x40000000 /* DMA ESC Version 1 */
95#define DMA_VERS1 0x80000000 /* DMA rev 1 */
96#define DMA_VERS2 0xa0000000 /* DMA rev 2 */
97#define DMA_VERHME 0xb0000000 /* DMA hme gate array */
98#define DMA_VERSPLUS 0x90000000 /* DMA rev 1 PLUS */
99
100#define DMA_HNDL_INTR 0x00000001 /* An IRQ needs to be handled */
101#define DMA_HNDL_ERROR 0x00000002 /* We need to take an error */
102#define DMA_FIFO_ISDRAIN 0x0000000c /* The DMA FIFO is draining */
103#define DMA_INT_ENAB 0x00000010 /* Turn on interrupts */
104#define DMA_FIFO_INV 0x00000020 /* Invalidate the FIFO */
105#define DMA_ACC_SZ_ERR 0x00000040 /* The access size was bad */
106#define DMA_FIFO_STDRAIN 0x00000040 /* DMA_VERS1 Drain the FIFO */
107#define DMA_RST_SCSI 0x00000080 /* Reset the SCSI controller */
108#define DMA_RST_ENET DMA_RST_SCSI /* Reset the ENET controller */
109#define DMA_ST_WRITE 0x00000100 /* write from device to memory */
110#define DMA_ENABLE 0x00000200 /* Fire up DMA, handle requests */
111#define DMA_PEND_READ 0x00000400 /* DMA_VERS1/0/PLUS Pending Read */
112#define DMA_ESC_BURST 0x00000800 /* 1=16byte 0=32byte */
113#define DMA_READ_AHEAD 0x00001800 /* DMA read ahead partial longword */
114#define DMA_DSBL_RD_DRN 0x00001000 /* No EC drain on slave reads */
115#define DMA_BCNT_ENAB 0x00002000 /* If on, use the byte counter */
116#define DMA_TERM_CNTR 0x00004000 /* Terminal counter */
117#define DMA_SCSI_SBUS64 0x00008000 /* HME: Enable 64-bit SBUS mode. */
118#define DMA_CSR_DISAB 0x00010000 /* No FIFO drains during csr */
119#define DMA_SCSI_DISAB 0x00020000 /* No FIFO drains during reg */
120#define DMA_DSBL_WR_INV 0x00020000 /* No EC inval. on slave writes */
121#define DMA_ADD_ENABLE 0x00040000 /* Special ESC DVMA optimization */
122#define DMA_E_BURSTS 0x000c0000 /* ENET: SBUS r/w burst mask */
123#define DMA_E_BURST32 0x00040000 /* ENET: SBUS 32 byte r/w burst */
124#define DMA_E_BURST16 0x00000000 /* ENET: SBUS 16 byte r/w burst */
125#define DMA_BRST_SZ 0x000c0000 /* SCSI: SBUS r/w burst size */
126#define DMA_BRST64 0x000c0000 /* SCSI: 64byte bursts (HME on UltraSparc only) */
127#define DMA_BRST32 0x00040000 /* SCSI: 32byte bursts */
128#define DMA_BRST16 0x00000000 /* SCSI: 16byte bursts */
129#define DMA_BRST0 0x00080000 /* SCSI: no bursts (non-HME gate arrays) */
130#define DMA_ADDR_DISAB 0x00100000 /* No FIFO drains during addr */
131#define DMA_2CLKS 0x00200000 /* Each transfer = 2 clock ticks */
132#define DMA_3CLKS 0x00400000 /* Each transfer = 3 clock ticks */
133#define DMA_EN_ENETAUI DMA_3CLKS /* Put lance into AUI-cable mode */
134#define DMA_CNTR_DISAB 0x00800000 /* No IRQ when DMA_TERM_CNTR set */
135#define DMA_AUTO_NADDR 0x01000000 /* Use "auto nxt addr" feature */
136#define DMA_SCSI_ON 0x02000000 /* Enable SCSI dma */
137#define DMA_PARITY_OFF 0x02000000 /* HME: disable parity checking */
138#define DMA_LOADED_ADDR 0x04000000 /* Address has been loaded */
139#define DMA_LOADED_NADDR 0x08000000 /* Next address has been loaded */
140#define DMA_RESET_FAS366 0x08000000 /* HME: Assert RESET to FAS366 */
141
142/* Values describing the burst-size property from the PROM */
143#define DMA_BURST1 0x01
144#define DMA_BURST2 0x02
145#define DMA_BURST4 0x04
146#define DMA_BURST8 0x08
147#define DMA_BURST16 0x10
148#define DMA_BURST32 0x20
149#define DMA_BURST64 0x40
150#define DMA_BURSTBITS 0x7f
151
152/* Determine highest possible final transfer address given a base */
153#define DMA_MAXEND(addr) (0x01000000UL-(((unsigned long)(addr))&0x00ffffffUL))
154
155/* Yes, I hack a lot of elisp in my spare time... */
156#define DMA_ERROR_P(regs) (((sbus_readl((regs) + DMA_CSR) & DMA_HNDL_ERROR))
157#define DMA_IRQ_P(regs) (((sbus_readl((regs) + DMA_CSR)) & (DMA_HNDL_INTR | DMA_HNDL_ERROR)))
158#define DMA_WRITE_P(regs) (((sbus_readl((regs) + DMA_CSR) & DMA_ST_WRITE))
159#define DMA_OFF(__regs) \
160do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
161 tmp &= ~DMA_ENABLE; \
162 sbus_writel(tmp, (__regs) + DMA_CSR); \
163} while(0)
164#define DMA_INTSOFF(__regs) \
165do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
166 tmp &= ~DMA_INT_ENAB; \
167 sbus_writel(tmp, (__regs) + DMA_CSR); \
168} while(0)
169#define DMA_INTSON(__regs) \
170do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
171 tmp |= DMA_INT_ENAB; \
172 sbus_writel(tmp, (__regs) + DMA_CSR); \
173} while(0)
174#define DMA_PUNTFIFO(__regs) \
175do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
176 tmp |= DMA_FIFO_INV; \
177 sbus_writel(tmp, (__regs) + DMA_CSR); \
178} while(0)
179#define DMA_SETSTART(__regs, __addr) \
180 sbus_writel((u32)(__addr), (__regs) + DMA_ADDR);
181#define DMA_BEGINDMA_W(__regs) \
182do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
183 tmp |= (DMA_ST_WRITE|DMA_ENABLE|DMA_INT_ENAB); \
184 sbus_writel(tmp, (__regs) + DMA_CSR); \
185} while(0)
186#define DMA_BEGINDMA_R(__regs) \
187do { u32 tmp = sbus_readl((__regs) + DMA_CSR); \
188 tmp |= (DMA_ENABLE|DMA_INT_ENAB); \
189 tmp &= ~DMA_ST_WRITE; \
190 sbus_writel(tmp, (__regs) + DMA_CSR); \
191} while(0)
192
193/* For certain DMA chips, we need to disable ints upon irq entry
194 * and turn them back on when we are done. So in any ESP interrupt
195 * handler you *must* call DMA_IRQ_ENTRY upon entry and DMA_IRQ_EXIT
196 * when leaving the handler. You have been warned...
197 */
198#define DMA_IRQ_ENTRY(dma, dregs) do { \
199 if(DMA_ISBROKEN(dma)) DMA_INTSOFF(dregs); \
200 } while (0)
201
202#define DMA_IRQ_EXIT(dma, dregs) do { \
203 if(DMA_ISBROKEN(dma)) DMA_INTSON(dregs); \
204 } while(0)
205
206#define for_each_dvma(dma) \
207 for((dma) = dma_chain; (dma); (dma) = (dma)->next)
208
209extern int get_dma_list(char *);
210extern int request_dma(unsigned int, __const__ char *);
211extern void free_dma(unsigned int);
212
213/* From PCI */
214
215#ifdef CONFIG_PCI
216extern int isa_dma_bridge_buggy;
217#else
218#define isa_dma_bridge_buggy (0)
219#endif
220
221#endif /* !(_ASM_SPARC64_DMA_H) */
diff --git a/include/asm-sparc64/ebus.h b/include/asm-sparc64/ebus.h
new file mode 100644
index 000000000000..543e4e500a72
--- /dev/null
+++ b/include/asm-sparc64/ebus.h
@@ -0,0 +1,97 @@
1/* $Id: ebus.h,v 1.10 2001/03/14 05:00:55 davem Exp $
2 * ebus.h: PCI to Ebus pseudo driver software state.
3 *
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
6 */
7
8#ifndef __SPARC64_EBUS_H
9#define __SPARC64_EBUS_H
10
11#include <asm/pbm.h>
12#include <asm/oplib.h>
13
14struct linux_ebus_child {
15 struct linux_ebus_child *next;
16 struct linux_ebus_device *parent;
17 struct linux_ebus *bus;
18 int prom_node;
19 char prom_name[64];
20 struct resource resource[PROMREG_MAX];
21 int num_addrs;
22 unsigned int irqs[PROMINTR_MAX];
23 int num_irqs;
24};
25
26struct linux_ebus_device {
27 struct linux_ebus_device *next;
28 struct linux_ebus_child *children;
29 struct linux_ebus *bus;
30 int prom_node;
31 char prom_name[64];
32 struct resource resource[PROMREG_MAX];
33 int num_addrs;
34 unsigned int irqs[PROMINTR_MAX];
35 int num_irqs;
36};
37
38struct linux_ebus {
39 struct linux_ebus *next;
40 struct linux_ebus_device *devices;
41 struct pci_pbm_info *parent;
42 struct pci_dev *self;
43 int index;
44 int is_rio;
45 int prom_node;
46 char prom_name[64];
47 struct linux_prom_ebus_ranges ebus_ranges[PROMREG_MAX];
48 int num_ebus_ranges;
49 struct linux_prom_ebus_intmap ebus_intmap[PROMREG_MAX];
50 int num_ebus_intmap;
51 struct linux_prom_ebus_intmask ebus_intmask;
52};
53
54struct ebus_dma_info {
55 spinlock_t lock;
56 void __iomem *regs;
57
58 unsigned int flags;
59#define EBUS_DMA_FLAG_USE_EBDMA_HANDLER 0x00000001
60#define EBUS_DMA_FLAG_TCI_DISABLE 0x00000002
61
62 /* These are only valid is EBUS_DMA_FLAG_USE_EBDMA_HANDLER is
63 * set.
64 */
65 void (*callback)(struct ebus_dma_info *p, int event, void *cookie);
66 void *client_cookie;
67 unsigned int irq;
68#define EBUS_DMA_EVENT_ERROR 1
69#define EBUS_DMA_EVENT_DMA 2
70#define EBUS_DMA_EVENT_DEVICE 4
71
72 unsigned char name[64];
73};
74
75extern int ebus_dma_register(struct ebus_dma_info *p);
76extern int ebus_dma_irq_enable(struct ebus_dma_info *p, int on);
77extern void ebus_dma_unregister(struct ebus_dma_info *p);
78extern int ebus_dma_request(struct ebus_dma_info *p, dma_addr_t bus_addr,
79 size_t len);
80extern void ebus_dma_prepare(struct ebus_dma_info *p, int write);
81extern unsigned int ebus_dma_residue(struct ebus_dma_info *p);
82extern void ebus_dma_enable(struct ebus_dma_info *p, int on);
83
84extern struct linux_ebus *ebus_chain;
85
86extern void ebus_init(void);
87
88#define for_each_ebus(bus) \
89 for((bus) = ebus_chain; (bus); (bus) = (bus)->next)
90
91#define for_each_ebusdev(dev, bus) \
92 for((dev) = (bus)->devices; (dev); (dev) = (dev)->next)
93
94#define for_each_edevchild(dev, child) \
95 for((child) = (dev)->children; (child); (child) = (child)->next)
96
97#endif /* !(__SPARC64_EBUS_H) */
diff --git a/include/asm-sparc64/elf.h b/include/asm-sparc64/elf.h
new file mode 100644
index 000000000000..91458118277e
--- /dev/null
+++ b/include/asm-sparc64/elf.h
@@ -0,0 +1,181 @@
1/* $Id: elf.h,v 1.32 2002/02/09 19:49:31 davem Exp $ */
2#ifndef __ASM_SPARC64_ELF_H
3#define __ASM_SPARC64_ELF_H
4
5/*
6 * ELF register definitions..
7 */
8
9#include <asm/ptrace.h>
10#ifdef __KERNEL__
11#include <asm/processor.h>
12#include <asm/uaccess.h>
13#endif
14
15/*
16 * Sparc section types
17 */
18#define STT_REGISTER 13
19
20/*
21 * Sparc ELF relocation types
22 */
23#define R_SPARC_NONE 0
24#define R_SPARC_8 1
25#define R_SPARC_16 2
26#define R_SPARC_32 3
27#define R_SPARC_DISP8 4
28#define R_SPARC_DISP16 5
29#define R_SPARC_DISP32 6
30#define R_SPARC_WDISP30 7
31#define R_SPARC_WDISP22 8
32#define R_SPARC_HI22 9
33#define R_SPARC_22 10
34#define R_SPARC_13 11
35#define R_SPARC_LO10 12
36#define R_SPARC_GOT10 13
37#define R_SPARC_GOT13 14
38#define R_SPARC_GOT22 15
39#define R_SPARC_PC10 16
40#define R_SPARC_PC22 17
41#define R_SPARC_WPLT30 18
42#define R_SPARC_COPY 19
43#define R_SPARC_GLOB_DAT 20
44#define R_SPARC_JMP_SLOT 21
45#define R_SPARC_RELATIVE 22
46#define R_SPARC_UA32 23
47#define R_SPARC_PLT32 24
48#define R_SPARC_HIPLT22 25
49#define R_SPARC_LOPLT10 26
50#define R_SPARC_PCPLT32 27
51#define R_SPARC_PCPLT22 28
52#define R_SPARC_PCPLT10 29
53#define R_SPARC_10 30
54#define R_SPARC_11 31
55#define R_SPARC_64 32
56#define R_SPARC_OLO10 33
57#define R_SPARC_WDISP16 40
58#define R_SPARC_WDISP19 41
59#define R_SPARC_7 43
60#define R_SPARC_5 44
61#define R_SPARC_6 45
62
63/* Bits present in AT_HWCAP, primarily for Sparc32. */
64
65#define HWCAP_SPARC_FLUSH 1 /* CPU supports flush instruction. */
66#define HWCAP_SPARC_STBAR 2
67#define HWCAP_SPARC_SWAP 4
68#define HWCAP_SPARC_MULDIV 8
69#define HWCAP_SPARC_V9 16
70#define HWCAP_SPARC_ULTRA3 32
71
72/*
73 * These are used to set parameters in the core dumps.
74 */
75#ifndef ELF_ARCH
76#define ELF_ARCH EM_SPARCV9
77#define ELF_CLASS ELFCLASS64
78#define ELF_DATA ELFDATA2MSB
79
80typedef unsigned long elf_greg_t;
81
82#define ELF_NGREG 36
83typedef elf_greg_t elf_gregset_t[ELF_NGREG];
84/* Format of 64-bit elf_gregset_t is:
85 * G0 --> G7
86 * O0 --> O7
87 * L0 --> L7
88 * I0 --> I7
89 * TSTATE
90 * TPC
91 * TNPC
92 * Y
93 */
94#define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \
95do { unsigned long *dest = &(__elf_regs[0]); \
96 struct pt_regs *src = (__pt_regs); \
97 unsigned long __user *sp; \
98 int i; \
99 for(i = 0; i < 16; i++) \
100 dest[i] = src->u_regs[i]; \
101 /* Don't try this at home kids... */ \
102 sp = (unsigned long __user *) \
103 ((src->u_regs[14] + STACK_BIAS) \
104 & 0xfffffffffffffff8UL); \
105 for(i = 0; i < 16; i++) \
106 __get_user(dest[i+16], &sp[i]); \
107 dest[32] = src->tstate; \
108 dest[33] = src->tpc; \
109 dest[34] = src->tnpc; \
110 dest[35] = src->y; \
111} while (0);
112
113typedef struct {
114 unsigned long pr_regs[32];
115 unsigned long pr_fsr;
116 unsigned long pr_gsr;
117 unsigned long pr_fprs;
118} elf_fpregset_t;
119#endif
120
121#define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \
122 ({ ELF_CORE_COPY_REGS((*(__elf_regs)), (__tsk)->thread_info->kregs); 1; })
123
124/*
125 * This is used to ensure we don't load something for the wrong architecture.
126 */
127#ifndef elf_check_arch
128#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */
129#endif
130
131#define USE_ELF_CORE_DUMP
132#define ELF_EXEC_PAGESIZE PAGE_SIZE
133
134/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
135 use of this is to invoke "./ld.so someprog" to test out a new version of
136 the loader. We need to make sure that it is out of the way of the program
137 that it will "exec", and that there is sufficient room for the brk. */
138
139#ifndef ELF_ET_DYN_BASE
140#define ELF_ET_DYN_BASE 0x0000010000000000UL
141#endif
142
143
144/* This yields a mask that user programs can use to figure out what
145 instruction set this cpu supports. */
146
147/* On Ultra, we support all of the v8 capabilities. */
148#define ELF_HWCAP ((HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \
149 HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | \
150 HWCAP_SPARC_V9) | \
151 ((tlb_type == cheetah || tlb_type == cheetah_plus) ? \
152 HWCAP_SPARC_ULTRA3 : 0))
153
154/* This yields a string that ld.so will use to load implementation
155 specific libraries for optimization. This is more specific in
156 intent than poking at uname or /proc/cpuinfo. */
157
158#define ELF_PLATFORM (NULL)
159
160#ifdef __KERNEL__
161#define SET_PERSONALITY(ex, ibcs2) \
162do { unsigned long new_flags = current_thread_info()->flags; \
163 new_flags &= _TIF_32BIT; \
164 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
165 new_flags |= _TIF_32BIT; \
166 else \
167 new_flags &= ~_TIF_32BIT; \
168 if ((current_thread_info()->flags & _TIF_32BIT) \
169 != new_flags) \
170 set_thread_flag(TIF_ABI_PENDING); \
171 else \
172 clear_thread_flag(TIF_ABI_PENDING); \
173 /* flush_thread will update pgd cache */ \
174 if (ibcs2) \
175 set_personality(PER_SVR4); \
176 else if (current->personality != PER_LINUX32) \
177 set_personality(PER_LINUX); \
178} while (0)
179#endif
180
181#endif /* !(__ASM_SPARC64_ELF_H) */
diff --git a/include/asm-sparc64/envctrl.h b/include/asm-sparc64/envctrl.h
new file mode 100644
index 000000000000..53a6653815eb
--- /dev/null
+++ b/include/asm-sparc64/envctrl.h
@@ -0,0 +1,103 @@
1/* $Id: envctrl.h,v 1.3 2000/11/03 00:37:40 davem Exp $
2 *
3 * envctrl.h: Definitions for access to the i2c environment
4 * monitoring on Ultrasparc systems.
5 *
6 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
7 * Copyright (C) 2000 Vinh Truong (vinh.truong@eng.sun.com)
8 * VT - Add all ioctl commands and environment status definitions
9 * VT - Add application note
10 */
11#ifndef _SPARC64_ENVCTRL_H
12#define _SPARC64_ENVCTRL_H 1
13
14#include <linux/ioctl.h>
15
16/* Application note:
17 *
18 * The driver supports 4 operations: open(), close(), ioctl(), read()
19 * The device name is /dev/envctrl.
20 * Below is sample usage:
21 *
22 * fd = open("/dev/envtrl", O_RDONLY);
23 * if (ioctl(fd, ENVCTRL_READ_SHUTDOWN_TEMPERATURE, 0) < 0)
24 * printf("error\n");
25 * ret = read(fd, buf, 10);
26 * close(fd);
27 *
28 * Notice in the case of cpu voltage and temperature, the default is
29 * cpu0. If we need to know the info of cpu1, cpu2, cpu3, we need to
30 * pass in cpu number in ioctl() last parameter. For example, to
31 * get the voltage of cpu2:
32 *
33 * ioctlbuf[0] = 2;
34 * if (ioctl(fd, ENVCTRL_READ_CPU_VOLTAGE, ioctlbuf) < 0)
35 * printf("error\n");
36 * ret = read(fd, buf, 10);
37 *
38 * All the return values are in ascii. So check read return value
39 * and do appropriate conversions in your application.
40 */
41
42/* IOCTL commands */
43
44/* Note: these commands reflect possible monitor features.
45 * Some boards choose to support some of the features only.
46 */
47#define ENVCTRL_RD_CPU_TEMPERATURE _IOR('p', 0x40, int)
48#define ENVCTRL_RD_CPU_VOLTAGE _IOR('p', 0x41, int)
49#define ENVCTRL_RD_FAN_STATUS _IOR('p', 0x42, int)
50#define ENVCTRL_RD_WARNING_TEMPERATURE _IOR('p', 0x43, int)
51#define ENVCTRL_RD_SHUTDOWN_TEMPERATURE _IOR('p', 0x44, int)
52#define ENVCTRL_RD_VOLTAGE_STATUS _IOR('p', 0x45, int)
53#define ENVCTRL_RD_SCSI_TEMPERATURE _IOR('p', 0x46, int)
54#define ENVCTRL_RD_ETHERNET_TEMPERATURE _IOR('p', 0x47, int)
55#define ENVCTRL_RD_MTHRBD_TEMPERATURE _IOR('p', 0x48, int)
56
57#define ENVCTRL_RD_GLOBALADDRESS _IOR('p', 0x49, int)
58
59/* Read return values for a voltage status request. */
60#define ENVCTRL_VOLTAGE_POWERSUPPLY_GOOD 0x01
61#define ENVCTRL_VOLTAGE_BAD 0x02
62#define ENVCTRL_POWERSUPPLY_BAD 0x03
63#define ENVCTRL_VOLTAGE_POWERSUPPLY_BAD 0x04
64
65/* Read return values for a fan status request.
66 * A failure match means either the fan fails or
67 * the fan is not connected. Some boards have optional
68 * connectors to connect extra fans.
69 *
70 * There are maximum 8 monitor fans. Some are cpu fans
71 * some are system fans. The mask below only indicates
72 * fan by order number.
73 * Below is a sample application:
74 *
75 * if (ioctl(fd, ENVCTRL_READ_FAN_STATUS, 0) < 0) {
76 * printf("ioctl fan failed\n");
77 * }
78 * if (read(fd, rslt, 1) <= 0) {
79 * printf("error or fan not monitored\n");
80 * } else {
81 * if (rslt[0] == ENVCTRL_ALL_FANS_GOOD) {
82 * printf("all fans good\n");
83 * } else if (rslt[0] == ENVCTRL_ALL_FANS_BAD) {
84 * printf("all fans bad\n");
85 * } else {
86 * if (rslt[0] & ENVCTRL_FAN0_FAILURE_MASK) {
87 * printf("fan 0 failed or not connected\n");
88 * }
89 * ......
90 */
91
92#define ENVCTRL_ALL_FANS_GOOD 0x00
93#define ENVCTRL_FAN0_FAILURE_MASK 0x01
94#define ENVCTRL_FAN1_FAILURE_MASK 0x02
95#define ENVCTRL_FAN2_FAILURE_MASK 0x04
96#define ENVCTRL_FAN3_FAILURE_MASK 0x08
97#define ENVCTRL_FAN4_FAILURE_MASK 0x10
98#define ENVCTRL_FAN5_FAILURE_MASK 0x20
99#define ENVCTRL_FAN6_FAILURE_MASK 0x40
100#define ENVCTRL_FAN7_FAILURE_MASK 0x80
101#define ENVCTRL_ALL_FANS_BAD 0xFF
102
103#endif /* !(_SPARC64_ENVCTRL_H) */
diff --git a/include/asm-sparc64/errno.h b/include/asm-sparc64/errno.h
new file mode 100644
index 000000000000..cc98a73b55a7
--- /dev/null
+++ b/include/asm-sparc64/errno.h
@@ -0,0 +1,110 @@
1/* $Id: errno.h,v 1.2 1997/04/15 12:46:11 jj Exp $ */
2#ifndef _SPARC64_ERRNO_H
3#define _SPARC64_ERRNO_H
4
5/* These match the SunOS error numbering scheme. */
6
7#include <asm-generic/errno-base.h>
8
9#define EWOULDBLOCK EAGAIN /* Operation would block */
10#define EINPROGRESS 36 /* Operation now in progress */
11#define EALREADY 37 /* Operation already in progress */
12#define ENOTSOCK 38 /* Socket operation on non-socket */
13#define EDESTADDRREQ 39 /* Destination address required */
14#define EMSGSIZE 40 /* Message too long */
15#define EPROTOTYPE 41 /* Protocol wrong type for socket */
16#define ENOPROTOOPT 42 /* Protocol not available */
17#define EPROTONOSUPPORT 43 /* Protocol not supported */
18#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
19#define EOPNOTSUPP 45 /* Op not supported on transport endpoint */
20#define EPFNOSUPPORT 46 /* Protocol family not supported */
21#define EAFNOSUPPORT 47 /* Address family not supported by protocol */
22#define EADDRINUSE 48 /* Address already in use */
23#define EADDRNOTAVAIL 49 /* Cannot assign requested address */
24#define ENETDOWN 50 /* Network is down */
25#define ENETUNREACH 51 /* Network is unreachable */
26#define ENETRESET 52 /* Net dropped connection because of reset */
27#define ECONNABORTED 53 /* Software caused connection abort */
28#define ECONNRESET 54 /* Connection reset by peer */
29#define ENOBUFS 55 /* No buffer space available */
30#define EISCONN 56 /* Transport endpoint is already connected */
31#define ENOTCONN 57 /* Transport endpoint is not connected */
32#define ESHUTDOWN 58 /* No send after transport endpoint shutdown */
33#define ETOOMANYREFS 59 /* Too many references: cannot splice */
34#define ETIMEDOUT 60 /* Connection timed out */
35#define ECONNREFUSED 61 /* Connection refused */
36#define ELOOP 62 /* Too many symbolic links encountered */
37#define ENAMETOOLONG 63 /* File name too long */
38#define EHOSTDOWN 64 /* Host is down */
39#define EHOSTUNREACH 65 /* No route to host */
40#define ENOTEMPTY 66 /* Directory not empty */
41#define EPROCLIM 67 /* SUNOS: Too many processes */
42#define EUSERS 68 /* Too many users */
43#define EDQUOT 69 /* Quota exceeded */
44#define ESTALE 70 /* Stale NFS file handle */
45#define EREMOTE 71 /* Object is remote */
46#define ENOSTR 72 /* Device not a stream */
47#define ETIME 73 /* Timer expired */
48#define ENOSR 74 /* Out of streams resources */
49#define ENOMSG 75 /* No message of desired type */
50#define EBADMSG 76 /* Not a data message */
51#define EIDRM 77 /* Identifier removed */
52#define EDEADLK 78 /* Resource deadlock would occur */
53#define ENOLCK 79 /* No record locks available */
54#define ENONET 80 /* Machine is not on the network */
55#define ERREMOTE 81 /* SunOS: Too many lvls of remote in path */
56#define ENOLINK 82 /* Link has been severed */
57#define EADV 83 /* Advertise error */
58#define ESRMNT 84 /* Srmount error */
59#define ECOMM 85 /* Communication error on send */
60#define EPROTO 86 /* Protocol error */
61#define EMULTIHOP 87 /* Multihop attempted */
62#define EDOTDOT 88 /* RFS specific error */
63#define EREMCHG 89 /* Remote address changed */
64#define ENOSYS 90 /* Function not implemented */
65
66/* The rest have no SunOS equivalent. */
67#define ESTRPIPE 91 /* Streams pipe error */
68#define EOVERFLOW 92 /* Value too large for defined data type */
69#define EBADFD 93 /* File descriptor in bad state */
70#define ECHRNG 94 /* Channel number out of range */
71#define EL2NSYNC 95 /* Level 2 not synchronized */
72#define EL3HLT 96 /* Level 3 halted */
73#define EL3RST 97 /* Level 3 reset */
74#define ELNRNG 98 /* Link number out of range */
75#define EUNATCH 99 /* Protocol driver not attached */
76#define ENOCSI 100 /* No CSI structure available */
77#define EL2HLT 101 /* Level 2 halted */
78#define EBADE 102 /* Invalid exchange */
79#define EBADR 103 /* Invalid request descriptor */
80#define EXFULL 104 /* Exchange full */
81#define ENOANO 105 /* No anode */
82#define EBADRQC 106 /* Invalid request code */
83#define EBADSLT 107 /* Invalid slot */
84#define EDEADLOCK 108 /* File locking deadlock error */
85#define EBFONT 109 /* Bad font file format */
86#define ELIBEXEC 110 /* Cannot exec a shared library directly */
87#define ENODATA 111 /* No data available */
88#define ELIBBAD 112 /* Accessing a corrupted shared library */
89#define ENOPKG 113 /* Package not installed */
90#define ELIBACC 114 /* Can not access a needed shared library */
91#define ENOTUNIQ 115 /* Name not unique on network */
92#define ERESTART 116 /* Interrupted syscall should be restarted */
93#define EUCLEAN 117 /* Structure needs cleaning */
94#define ENOTNAM 118 /* Not a XENIX named type file */
95#define ENAVAIL 119 /* No XENIX semaphores available */
96#define EISNAM 120 /* Is a named type file */
97#define EREMOTEIO 121 /* Remote I/O error */
98#define EILSEQ 122 /* Illegal byte sequence */
99#define ELIBMAX 123 /* Atmpt to link in too many shared libs */
100#define ELIBSCN 124 /* .lib section in a.out corrupted */
101
102#define ENOMEDIUM 125 /* No medium found */
103#define EMEDIUMTYPE 126 /* Wrong medium type */
104#define ECANCELED 127 /* Operation Cancelled */
105#define ENOKEY 128 /* Required key not available */
106#define EKEYEXPIRED 129 /* Key has expired */
107#define EKEYREVOKED 130 /* Key has been revoked */
108#define EKEYREJECTED 131 /* Key was rejected by service */
109
110#endif /* !(_SPARC64_ERRNO_H) */
diff --git a/include/asm-sparc64/estate.h b/include/asm-sparc64/estate.h
new file mode 100644
index 000000000000..a719c3d2f6b1
--- /dev/null
+++ b/include/asm-sparc64/estate.h
@@ -0,0 +1,50 @@
1/* $Id: estate.h,v 1.1 2001/03/28 10:56:34 davem Exp $ */
2#ifndef _SPARC64_ESTATE_H
3#define _SPARC64_ESTATE_H
4
5/* UltraSPARC-III E-cache Error Enable */
6#define ESTATE_ERROR_FMT 0x0000000000040000 /* Force MTAG ECC */
7#define ESTATE_ERROR_FMESS 0x000000000003c000 /* Forced MTAG ECC val */
8#define ESTATE_ERROR_FMD 0x0000000000002000 /* Force DATA ECC */
9#define ESTATE_ERROR_FDECC 0x0000000000001ff0 /* Forced DATA ECC val */
10#define ESTATE_ERROR_UCEEN 0x0000000000000008 /* See below */
11#define ESTATE_ERROR_NCEEN 0x0000000000000002 /* See below */
12#define ESTATE_ERROR_CEEN 0x0000000000000001 /* See below */
13
14/* UCEEN enables the fast_ECC_error trap for: 1) software correctable E-cache
15 * errors 2) uncorrectable E-cache errors. Such events only occur on reads
16 * of the E-cache by the local processor for: 1) data loads 2) instruction
17 * fetches 3) atomic operations. Such events _cannot_ occur for: 1) merge
18 * 2) writeback 2) copyout. The AFSR bits associated with these traps are
19 * UCC and UCU.
20 */
21
22/* NCEEN enables instruction_access_error, data_access_error, and ECC_error traps
23 * for uncorrectable ECC errors and system errors.
24 *
25 * Uncorrectable system bus data error or MTAG ECC error, system bus TimeOUT,
26 * or system bus BusERR:
27 * 1) As the result of an instruction fetch, will generate instruction_access_error
28 * 2) As the result of a load etc. will generate data_access_error.
29 * 3) As the result of store merge completion, writeback, or copyout will
30 * generate a disrupting ECC_error trap.
31 * 4) As the result of such errors on instruction vector fetch can generate any
32 * of the 3 trap types.
33 *
34 * The AFSR bits associated with these traps are EMU, EDU, WDU, CPU, IVU, UE,
35 * BERR, and TO.
36 */
37
38/* CEEN enables the ECC_error trap for hardware corrected ECC errors. System bus
39 * reads resulting in a hardware corrected data or MTAG ECC error will generate an
40 * ECC_error disrupting trap with this bit enabled.
41 *
42 * This same trap will also be generated when a hardware corrected ECC error results
43 * during store merge, writeback, and copyout operations.
44 */
45
46/* In general, if the trap enable bits above are disabled the AFSR bits will still
47 * log the events even though the trap will not be generated by the processor.
48 */
49
50#endif /* _SPARC64_ESTATE_H */
diff --git a/include/asm-sparc64/fbio.h b/include/asm-sparc64/fbio.h
new file mode 100644
index 000000000000..500026d9f6e1
--- /dev/null
+++ b/include/asm-sparc64/fbio.h
@@ -0,0 +1,302 @@
1#ifndef __LINUX_FBIO_H
2#define __LINUX_FBIO_H
3
4#include <linux/compiler.h>
5
6/* Constants used for fbio SunOS compatibility */
7/* (C) 1996 Miguel de Icaza */
8
9/* Frame buffer types */
10#define FBTYPE_NOTYPE -1
11#define FBTYPE_SUN1BW 0 /* mono */
12#define FBTYPE_SUN1COLOR 1
13#define FBTYPE_SUN2BW 2
14#define FBTYPE_SUN2COLOR 3
15#define FBTYPE_SUN2GP 4
16#define FBTYPE_SUN5COLOR 5
17#define FBTYPE_SUN3COLOR 6
18#define FBTYPE_MEMCOLOR 7
19#define FBTYPE_SUN4COLOR 8
20
21#define FBTYPE_NOTSUN1 9
22#define FBTYPE_NOTSUN2 10
23#define FBTYPE_NOTSUN3 11
24
25#define FBTYPE_SUNFAST_COLOR 12 /* cg6 */
26#define FBTYPE_SUNROP_COLOR 13
27#define FBTYPE_SUNFB_VIDEO 14
28#define FBTYPE_SUNGIFB 15
29#define FBTYPE_SUNGPLAS 16
30#define FBTYPE_SUNGP3 17
31#define FBTYPE_SUNGT 18
32#define FBTYPE_SUNLEO 19 /* zx Leo card */
33#define FBTYPE_MDICOLOR 20 /* cg14 */
34#define FBTYPE_TCXCOLOR 21 /* SUNW,tcx card */
35
36#define FBTYPE_LASTPLUSONE 21 /* This is not last + 1 in fact... */
37
38/* Does not seem to be listed in the Sun file either */
39#define FBTYPE_CREATOR 22
40#define FBTYPE_PCI_IGA1682 23
41#define FBTYPE_P9100COLOR 24
42
43#define FBTYPE_PCI_GENERIC 1000
44#define FBTYPE_PCI_MACH64 1001
45
46/* fbio ioctls */
47/* Returned by FBIOGTYPE */
48struct fbtype {
49 int fb_type; /* fb type, see above */
50 int fb_height; /* pixels */
51 int fb_width; /* pixels */
52 int fb_depth;
53 int fb_cmsize; /* color map entries */
54 int fb_size; /* fb size in bytes */
55};
56#define FBIOGTYPE _IOR('F', 0, struct fbtype)
57
58struct fbcmap {
59 int index; /* first element (0 origin) */
60 int count;
61 unsigned char __user *red;
62 unsigned char __user *green;
63 unsigned char __user *blue;
64};
65
66#ifdef __KERNEL__
67#define FBIOPUTCMAP_SPARC _IOW('F', 3, struct fbcmap)
68#define FBIOGETCMAP_SPARC _IOW('F', 4, struct fbcmap)
69#else
70#define FBIOPUTCMAP _IOW('F', 3, struct fbcmap)
71#define FBIOGETCMAP _IOW('F', 4, struct fbcmap)
72#endif
73
74/* # of device specific values */
75#define FB_ATTR_NDEVSPECIFIC 8
76/* # of possible emulations */
77#define FB_ATTR_NEMUTYPES 4
78
79struct fbsattr {
80 int flags;
81 int emu_type; /* -1 if none */
82 int dev_specific[FB_ATTR_NDEVSPECIFIC];
83};
84
85struct fbgattr {
86 int real_type; /* real frame buffer type */
87 int owner; /* unknown */
88 struct fbtype fbtype; /* real frame buffer fbtype */
89 struct fbsattr sattr;
90 int emu_types[FB_ATTR_NEMUTYPES]; /* supported emulations */
91};
92#define FBIOSATTR _IOW('F', 5, struct fbgattr) /* Unsupported: */
93#define FBIOGATTR _IOR('F', 6, struct fbgattr) /* supported */
94
95#define FBIOSVIDEO _IOW('F', 7, int)
96#define FBIOGVIDEO _IOR('F', 8, int)
97
98struct fbcursor {
99 short set; /* what to set, choose from the list above */
100 short enable; /* cursor on/off */
101 struct fbcurpos pos; /* cursor position */
102 struct fbcurpos hot; /* cursor hot spot */
103 struct fbcmap cmap; /* color map info */
104 struct fbcurpos size; /* cursor bit map size */
105 char __user *image; /* cursor image bits */
106 char __user *mask; /* cursor mask bits */
107};
108
109/* set/get cursor attributes/shape */
110#define FBIOSCURSOR _IOW('F', 24, struct fbcursor)
111#define FBIOGCURSOR _IOWR('F', 25, struct fbcursor)
112
113/* set/get cursor position */
114#define FBIOSCURPOS _IOW('F', 26, struct fbcurpos)
115#define FBIOGCURPOS _IOW('F', 27, struct fbcurpos)
116
117/* get max cursor size */
118#define FBIOGCURMAX _IOR('F', 28, struct fbcurpos)
119
120/* wid manipulation */
121struct fb_wid_alloc {
122#define FB_WID_SHARED_8 0
123#define FB_WID_SHARED_24 1
124#define FB_WID_DBL_8 2
125#define FB_WID_DBL_24 3
126 __u32 wa_type;
127 __s32 wa_index; /* Set on return */
128 __u32 wa_count;
129};
130struct fb_wid_item {
131 __u32 wi_type;
132 __s32 wi_index;
133 __u32 wi_attrs;
134 __u32 wi_values[32];
135};
136struct fb_wid_list {
137 __u32 wl_flags;
138 __u32 wl_count;
139 struct fb_wid_item *wl_list;
140};
141
142#define FBIO_WID_ALLOC _IOWR('F', 30, struct fb_wid_alloc)
143#define FBIO_WID_FREE _IOW('F', 31, struct fb_wid_alloc)
144#define FBIO_WID_PUT _IOW('F', 32, struct fb_wid_list)
145#define FBIO_WID_GET _IOWR('F', 33, struct fb_wid_list)
146
147/* Creator ioctls */
148#define FFB_IOCTL ('F'<<8)
149#define FFB_SYS_INFO (FFB_IOCTL|80)
150#define FFB_CLUTREAD (FFB_IOCTL|81)
151#define FFB_CLUTPOST (FFB_IOCTL|82)
152#define FFB_SETDIAGMODE (FFB_IOCTL|83)
153#define FFB_GETMONITORID (FFB_IOCTL|84)
154#define FFB_GETVIDEOMODE (FFB_IOCTL|85)
155#define FFB_SETVIDEOMODE (FFB_IOCTL|86)
156#define FFB_SETSERVER (FFB_IOCTL|87)
157#define FFB_SETOVCTL (FFB_IOCTL|88)
158#define FFB_GETOVCTL (FFB_IOCTL|89)
159#define FFB_GETSAXNUM (FFB_IOCTL|90)
160#define FFB_FBDEBUG (FFB_IOCTL|91)
161
162/* Cg14 ioctls */
163#define MDI_IOCTL ('M'<<8)
164#define MDI_RESET (MDI_IOCTL|1)
165#define MDI_GET_CFGINFO (MDI_IOCTL|2)
166#define MDI_SET_PIXELMODE (MDI_IOCTL|3)
167# define MDI_32_PIX 32
168# define MDI_16_PIX 16
169# define MDI_8_PIX 8
170
171struct mdi_cfginfo {
172 int mdi_ncluts; /* Number of implemented CLUTs in this MDI */
173 int mdi_type; /* FBTYPE name */
174 int mdi_height; /* height */
175 int mdi_width; /* widht */
176 int mdi_size; /* available ram */
177 int mdi_mode; /* 8bpp, 16bpp or 32bpp */
178 int mdi_pixfreq; /* pixel clock (from PROM) */
179};
180
181/* SparcLinux specific ioctl for the MDI, should be replaced for
182 * the SET_XLUT/SET_CLUTn ioctls instead
183 */
184#define MDI_CLEAR_XLUT (MDI_IOCTL|9)
185
186/* leo & ffb ioctls */
187struct fb_clut_alloc {
188 __u32 clutid; /* Set on return */
189 __u32 flag;
190 __u32 index;
191};
192
193struct fb_clut {
194#define FB_CLUT_WAIT 0x00000001 /* Not yet implemented */
195 __u32 flag;
196 __u32 clutid;
197 __u32 offset;
198 __u32 count;
199 char * red;
200 char * green;
201 char * blue;
202};
203
204struct fb_clut32 {
205 __u32 flag;
206 __u32 clutid;
207 __u32 offset;
208 __u32 count;
209 __u32 red;
210 __u32 green;
211 __u32 blue;
212};
213
214#define LEO_CLUTALLOC _IOWR('L', 53, struct fb_clut_alloc)
215#define LEO_CLUTFREE _IOW('L', 54, struct fb_clut_alloc)
216#define LEO_CLUTREAD _IOW('L', 55, struct fb_clut)
217#define LEO_CLUTPOST _IOW('L', 56, struct fb_clut)
218#define LEO_SETGAMMA _IOW('L', 68, int) /* Not yet implemented */
219#define LEO_GETGAMMA _IOR('L', 69, int) /* Not yet implemented */
220
221#ifdef __KERNEL__
222/* Addresses on the fd of a cgsix that are mappable */
223#define CG6_FBC 0x70000000
224#define CG6_TEC 0x70001000
225#define CG6_BTREGS 0x70002000
226#define CG6_FHC 0x70004000
227#define CG6_THC 0x70005000
228#define CG6_ROM 0x70006000
229#define CG6_RAM 0x70016000
230#define CG6_DHC 0x80000000
231
232#define CG3_MMAP_OFFSET 0x4000000
233
234/* Addresses on the fd of a tcx that are mappable */
235#define TCX_RAM8BIT 0x00000000
236#define TCX_RAM24BIT 0x01000000
237#define TCX_UNK3 0x10000000
238#define TCX_UNK4 0x20000000
239#define TCX_CONTROLPLANE 0x28000000
240#define TCX_UNK6 0x30000000
241#define TCX_UNK7 0x38000000
242#define TCX_TEC 0x70000000
243#define TCX_BTREGS 0x70002000
244#define TCX_THC 0x70004000
245#define TCX_DHC 0x70008000
246#define TCX_ALT 0x7000a000
247#define TCX_SYNC 0x7000e000
248#define TCX_UNK2 0x70010000
249
250/* CG14 definitions */
251
252/* Offsets into the OBIO space: */
253#define CG14_REGS 0 /* registers */
254#define CG14_CURSORREGS 0x1000 /* cursor registers */
255#define CG14_DACREGS 0x2000 /* DAC registers */
256#define CG14_XLUT 0x3000 /* X Look Up Table -- ??? */
257#define CG14_CLUT1 0x4000 /* Color Look Up Table */
258#define CG14_CLUT2 0x5000 /* Color Look Up Table */
259#define CG14_CLUT3 0x6000 /* Color Look Up Table */
260#define CG14_AUTO 0xf000
261
262#endif /* KERNEL */
263
264/* These are exported to userland for applications to use */
265/* Mappable offsets for the cg14: control registers */
266#define MDI_DIRECT_MAP 0x10000000
267#define MDI_CTLREG_MAP 0x20000000
268#define MDI_CURSOR_MAP 0x30000000
269#define MDI_SHDW_VRT_MAP 0x40000000
270
271/* Mappable offsets for the cg14: frame buffer resolutions */
272/* 32 bits */
273#define MDI_CHUNKY_XBGR_MAP 0x50000000
274#define MDI_CHUNKY_BGR_MAP 0x60000000
275
276/* 16 bits */
277#define MDI_PLANAR_X16_MAP 0x70000000
278#define MDI_PLANAR_C16_MAP 0x80000000
279
280/* 8 bit is done as CG3 MMAP offset */
281/* 32 bits, planar */
282#define MDI_PLANAR_X32_MAP 0x90000000
283#define MDI_PLANAR_B32_MAP 0xa0000000
284#define MDI_PLANAR_G32_MAP 0xb0000000
285#define MDI_PLANAR_R32_MAP 0xc0000000
286
287/* Mappable offsets on leo */
288#define LEO_SS0_MAP 0x00000000
289#define LEO_LC_SS0_USR_MAP 0x00800000
290#define LEO_LD_SS0_MAP 0x00801000
291#define LEO_LX_CURSOR_MAP 0x00802000
292#define LEO_SS1_MAP 0x00803000
293#define LEO_LC_SS1_USR_MAP 0x01003000
294#define LEO_LD_SS1_MAP 0x01004000
295#define LEO_UNK_MAP 0x01005000
296#define LEO_LX_KRN_MAP 0x01006000
297#define LEO_LC_SS0_KRN_MAP 0x01007000
298#define LEO_LC_SS1_KRN_MAP 0x01008000
299#define LEO_LD_GBL_MAP 0x01009000
300#define LEO_UNK2_MAP 0x0100a000
301
302#endif /* __LINUX_FBIO_H */
diff --git a/include/asm-sparc64/fcntl.h b/include/asm-sparc64/fcntl.h
new file mode 100644
index 000000000000..e36def0d0d80
--- /dev/null
+++ b/include/asm-sparc64/fcntl.h
@@ -0,0 +1,78 @@
1/* $Id: fcntl.h,v 1.12 2001/09/20 00:35:34 davem Exp $ */
2#ifndef _SPARC64_FCNTL_H
3#define _SPARC64_FCNTL_H
4
5/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
6 located on an ext2 file system */
7#define O_RDONLY 0x0000
8#define O_WRONLY 0x0001
9#define O_RDWR 0x0002
10#define O_ACCMODE 0x0003
11#define O_NDELAY 0x0004
12#define O_APPEND 0x0008
13#define FASYNC 0x0040 /* fcntl, for BSD compatibility */
14#define O_CREAT 0x0200 /* not fcntl */
15#define O_TRUNC 0x0400 /* not fcntl */
16#define O_EXCL 0x0800 /* not fcntl */
17#define O_SYNC 0x2000
18#define O_NONBLOCK 0x4000
19#define O_NOCTTY 0x8000 /* not fcntl */
20#define O_DIRECTORY 0x10000 /* must be a directory */
21#define O_NOFOLLOW 0x20000 /* don't follow links */
22#define O_LARGEFILE 0x40000
23#define O_DIRECT 0x100000 /* direct disk access hint */
24#define O_NOATIME 0x200000
25
26
27#define F_DUPFD 0 /* dup */
28#define F_GETFD 1 /* get close_on_exec */
29#define F_SETFD 2 /* set/clear close_on_exec */
30#define F_GETFL 3 /* get file->f_flags */
31#define F_SETFL 4 /* set file->f_flags */
32#define F_GETOWN 5 /* for sockets. */
33#define F_SETOWN 6 /* for sockets. */
34#define F_GETLK 7
35#define F_SETLK 8
36#define F_SETLKW 9
37#define F_SETSIG 10 /* for sockets. */
38#define F_GETSIG 11 /* for sockets. */
39
40/* for F_[GET|SET]FL */
41#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
42
43/* for posix fcntl() and lockf() */
44#define F_RDLCK 1
45#define F_WRLCK 2
46#define F_UNLCK 3
47
48/* for old implementation of bsd flock () */
49#define F_EXLCK 4 /* or 3 */
50#define F_SHLCK 8 /* or 4 */
51
52/* for leases */
53#define F_INPROGRESS 16
54
55/* operations for bsd flock(), also used by the kernel implementation */
56#define LOCK_SH 1 /* shared lock */
57#define LOCK_EX 2 /* exclusive lock */
58#define LOCK_NB 4 /* or'd with one of the above to prevent
59 blocking */
60#define LOCK_UN 8 /* remove lock */
61
62#define LOCK_MAND 32 /* This is a mandatory flock */
63#define LOCK_READ 64 /* ... Which allows concurrent read operations */
64#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
65#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
66
67struct flock {
68 short l_type;
69 short l_whence;
70 off_t l_start;
71 off_t l_len;
72 pid_t l_pid;
73 short __unused;
74};
75
76#define F_LINUX_SPECIFIC_BASE 1024
77
78#endif /* !(_SPARC64_FCNTL_H) */
diff --git a/include/asm-sparc64/fhc.h b/include/asm-sparc64/fhc.h
new file mode 100644
index 000000000000..f29eaa254055
--- /dev/null
+++ b/include/asm-sparc64/fhc.h
@@ -0,0 +1,132 @@
1/* $Id: fhc.h,v 1.5 1999/09/21 14:39:29 davem Exp $
2 * fhc.h: Structures for central/fhc pseudo driver on Sunfire/Starfire/Wildfire.
3 *
4 * Copyright (C) 1997, 1999 David S. Miller (davem@redhat.com)
5 */
6
7#ifndef _SPARC64_FHC_H
8#define _SPARC64_FHC_H
9
10#include <linux/timer.h>
11
12#include <asm/oplib.h>
13#include <asm/upa.h>
14
15struct linux_fhc;
16
17/* Clock board register offsets. */
18#define CLOCK_CTRL 0x00UL /* Main control */
19#define CLOCK_STAT1 0x10UL /* Status one */
20#define CLOCK_STAT2 0x20UL /* Status two */
21#define CLOCK_PWRSTAT 0x30UL /* Power status */
22#define CLOCK_PWRPRES 0x40UL /* Power presence */
23#define CLOCK_TEMP 0x50UL /* Temperature */
24#define CLOCK_IRQDIAG 0x60UL /* IRQ diagnostics */
25#define CLOCK_PWRSTAT2 0x70UL /* Power status two */
26
27#define CLOCK_CTRL_LLED 0x04 /* Left LED, 0 == on */
28#define CLOCK_CTRL_MLED 0x02 /* Mid LED, 1 == on */
29#define CLOCK_CTRL_RLED 0x01 /* RIght LED, 1 == on */
30
31struct linux_central {
32 struct linux_fhc *child;
33 unsigned long cfreg;
34 unsigned long clkregs;
35 unsigned long clkver;
36 int slots;
37 int prom_node;
38 char prom_name[64];
39
40 struct linux_prom_ranges central_ranges[PROMREG_MAX];
41 int num_central_ranges;
42};
43
44/* Firehose controller register offsets */
45struct fhc_regs {
46 unsigned long pregs; /* FHC internal regs */
47#define FHC_PREGS_ID 0x00UL /* FHC ID */
48#define FHC_ID_VERS 0xf0000000 /* Version of this FHC */
49#define FHC_ID_PARTID 0x0ffff000 /* Part ID code (0x0f9f == FHC) */
50#define FHC_ID_MANUF 0x0000007e /* Manufacturer (0x3e == SUN's JEDEC)*/
51#define FHC_ID_RESV 0x00000001 /* Read as one */
52#define FHC_PREGS_RCS 0x10UL /* FHC Reset Control/Status Register */
53#define FHC_RCS_POR 0x80000000 /* Last reset was a power cycle */
54#define FHC_RCS_SPOR 0x40000000 /* Last reset was sw power on reset */
55#define FHC_RCS_SXIR 0x20000000 /* Last reset was sw XIR reset */
56#define FHC_RCS_BPOR 0x10000000 /* Last reset was due to POR button */
57#define FHC_RCS_BXIR 0x08000000 /* Last reset was due to XIR button */
58#define FHC_RCS_WEVENT 0x04000000 /* CPU reset was due to wakeup event */
59#define FHC_RCS_CFATAL 0x02000000 /* Centerplane Fatal Error signalled */
60#define FHC_RCS_FENAB 0x01000000 /* Fatal errors elicit system reset */
61#define FHC_PREGS_CTRL 0x20UL /* FHC Control Register */
62#define FHC_CONTROL_ICS 0x00100000 /* Ignore Centerplane Signals */
63#define FHC_CONTROL_FRST 0x00080000 /* Fatal Error Reset Enable */
64#define FHC_CONTROL_LFAT 0x00040000 /* AC/DC signalled a local error */
65#define FHC_CONTROL_SLINE 0x00010000 /* Firmware Synchronization Line */
66#define FHC_CONTROL_DCD 0x00008000 /* DC-->DC Converter Disable */
67#define FHC_CONTROL_POFF 0x00004000 /* AC/DC Controller PLL Disable */
68#define FHC_CONTROL_FOFF 0x00002000 /* FHC Controller PLL Disable */
69#define FHC_CONTROL_AOFF 0x00001000 /* CPU A SRAM/SBD Low Power Mode */
70#define FHC_CONTROL_BOFF 0x00000800 /* CPU B SRAM/SBD Low Power Mode */
71#define FHC_CONTROL_PSOFF 0x00000400 /* Turns off this FHC's power supply */
72#define FHC_CONTROL_IXIST 0x00000200 /* 0=FHC tells clock board it exists */
73#define FHC_CONTROL_XMSTR 0x00000100 /* 1=Causes this FHC to be XIR master*/
74#define FHC_CONTROL_LLED 0x00000040 /* 0=Left LED ON */
75#define FHC_CONTROL_MLED 0x00000020 /* 1=Middle LED ON */
76#define FHC_CONTROL_RLED 0x00000010 /* 1=Right LED */
77#define FHC_CONTROL_BPINS 0x00000003 /* Spare Bidirectional Pins */
78#define FHC_PREGS_BSR 0x30UL /* FHC Board Status Register */
79#define FHC_BSR_DA64 0x00040000 /* Port A: 0=128bit 1=64bit data path */
80#define FHC_BSR_DB64 0x00020000 /* Port B: 0=128bit 1=64bit data path */
81#define FHC_BSR_BID 0x0001e000 /* Board ID */
82#define FHC_BSR_SA 0x00001c00 /* Port A UPA Speed (from the pins) */
83#define FHC_BSR_SB 0x00000380 /* Port B UPA Speed (from the pins) */
84#define FHC_BSR_NDIAG 0x00000040 /* Not in Diag Mode */
85#define FHC_BSR_NTBED 0x00000020 /* Not in TestBED Mode */
86#define FHC_BSR_NIA 0x0000001c /* Jumper, bit 18 in PROM space */
87#define FHC_BSR_SI 0x00000001 /* Spare input pin value */
88#define FHC_PREGS_ECC 0x40UL /* FHC ECC Control Register (16 bits) */
89#define FHC_PREGS_JCTRL 0xf0UL /* FHC JTAG Control Register */
90#define FHC_JTAG_CTRL_MENAB 0x80000000 /* Indicates this is JTAG Master */
91#define FHC_JTAG_CTRL_MNONE 0x40000000 /* Indicates no JTAG Master present */
92#define FHC_PREGS_JCMD 0x100UL /* FHC JTAG Command Register */
93 unsigned long ireg; /* FHC IGN reg */
94#define FHC_IREG_IGN 0x00UL /* This FHC's IGN */
95 unsigned long ffregs; /* FHC fanfail regs */
96#define FHC_FFREGS_IMAP 0x00UL /* FHC Fanfail IMAP */
97#define FHC_FFREGS_ICLR 0x10UL /* FHC Fanfail ICLR */
98 unsigned long sregs; /* FHC system regs */
99#define FHC_SREGS_IMAP 0x00UL /* FHC System IMAP */
100#define FHC_SREGS_ICLR 0x10UL /* FHC System ICLR */
101 unsigned long uregs; /* FHC uart regs */
102#define FHC_UREGS_IMAP 0x00UL /* FHC Uart IMAP */
103#define FHC_UREGS_ICLR 0x10UL /* FHC Uart ICLR */
104 unsigned long tregs; /* FHC TOD regs */
105#define FHC_TREGS_IMAP 0x00UL /* FHC TOD IMAP */
106#define FHC_TREGS_ICLR 0x10UL /* FHC TOD ICLR */
107};
108
109struct linux_fhc {
110 struct linux_fhc *next;
111 struct linux_central *parent; /* NULL if not central FHC */
112 struct fhc_regs fhc_regs;
113 int board;
114 int jtag_master;
115 int prom_node;
116 char prom_name[64];
117
118 struct linux_prom_ranges fhc_ranges[PROMREG_MAX];
119 int num_fhc_ranges;
120};
121
122extern struct linux_central *central_bus;
123
124extern void apply_central_ranges(struct linux_central *central,
125 struct linux_prom_registers *regs,
126 int nregs);
127
128extern void apply_fhc_ranges(struct linux_fhc *fhc,
129 struct linux_prom_registers *regs,
130 int nregs);
131
132#endif /* !(_SPARC64_FHC_H) */
diff --git a/include/asm-sparc64/floppy.h b/include/asm-sparc64/floppy.h
new file mode 100644
index 000000000000..e071b4b4edfd
--- /dev/null
+++ b/include/asm-sparc64/floppy.h
@@ -0,0 +1,811 @@
1/* $Id: floppy.h,v 1.32 2001/10/26 17:59:36 davem Exp $
2 * asm-sparc64/floppy.h: Sparc specific parts of the Floppy driver.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 *
7 * Ultra/PCI support added: Sep 1997 Eddie C. Dost (ecd@skynet.be)
8 */
9
10#ifndef __ASM_SPARC64_FLOPPY_H
11#define __ASM_SPARC64_FLOPPY_H
12
13#include <linux/config.h>
14#include <linux/init.h>
15
16#include <asm/page.h>
17#include <asm/pgtable.h>
18#include <asm/system.h>
19#include <asm/idprom.h>
20#include <asm/oplib.h>
21#include <asm/auxio.h>
22#include <asm/sbus.h>
23#include <asm/irq.h>
24
25
26/*
27 * Define this to enable exchanging drive 0 and 1 if only drive 1 is
28 * probed on PCI machines.
29 */
30#undef PCI_FDC_SWAP_DRIVES
31
32
33/* References:
34 * 1) Netbsd Sun floppy driver.
35 * 2) NCR 82077 controller manual
36 * 3) Intel 82077 controller manual
37 */
38struct sun_flpy_controller {
39 volatile unsigned char status1_82077; /* Auxiliary Status reg. 1 */
40 volatile unsigned char status2_82077; /* Auxiliary Status reg. 2 */
41 volatile unsigned char dor_82077; /* Digital Output reg. */
42 volatile unsigned char tapectl_82077; /* Tape Control reg */
43 volatile unsigned char status_82077; /* Main Status Register. */
44#define drs_82077 status_82077 /* Digital Rate Select reg. */
45 volatile unsigned char data_82077; /* Data fifo. */
46 volatile unsigned char ___unused;
47 volatile unsigned char dir_82077; /* Digital Input reg. */
48#define dcr_82077 dir_82077 /* Config Control reg. */
49};
50
51/* You'll only ever find one controller on an Ultra anyways. */
52static struct sun_flpy_controller *sun_fdc = (struct sun_flpy_controller *)-1;
53unsigned long fdc_status;
54static struct sbus_dev *floppy_sdev = NULL;
55
56struct sun_floppy_ops {
57 unsigned char (*fd_inb) (unsigned long port);
58 void (*fd_outb) (unsigned char value, unsigned long port);
59 void (*fd_enable_dma) (void);
60 void (*fd_disable_dma) (void);
61 void (*fd_set_dma_mode) (int);
62 void (*fd_set_dma_addr) (char *);
63 void (*fd_set_dma_count) (int);
64 unsigned int (*get_dma_residue) (void);
65 int (*fd_request_irq) (void);
66 void (*fd_free_irq) (void);
67 int (*fd_eject) (int);
68};
69
70static struct sun_floppy_ops sun_fdops;
71
72#define fd_inb(port) sun_fdops.fd_inb(port)
73#define fd_outb(value,port) sun_fdops.fd_outb(value,port)
74#define fd_enable_dma() sun_fdops.fd_enable_dma()
75#define fd_disable_dma() sun_fdops.fd_disable_dma()
76#define fd_request_dma() (0) /* nothing... */
77#define fd_free_dma() /* nothing... */
78#define fd_clear_dma_ff() /* nothing... */
79#define fd_set_dma_mode(mode) sun_fdops.fd_set_dma_mode(mode)
80#define fd_set_dma_addr(addr) sun_fdops.fd_set_dma_addr(addr)
81#define fd_set_dma_count(count) sun_fdops.fd_set_dma_count(count)
82#define get_dma_residue(x) sun_fdops.get_dma_residue()
83#define fd_cacheflush(addr, size) /* nothing... */
84#define fd_request_irq() sun_fdops.fd_request_irq()
85#define fd_free_irq() sun_fdops.fd_free_irq()
86#define fd_eject(drive) sun_fdops.fd_eject(drive)
87
88static int FLOPPY_MOTOR_MASK = 0x10;
89
90/* Super paranoid... */
91#undef HAVE_DISABLE_HLT
92
93static int sun_floppy_types[2] = { 0, 0 };
94
95/* Here is where we catch the floppy driver trying to initialize,
96 * therefore this is where we call the PROM device tree probing
97 * routine etc. on the Sparc.
98 */
99#define FLOPPY0_TYPE sun_floppy_init()
100#define FLOPPY1_TYPE sun_floppy_types[1]
101
102#define FDC1 ((unsigned long)sun_fdc)
103
104#define N_FDC 1
105#define N_DRIVE 8
106
107/* No 64k boundary crossing problems on the Sparc. */
108#define CROSS_64KB(a,s) (0)
109
110static unsigned char sun_82077_fd_inb(unsigned long port)
111{
112 udelay(5);
113 switch(port & 7) {
114 default:
115 printk("floppy: Asked to read unknown port %lx\n", port);
116 panic("floppy: Port bolixed.");
117 case 4: /* FD_STATUS */
118 return sbus_readb(&sun_fdc->status_82077) & ~STATUS_DMA;
119 case 5: /* FD_DATA */
120 return sbus_readb(&sun_fdc->data_82077);
121 case 7: /* FD_DIR */
122 /* XXX: Is DCL on 0x80 in sun4m? */
123 return sbus_readb(&sun_fdc->dir_82077);
124 };
125 panic("sun_82072_fd_inb: How did I get here?");
126}
127
128static void sun_82077_fd_outb(unsigned char value, unsigned long port)
129{
130 udelay(5);
131 switch(port & 7) {
132 default:
133 printk("floppy: Asked to write to unknown port %lx\n", port);
134 panic("floppy: Port bolixed.");
135 case 2: /* FD_DOR */
136 /* Happily, the 82077 has a real DOR register. */
137 sbus_writeb(value, &sun_fdc->dor_82077);
138 break;
139 case 5: /* FD_DATA */
140 sbus_writeb(value, &sun_fdc->data_82077);
141 break;
142 case 7: /* FD_DCR */
143 sbus_writeb(value, &sun_fdc->dcr_82077);
144 break;
145 case 4: /* FD_STATUS */
146 sbus_writeb(value, &sun_fdc->status_82077);
147 break;
148 };
149 return;
150}
151
152/* For pseudo-dma (Sun floppy drives have no real DMA available to
153 * them so we must eat the data fifo bytes directly ourselves) we have
154 * three state variables. doing_pdma tells our inline low-level
155 * assembly floppy interrupt entry point whether it should sit and eat
156 * bytes from the fifo or just transfer control up to the higher level
157 * floppy interrupt c-code. I tried very hard but I could not get the
158 * pseudo-dma to work in c-code without getting many overruns and
159 * underruns. If non-zero, doing_pdma encodes the direction of
160 * the transfer for debugging. 1=read 2=write
161 */
162char *pdma_vaddr;
163unsigned long pdma_size;
164volatile int doing_pdma = 0;
165
166/* This is software state */
167char *pdma_base = NULL;
168unsigned long pdma_areasize;
169
170/* Common routines to all controller types on the Sparc. */
171static void sun_fd_disable_dma(void)
172{
173 doing_pdma = 0;
174 if (pdma_base) {
175 mmu_unlockarea(pdma_base, pdma_areasize);
176 pdma_base = NULL;
177 }
178}
179
180static void sun_fd_set_dma_mode(int mode)
181{
182 switch(mode) {
183 case DMA_MODE_READ:
184 doing_pdma = 1;
185 break;
186 case DMA_MODE_WRITE:
187 doing_pdma = 2;
188 break;
189 default:
190 printk("Unknown dma mode %d\n", mode);
191 panic("floppy: Giving up...");
192 }
193}
194
195static void sun_fd_set_dma_addr(char *buffer)
196{
197 pdma_vaddr = buffer;
198}
199
200static void sun_fd_set_dma_count(int length)
201{
202 pdma_size = length;
203}
204
205static void sun_fd_enable_dma(void)
206{
207 pdma_vaddr = mmu_lockarea(pdma_vaddr, pdma_size);
208 pdma_base = pdma_vaddr;
209 pdma_areasize = pdma_size;
210}
211
212/* Our low-level entry point in arch/sparc/kernel/entry.S */
213extern irqreturn_t floppy_hardint(int irq, void *unused, struct pt_regs *regs);
214
215static int sun_fd_request_irq(void)
216{
217 static int once = 0;
218 int error;
219
220 if(!once) {
221 once = 1;
222
223 error = request_fast_irq(FLOPPY_IRQ, floppy_hardint,
224 SA_INTERRUPT, "floppy", NULL);
225
226 return ((error == 0) ? 0 : -1);
227 }
228 return 0;
229}
230
231static void sun_fd_free_irq(void)
232{
233}
234
235static unsigned int sun_get_dma_residue(void)
236{
237 /* XXX This isn't really correct. XXX */
238 return 0;
239}
240
241static int sun_fd_eject(int drive)
242{
243 set_dor(0x00, 0xff, 0x90);
244 udelay(500);
245 set_dor(0x00, 0x6f, 0x00);
246 udelay(500);
247 return 0;
248}
249
250#ifdef CONFIG_PCI
251#include <asm/ebus.h>
252#include <asm/isa.h>
253#include <asm/ns87303.h>
254
255static struct ebus_dma_info sun_pci_fd_ebus_dma;
256static struct pci_dev *sun_pci_ebus_dev;
257static int sun_pci_broken_drive = -1;
258
259struct sun_pci_dma_op {
260 unsigned int addr;
261 int len;
262 int direction;
263 char *buf;
264};
265static struct sun_pci_dma_op sun_pci_dma_current = { -1U, 0, 0, NULL};
266static struct sun_pci_dma_op sun_pci_dma_pending = { -1U, 0, 0, NULL};
267
268extern irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs *regs);
269
270static unsigned char sun_pci_fd_inb(unsigned long port)
271{
272 udelay(5);
273 return inb(port);
274}
275
276static void sun_pci_fd_outb(unsigned char val, unsigned long port)
277{
278 udelay(5);
279 outb(val, port);
280}
281
282static void sun_pci_fd_broken_outb(unsigned char val, unsigned long port)
283{
284 udelay(5);
285 /*
286 * XXX: Due to SUN's broken floppy connector on AX and AXi
287 * we need to turn on MOTOR_0 also, if the floppy is
288 * jumpered to DS1 (like most PC floppies are). I hope
289 * this does not hurt correct hardware like the AXmp.
290 * (Eddie, Sep 12 1998).
291 */
292 if (port == ((unsigned long)sun_fdc) + 2) {
293 if (((val & 0x03) == sun_pci_broken_drive) && (val & 0x20)) {
294 val |= 0x10;
295 }
296 }
297 outb(val, port);
298}
299
300#ifdef PCI_FDC_SWAP_DRIVES
301static void sun_pci_fd_lde_broken_outb(unsigned char val, unsigned long port)
302{
303 udelay(5);
304 /*
305 * XXX: Due to SUN's broken floppy connector on AX and AXi
306 * we need to turn on MOTOR_0 also, if the floppy is
307 * jumpered to DS1 (like most PC floppies are). I hope
308 * this does not hurt correct hardware like the AXmp.
309 * (Eddie, Sep 12 1998).
310 */
311 if (port == ((unsigned long)sun_fdc) + 2) {
312 if (((val & 0x03) == sun_pci_broken_drive) && (val & 0x10)) {
313 val &= ~(0x03);
314 val |= 0x21;
315 }
316 }
317 outb(val, port);
318}
319#endif /* PCI_FDC_SWAP_DRIVES */
320
321static void sun_pci_fd_enable_dma(void)
322{
323 BUG_ON((NULL == sun_pci_dma_pending.buf) ||
324 (0 == sun_pci_dma_pending.len) ||
325 (0 == sun_pci_dma_pending.direction));
326
327 sun_pci_dma_current.buf = sun_pci_dma_pending.buf;
328 sun_pci_dma_current.len = sun_pci_dma_pending.len;
329 sun_pci_dma_current.direction = sun_pci_dma_pending.direction;
330
331 sun_pci_dma_pending.buf = NULL;
332 sun_pci_dma_pending.len = 0;
333 sun_pci_dma_pending.direction = 0;
334 sun_pci_dma_pending.addr = -1U;
335
336 sun_pci_dma_current.addr =
337 pci_map_single(sun_pci_ebus_dev,
338 sun_pci_dma_current.buf,
339 sun_pci_dma_current.len,
340 sun_pci_dma_current.direction);
341
342 ebus_dma_enable(&sun_pci_fd_ebus_dma, 1);
343
344 if (ebus_dma_request(&sun_pci_fd_ebus_dma,
345 sun_pci_dma_current.addr,
346 sun_pci_dma_current.len))
347 BUG();
348}
349
350static void sun_pci_fd_disable_dma(void)
351{
352 ebus_dma_enable(&sun_pci_fd_ebus_dma, 0);
353 if (sun_pci_dma_current.addr != -1U)
354 pci_unmap_single(sun_pci_ebus_dev,
355 sun_pci_dma_current.addr,
356 sun_pci_dma_current.len,
357 sun_pci_dma_current.direction);
358 sun_pci_dma_current.addr = -1U;
359}
360
361static void sun_pci_fd_set_dma_mode(int mode)
362{
363 if (mode == DMA_MODE_WRITE)
364 sun_pci_dma_pending.direction = PCI_DMA_TODEVICE;
365 else
366 sun_pci_dma_pending.direction = PCI_DMA_FROMDEVICE;
367
368 ebus_dma_prepare(&sun_pci_fd_ebus_dma, mode != DMA_MODE_WRITE);
369}
370
371static void sun_pci_fd_set_dma_count(int length)
372{
373 sun_pci_dma_pending.len = length;
374}
375
376static void sun_pci_fd_set_dma_addr(char *buffer)
377{
378 sun_pci_dma_pending.buf = buffer;
379}
380
381static unsigned int sun_pci_get_dma_residue(void)
382{
383 return ebus_dma_residue(&sun_pci_fd_ebus_dma);
384}
385
386static int sun_pci_fd_request_irq(void)
387{
388 return ebus_dma_irq_enable(&sun_pci_fd_ebus_dma, 1);
389}
390
391static void sun_pci_fd_free_irq(void)
392{
393 ebus_dma_irq_enable(&sun_pci_fd_ebus_dma, 0);
394}
395
396static int sun_pci_fd_eject(int drive)
397{
398 return -EINVAL;
399}
400
401void sun_pci_fd_dma_callback(struct ebus_dma_info *p, int event, void *cookie)
402{
403 floppy_interrupt(0, NULL, NULL);
404}
405
406/*
407 * Floppy probing, we'd like to use /dev/fd0 for a single Floppy on PCI,
408 * even if this is configured using DS1, thus looks like /dev/fd1 with
409 * the cabling used in Ultras.
410 */
411#define DOR (port + 2)
412#define MSR (port + 4)
413#define FIFO (port + 5)
414
415static void sun_pci_fd_out_byte(unsigned long port, unsigned char val,
416 unsigned long reg)
417{
418 unsigned char status;
419 int timeout = 1000;
420
421 while (!((status = inb(MSR)) & 0x80) && --timeout)
422 udelay(100);
423 outb(val, reg);
424}
425
426static unsigned char sun_pci_fd_sensei(unsigned long port)
427{
428 unsigned char result[2] = { 0x70, 0x00 };
429 unsigned char status;
430 int i = 0;
431
432 sun_pci_fd_out_byte(port, 0x08, FIFO);
433 do {
434 int timeout = 1000;
435
436 while (!((status = inb(MSR)) & 0x80) && --timeout)
437 udelay(100);
438
439 if (!timeout)
440 break;
441
442 if ((status & 0xf0) == 0xd0)
443 result[i++] = inb(FIFO);
444 else
445 break;
446 } while (i < 2);
447
448 return result[0];
449}
450
451static void sun_pci_fd_reset(unsigned long port)
452{
453 unsigned char mask = 0x00;
454 unsigned char status;
455 int timeout = 10000;
456
457 outb(0x80, MSR);
458 do {
459 status = sun_pci_fd_sensei(port);
460 if ((status & 0xc0) == 0xc0)
461 mask |= 1 << (status & 0x03);
462 else
463 udelay(100);
464 } while ((mask != 0x0f) && --timeout);
465}
466
467static int sun_pci_fd_test_drive(unsigned long port, int drive)
468{
469 unsigned char status, data;
470 int timeout = 1000;
471 int ready;
472
473 sun_pci_fd_reset(port);
474
475 data = (0x10 << drive) | 0x0c | drive;
476 sun_pci_fd_out_byte(port, data, DOR);
477
478 sun_pci_fd_out_byte(port, 0x07, FIFO);
479 sun_pci_fd_out_byte(port, drive & 0x03, FIFO);
480
481 do {
482 udelay(100);
483 status = sun_pci_fd_sensei(port);
484 } while (((status & 0xc0) == 0x80) && --timeout);
485
486 if (!timeout)
487 ready = 0;
488 else
489 ready = (status & 0x10) ? 0 : 1;
490
491 sun_pci_fd_reset(port);
492 return ready;
493}
494#undef FIFO
495#undef MSR
496#undef DOR
497
498#endif /* CONFIG_PCI */
499
500#ifdef CONFIG_PCI
501static int __init ebus_fdthree_p(struct linux_ebus_device *edev)
502{
503 if (!strcmp(edev->prom_name, "fdthree"))
504 return 1;
505 if (!strcmp(edev->prom_name, "floppy")) {
506 char compat[16];
507 prom_getstring(edev->prom_node,
508 "compatible",
509 compat, sizeof(compat));
510 compat[15] = '\0';
511 if (!strcmp(compat, "fdthree"))
512 return 1;
513 }
514 return 0;
515}
516#endif
517
518#ifdef CONFIG_PCI
519#undef ISA_FLOPPY_WORKS
520
521#ifdef ISA_FLOPPY_WORKS
522static unsigned long __init isa_floppy_init(void)
523{
524 struct sparc_isa_bridge *isa_br;
525 struct sparc_isa_device *isa_dev = NULL;
526
527 for_each_isa(isa_br) {
528 for_each_isadev(isa_dev, isa_br) {
529 if (!strcmp(isa_dev->prom_name, "dma")) {
530 struct sparc_isa_device *child =
531 isa_dev->child;
532
533 while (child) {
534 if (!strcmp(child->prom_name,
535 "floppy")) {
536 isa_dev = child;
537 goto isa_done;
538 }
539 child = child->next;
540 }
541 }
542 }
543 }
544isa_done:
545 if (!isa_dev)
546 return 0;
547
548 /* We could use DMA on devices behind the ISA bridge, but...
549 *
550 * There is a slight problem. Normally on x86 kit the x86 processor
551 * delays I/O port instructions when the ISA bus "dma in progress"
552 * signal is active. Well, sparc64 systems do not monitor this
553 * signal thus we would need to block all I/O port accesses in software
554 * when a dma transfer is active for some device.
555 */
556
557 sun_fdc = (struct sun_flpy_controller *)isa_dev->resource.start;
558 FLOPPY_IRQ = isa_dev->irq;
559
560 sun_fdops.fd_inb = sun_pci_fd_inb;
561 sun_fdops.fd_outb = sun_pci_fd_outb;
562
563 can_use_virtual_dma = use_virtual_dma = 1;
564 sun_fdops.fd_enable_dma = sun_fd_enable_dma;
565 sun_fdops.fd_disable_dma = sun_fd_disable_dma;
566 sun_fdops.fd_set_dma_mode = sun_fd_set_dma_mode;
567 sun_fdops.fd_set_dma_addr = sun_fd_set_dma_addr;
568 sun_fdops.fd_set_dma_count = sun_fd_set_dma_count;
569 sun_fdops.get_dma_residue = sun_get_dma_residue;
570
571 sun_fdops.fd_request_irq = sun_fd_request_irq;
572 sun_fdops.fd_free_irq = sun_fd_free_irq;
573
574 /* Floppy eject is manual. Actually, could determine this
575 * via presence of 'manual' property in OBP node.
576 */
577 sun_fdops.fd_eject = sun_pci_fd_eject;
578
579 fdc_status = (unsigned long) &sun_fdc->status_82077;
580 FLOPPY_MOTOR_MASK = 0xf0;
581
582 allowed_drive_mask = 0;
583 sun_floppy_types[0] = 0;
584 sun_floppy_types[1] = 4;
585
586 sun_pci_broken_drive = 1;
587 sun_fdops.fd_outb = sun_pci_fd_broken_outb;
588
589 return sun_floppy_types[0];
590}
591#endif /* ISA_FLOPPY_WORKS */
592
593#endif
594
595static unsigned long __init sun_floppy_init(void)
596{
597 char state[128];
598 struct sbus_bus *bus;
599 struct sbus_dev *sdev = NULL;
600 static int initialized = 0;
601
602 if (initialized)
603 return sun_floppy_types[0];
604 initialized = 1;
605
606 for_all_sbusdev (sdev, bus) {
607 if (!strcmp(sdev->prom_name, "SUNW,fdtwo"))
608 break;
609 }
610 if(sdev) {
611 floppy_sdev = sdev;
612 FLOPPY_IRQ = sdev->irqs[0];
613 } else {
614#ifdef CONFIG_PCI
615 struct linux_ebus *ebus;
616 struct linux_ebus_device *edev = NULL;
617 unsigned long config = 0;
618 unsigned long auxio_reg;
619
620 for_each_ebus(ebus) {
621 for_each_ebusdev(edev, ebus) {
622 if (ebus_fdthree_p(edev))
623 goto ebus_done;
624 }
625 }
626 ebus_done:
627 if (!edev) {
628#ifdef ISA_FLOPPY_WORKS
629 return isa_floppy_init();
630#else
631 return 0;
632#endif
633 }
634
635 prom_getproperty(edev->prom_node, "status",
636 state, sizeof(state));
637 if (!strncmp(state, "disabled", 8))
638 return 0;
639
640 FLOPPY_IRQ = edev->irqs[0];
641
642 /* Make sure the high density bit is set, some systems
643 * (most notably Ultra5/Ultra10) come up with it clear.
644 */
645 auxio_reg = edev->resource[2].start;
646 writel(readl(auxio_reg)|0x2, auxio_reg);
647
648 sun_pci_ebus_dev = ebus->self;
649
650 spin_lock_init(&sun_pci_fd_ebus_dma.lock);
651
652 /* XXX ioremap */
653 sun_pci_fd_ebus_dma.regs = edev->resource[1].start;
654 if (!sun_pci_fd_ebus_dma.regs)
655 return 0;
656
657 sun_pci_fd_ebus_dma.flags = (EBUS_DMA_FLAG_USE_EBDMA_HANDLER |
658 EBUS_DMA_FLAG_TCI_DISABLE);
659 sun_pci_fd_ebus_dma.callback = sun_pci_fd_dma_callback;
660 sun_pci_fd_ebus_dma.client_cookie = NULL;
661 sun_pci_fd_ebus_dma.irq = FLOPPY_IRQ;
662 strcpy(sun_pci_fd_ebus_dma.name, "floppy");
663 if (ebus_dma_register(&sun_pci_fd_ebus_dma))
664 return 0;
665
666 /* XXX ioremap */
667 sun_fdc = (struct sun_flpy_controller *)edev->resource[0].start;
668
669 sun_fdops.fd_inb = sun_pci_fd_inb;
670 sun_fdops.fd_outb = sun_pci_fd_outb;
671
672 can_use_virtual_dma = use_virtual_dma = 0;
673 sun_fdops.fd_enable_dma = sun_pci_fd_enable_dma;
674 sun_fdops.fd_disable_dma = sun_pci_fd_disable_dma;
675 sun_fdops.fd_set_dma_mode = sun_pci_fd_set_dma_mode;
676 sun_fdops.fd_set_dma_addr = sun_pci_fd_set_dma_addr;
677 sun_fdops.fd_set_dma_count = sun_pci_fd_set_dma_count;
678 sun_fdops.get_dma_residue = sun_pci_get_dma_residue;
679
680 sun_fdops.fd_request_irq = sun_pci_fd_request_irq;
681 sun_fdops.fd_free_irq = sun_pci_fd_free_irq;
682
683 sun_fdops.fd_eject = sun_pci_fd_eject;
684
685 fdc_status = (unsigned long) &sun_fdc->status_82077;
686 FLOPPY_MOTOR_MASK = 0xf0;
687
688 /*
689 * XXX: Find out on which machines this is really needed.
690 */
691 if (1) {
692 sun_pci_broken_drive = 1;
693 sun_fdops.fd_outb = sun_pci_fd_broken_outb;
694 }
695
696 allowed_drive_mask = 0;
697 if (sun_pci_fd_test_drive((unsigned long)sun_fdc, 0))
698 sun_floppy_types[0] = 4;
699 if (sun_pci_fd_test_drive((unsigned long)sun_fdc, 1))
700 sun_floppy_types[1] = 4;
701
702 /*
703 * Find NS87303 SuperIO config registers (through ecpp).
704 */
705 for_each_ebus(ebus) {
706 for_each_ebusdev(edev, ebus) {
707 if (!strcmp(edev->prom_name, "ecpp")) {
708 config = edev->resource[1].start;
709 goto config_done;
710 }
711 }
712 }
713 config_done:
714
715 /*
716 * Sanity check, is this really the NS87303?
717 */
718 switch (config & 0x3ff) {
719 case 0x02e:
720 case 0x15c:
721 case 0x26e:
722 case 0x398:
723 break;
724 default:
725 config = 0;
726 }
727
728 if (!config)
729 return sun_floppy_types[0];
730
731 /* Enable PC-AT mode. */
732 ns87303_modify(config, ASC, 0, 0xc0);
733
734#ifdef PCI_FDC_SWAP_DRIVES
735 /*
736 * If only Floppy 1 is present, swap drives.
737 */
738 if (!sun_floppy_types[0] && sun_floppy_types[1]) {
739 /*
740 * Set the drive exchange bit in FCR on NS87303,
741 * make shure other bits are sane before doing so.
742 */
743 ns87303_modify(config, FER, FER_EDM, 0);
744 ns87303_modify(config, ASC, ASC_DRV2_SEL, 0);
745 ns87303_modify(config, FCR, 0, FCR_LDE);
746
747 config = sun_floppy_types[0];
748 sun_floppy_types[0] = sun_floppy_types[1];
749 sun_floppy_types[1] = config;
750
751 if (sun_pci_broken_drive != -1) {
752 sun_pci_broken_drive = 1 - sun_pci_broken_drive;
753 sun_fdops.fd_outb = sun_pci_fd_lde_broken_outb;
754 }
755 }
756#endif /* PCI_FDC_SWAP_DRIVES */
757
758 return sun_floppy_types[0];
759#else
760 return 0;
761#endif
762 }
763 prom_getproperty(sdev->prom_node, "status", state, sizeof(state));
764 if(!strncmp(state, "disabled", 8))
765 return 0;
766
767 /*
768 * We cannot do sbus_ioremap here: it does request_region,
769 * which the generic floppy driver tries to do once again.
770 * But we must use the sdev resource values as they have
771 * had parent ranges applied.
772 */
773 sun_fdc = (struct sun_flpy_controller *)
774 (sdev->resource[0].start +
775 ((sdev->resource[0].flags & 0x1ffUL) << 32UL));
776
777 /* Last minute sanity check... */
778 if(sbus_readb(&sun_fdc->status1_82077) == 0xff) {
779 sun_fdc = (struct sun_flpy_controller *)-1;
780 return 0;
781 }
782
783 sun_fdops.fd_inb = sun_82077_fd_inb;
784 sun_fdops.fd_outb = sun_82077_fd_outb;
785
786 can_use_virtual_dma = use_virtual_dma = 1;
787 sun_fdops.fd_enable_dma = sun_fd_enable_dma;
788 sun_fdops.fd_disable_dma = sun_fd_disable_dma;
789 sun_fdops.fd_set_dma_mode = sun_fd_set_dma_mode;
790 sun_fdops.fd_set_dma_addr = sun_fd_set_dma_addr;
791 sun_fdops.fd_set_dma_count = sun_fd_set_dma_count;
792 sun_fdops.get_dma_residue = sun_get_dma_residue;
793
794 sun_fdops.fd_request_irq = sun_fd_request_irq;
795 sun_fdops.fd_free_irq = sun_fd_free_irq;
796
797 sun_fdops.fd_eject = sun_fd_eject;
798
799 fdc_status = (unsigned long) &sun_fdc->status_82077;
800
801 /* Success... */
802 allowed_drive_mask = 0x01;
803 sun_floppy_types[0] = 4;
804 sun_floppy_types[1] = 0;
805
806 return sun_floppy_types[0];
807}
808
809#define EXTRA_FLOPPY_PARAMS
810
811#endif /* !(__ASM_SPARC64_FLOPPY_H) */
diff --git a/include/asm-sparc64/fpumacro.h b/include/asm-sparc64/fpumacro.h
new file mode 100644
index 000000000000..d583e5efd75d
--- /dev/null
+++ b/include/asm-sparc64/fpumacro.h
@@ -0,0 +1,33 @@
1/* fpumacro.h: FPU related macros.
2 *
3 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_FPUMACRO_H
8#define _SPARC64_FPUMACRO_H
9
10#include <asm/asi.h>
11#include <asm/visasm.h>
12
13struct fpustate {
14 u32 regs[64];
15};
16
17#define FPUSTATE (struct fpustate *)(current_thread_info()->fpregs)
18
19static __inline__ unsigned long fprs_read(void)
20{
21 unsigned long retval;
22
23 __asm__ __volatile__("rd %%fprs, %0" : "=r" (retval));
24
25 return retval;
26}
27
28static __inline__ void fprs_write(unsigned long val)
29{
30 __asm__ __volatile__("wr %0, 0x0, %%fprs" : : "r" (val));
31}
32
33#endif /* !(_SPARC64_FPUMACRO_H) */
diff --git a/include/asm-sparc64/hardirq.h b/include/asm-sparc64/hardirq.h
new file mode 100644
index 000000000000..d6db1aed7645
--- /dev/null
+++ b/include/asm-sparc64/hardirq.h
@@ -0,0 +1,23 @@
1/* hardirq.h: 64-bit Sparc hard IRQ support.
2 *
3 * Copyright (C) 1997, 1998 David S. Miller (davem@caip.rutgers.edu)
4 */
5
6#ifndef __SPARC64_HARDIRQ_H
7#define __SPARC64_HARDIRQ_H
8
9#include <linux/config.h>
10#include <linux/threads.h>
11#include <linux/spinlock.h>
12#include <linux/cache.h>
13
14/* rtrap.S is sensitive to the offsets of these fields */
15typedef struct {
16 unsigned int __softirq_pending;
17} ____cacheline_aligned irq_cpustat_t;
18
19#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
20
21#define HARDIRQ_BITS 8
22
23#endif /* !(__SPARC64_HARDIRQ_H) */
diff --git a/include/asm-sparc64/hdreg.h b/include/asm-sparc64/hdreg.h
new file mode 100644
index 000000000000..7f7fd1af0af3
--- /dev/null
+++ b/include/asm-sparc64/hdreg.h
@@ -0,0 +1 @@
#include <asm-generic/hdreg.h>
diff --git a/include/asm-sparc64/head.h b/include/asm-sparc64/head.h
new file mode 100644
index 000000000000..b63a33cf4971
--- /dev/null
+++ b/include/asm-sparc64/head.h
@@ -0,0 +1,59 @@
1/* $Id: head.h,v 1.30 1997/08/08 08:34:33 jj Exp $ */
2#ifndef _SPARC64_HEAD_H
3#define _SPARC64_HEAD_H
4
5#include <asm/pstate.h>
6
7#define KERNBASE 0x400000
8
9#define PTREGS_OFF (STACK_BIAS + STACKFRAME_SZ)
10
11#define __CHEETAH_ID 0x003e0014
12#define __JALAPENO_ID 0x003e0016
13
14#define CHEETAH_MANUF 0x003e
15#define CHEETAH_IMPL 0x0014
16#define CHEETAH_PLUS_IMPL 0x0015
17#define JALAPENO_IMPL 0x0016
18
19#define BRANCH_IF_CHEETAH_BASE(tmp1,tmp2,label) \
20 rdpr %ver, %tmp1; \
21 sethi %hi(__CHEETAH_ID), %tmp2; \
22 srlx %tmp1, 32, %tmp1; \
23 or %tmp2, %lo(__CHEETAH_ID), %tmp2;\
24 cmp %tmp1, %tmp2; \
25 be,pn %icc, label; \
26 nop;
27
28#define BRANCH_IF_JALAPENO(tmp1,tmp2,label) \
29 rdpr %ver, %tmp1; \
30 sethi %hi(__JALAPENO_ID), %tmp2; \
31 srlx %tmp1, 32, %tmp1; \
32 or %tmp2, %lo(__JALAPENO_ID), %tmp2;\
33 cmp %tmp1, %tmp2; \
34 be,pn %icc, label; \
35 nop;
36
37#define BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(tmp1,tmp2,label) \
38 rdpr %ver, %tmp1; \
39 srlx %tmp1, (32 + 16), %tmp2; \
40 cmp %tmp2, CHEETAH_MANUF; \
41 bne,pt %xcc, 99f; \
42 sllx %tmp1, 16, %tmp1; \
43 srlx %tmp1, (32 + 16), %tmp2; \
44 cmp %tmp2, CHEETAH_PLUS_IMPL; \
45 bgeu,pt %xcc, label; \
4699: nop;
47
48#define BRANCH_IF_ANY_CHEETAH(tmp1,tmp2,label) \
49 rdpr %ver, %tmp1; \
50 srlx %tmp1, (32 + 16), %tmp2; \
51 cmp %tmp2, CHEETAH_MANUF; \
52 bne,pt %xcc, 99f; \
53 sllx %tmp1, 16, %tmp1; \
54 srlx %tmp1, (32 + 16), %tmp2; \
55 cmp %tmp2, CHEETAH_IMPL; \
56 bgeu,pt %xcc, label; \
5799: nop;
58
59#endif /* !(_SPARC64_HEAD_H) */
diff --git a/include/asm-sparc64/hw_irq.h b/include/asm-sparc64/hw_irq.h
new file mode 100644
index 000000000000..153cae2ddaee
--- /dev/null
+++ b/include/asm-sparc64/hw_irq.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_SPARC64_HW_IRQ_H
2#define __ASM_SPARC64_HW_IRQ_H
3
4/* Dummy include. */
5
6#endif
diff --git a/include/asm-sparc64/ide.h b/include/asm-sparc64/ide.h
new file mode 100644
index 000000000000..4c1098474c73
--- /dev/null
+++ b/include/asm-sparc64/ide.h
@@ -0,0 +1,121 @@
1/* $Id: ide.h,v 1.21 2001/09/25 20:21:48 kanoj Exp $
2 * ide.h: Ultra/PCI specific IDE glue.
3 *
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 */
7
8#ifndef _SPARC64_IDE_H
9#define _SPARC64_IDE_H
10
11#ifdef __KERNEL__
12
13#include <linux/config.h>
14#include <asm/pgalloc.h>
15#include <asm/io.h>
16#include <asm/spitfire.h>
17#include <asm/cacheflush.h>
18
19#ifndef MAX_HWIFS
20# ifdef CONFIG_BLK_DEV_IDEPCI
21#define MAX_HWIFS 10
22# else
23#define MAX_HWIFS 2
24# endif
25#endif
26
27#define IDE_ARCH_OBSOLETE_INIT
28#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
29
30#define __ide_insl(data_reg, buffer, wcount) \
31 __ide_insw(data_reg, buffer, (wcount)<<1)
32#define __ide_outsl(data_reg, buffer, wcount) \
33 __ide_outsw(data_reg, buffer, (wcount)<<1)
34
35/* On sparc64, I/O ports and MMIO registers are accessed identically. */
36#define __ide_mm_insw __ide_insw
37#define __ide_mm_insl __ide_insl
38#define __ide_mm_outsw __ide_outsw
39#define __ide_mm_outsl __ide_outsl
40
41static inline unsigned int inw_be(void __iomem *addr)
42{
43 unsigned int ret;
44
45 __asm__ __volatile__("lduha [%1] %2, %0"
46 : "=r" (ret)
47 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
48
49 return ret;
50}
51
52static inline void __ide_insw(void __iomem *port, void *dst, u32 count)
53{
54#ifdef DCACHE_ALIASING_POSSIBLE
55 unsigned long end = (unsigned long)dst + (count << 1);
56#endif
57 u16 *ps = dst;
58 u32 *pi;
59
60 if(((u64)ps) & 0x2) {
61 *ps++ = inw_be(port);
62 count--;
63 }
64 pi = (u32 *)ps;
65 while(count >= 2) {
66 u32 w;
67
68 w = inw_be(port) << 16;
69 w |= inw_be(port);
70 *pi++ = w;
71 count -= 2;
72 }
73 ps = (u16 *)pi;
74 if(count)
75 *ps++ = inw_be(port);
76
77#ifdef DCACHE_ALIASING_POSSIBLE
78 __flush_dcache_range((unsigned long)dst, end);
79#endif
80}
81
82static inline void outw_be(unsigned short w, void __iomem *addr)
83{
84 __asm__ __volatile__("stha %0, [%1] %2"
85 : /* no outputs */
86 : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
87}
88
89static inline void __ide_outsw(void __iomem *port, void *src, u32 count)
90{
91#ifdef DCACHE_ALIASING_POSSIBLE
92 unsigned long end = (unsigned long)src + (count << 1);
93#endif
94 const u16 *ps = src;
95 const u32 *pi;
96
97 if(((u64)src) & 0x2) {
98 outw_be(*ps++, port);
99 count--;
100 }
101 pi = (const u32 *)ps;
102 while(count >= 2) {
103 u32 w;
104
105 w = *pi++;
106 outw_be((w >> 16), port);
107 outw_be(w, port);
108 count -= 2;
109 }
110 ps = (const u16 *)pi;
111 if(count)
112 outw_be(*ps, port);
113
114#ifdef DCACHE_ALIASING_POSSIBLE
115 __flush_dcache_range((unsigned long)src, end);
116#endif
117}
118
119#endif /* __KERNEL__ */
120
121#endif /* _SPARC64_IDE_H */
diff --git a/include/asm-sparc64/idprom.h b/include/asm-sparc64/idprom.h
new file mode 100644
index 000000000000..701483c5465d
--- /dev/null
+++ b/include/asm-sparc64/idprom.h
@@ -0,0 +1,35 @@
1/* $Id: idprom.h,v 1.2 1997/04/04 00:50:16 davem Exp $
2 * idprom.h: Macros and defines for idprom routines
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_IDPROM_H
8#define _SPARC64_IDPROM_H
9
10#include <linux/types.h>
11
12/* Offset into the EEPROM where the id PROM is located on the 4c */
13#define IDPROM_OFFSET 0x7d8
14
15/* On sun4m; physical. */
16/* MicroSPARC(-II) does not decode 31rd bit, but it works. */
17#define IDPROM_OFFSET_M 0xfd8
18
19struct idprom
20{
21 u8 id_format; /* Format identifier (always 0x01) */
22 u8 id_machtype; /* Machine type */
23 u8 id_ethaddr[6]; /* Hardware ethernet address */
24 s32 id_date; /* Date of manufacture */
25 u32 id_sernum:24; /* Unique serial number */
26 u8 id_cksum; /* Checksum - xor of the data bytes */
27 u8 reserved[16];
28};
29
30extern struct idprom *idprom;
31extern void idprom_init(void);
32
33#define IDPROM_SIZE (sizeof(struct idprom))
34
35#endif /* !(_SPARC_IDPROM_H) */
diff --git a/include/asm-sparc64/io.h b/include/asm-sparc64/io.h
new file mode 100644
index 000000000000..afdcea90707a
--- /dev/null
+++ b/include/asm-sparc64/io.h
@@ -0,0 +1,501 @@
1/* $Id: io.h,v 1.47 2001/12/13 10:36:02 davem Exp $ */
2#ifndef __SPARC64_IO_H
3#define __SPARC64_IO_H
4
5#include <linux/kernel.h>
6#include <linux/compiler.h>
7#include <linux/types.h>
8
9#include <asm/page.h> /* IO address mapping routines need this */
10#include <asm/system.h>
11#include <asm/asi.h>
12
13/* PC crapola... */
14#define __SLOW_DOWN_IO do { } while (0)
15#define SLOW_DOWN_IO do { } while (0)
16
17extern unsigned long virt_to_bus_not_defined_use_pci_map(volatile void *addr);
18#define virt_to_bus virt_to_bus_not_defined_use_pci_map
19extern unsigned long bus_to_virt_not_defined_use_pci_map(volatile void *addr);
20#define bus_to_virt bus_to_virt_not_defined_use_pci_map
21
22/* BIO layer definitions. */
23extern unsigned long kern_base, kern_size;
24#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
25#define BIO_VMERGE_BOUNDARY 8192
26
27/* Different PCI controllers we support have their PCI MEM space
28 * mapped to an either 2GB (Psycho) or 4GB (Sabre) aligned area,
29 * so need to chop off the top 33 or 32 bits.
30 */
31extern unsigned long pci_memspace_mask;
32
33#define bus_dvma_to_mem(__vaddr) ((__vaddr) & pci_memspace_mask)
34
35static __inline__ u8 _inb(unsigned long addr)
36{
37 u8 ret;
38
39 __asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_inb */"
40 : "=r" (ret)
41 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
42
43 return ret;
44}
45
46static __inline__ u16 _inw(unsigned long addr)
47{
48 u16 ret;
49
50 __asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_inw */"
51 : "=r" (ret)
52 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
53
54 return ret;
55}
56
57static __inline__ u32 _inl(unsigned long addr)
58{
59 u32 ret;
60
61 __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_inl */"
62 : "=r" (ret)
63 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
64
65 return ret;
66}
67
68static __inline__ void _outb(u8 b, unsigned long addr)
69{
70 __asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_outb */"
71 : /* no outputs */
72 : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
73}
74
75static __inline__ void _outw(u16 w, unsigned long addr)
76{
77 __asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_outw */"
78 : /* no outputs */
79 : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
80}
81
82static __inline__ void _outl(u32 l, unsigned long addr)
83{
84 __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_outl */"
85 : /* no outputs */
86 : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
87}
88
89#define inb(__addr) (_inb((unsigned long)(__addr)))
90#define inw(__addr) (_inw((unsigned long)(__addr)))
91#define inl(__addr) (_inl((unsigned long)(__addr)))
92#define outb(__b, __addr) (_outb((u8)(__b), (unsigned long)(__addr)))
93#define outw(__w, __addr) (_outw((u16)(__w), (unsigned long)(__addr)))
94#define outl(__l, __addr) (_outl((u32)(__l), (unsigned long)(__addr)))
95
96#define inb_p(__addr) inb(__addr)
97#define outb_p(__b, __addr) outb(__b, __addr)
98#define inw_p(__addr) inw(__addr)
99#define outw_p(__w, __addr) outw(__w, __addr)
100#define inl_p(__addr) inl(__addr)
101#define outl_p(__l, __addr) outl(__l, __addr)
102
103extern void outsb(void __iomem *addr, const void *src, unsigned long count);
104extern void outsw(void __iomem *addr, const void *src, unsigned long count);
105extern void outsl(void __iomem *addr, const void *src, unsigned long count);
106extern void insb(void __iomem *addr, void *dst, unsigned long count);
107extern void insw(void __iomem *addr, void *dst, unsigned long count);
108extern void insl(void __iomem *addr, void *dst, unsigned long count);
109#define ioread8_rep(a,d,c) insb(a,d,c)
110#define ioread16_rep(a,d,c) insw(a,d,c)
111#define ioread32_rep(a,d,c) insl(a,d,c)
112#define iowrite8_rep(a,s,c) outsb(a,s,c)
113#define iowrite16_rep(a,s,c) outsw(a,s,c)
114#define iowrite32_rep(a,s,c) outsl(a,s,c)
115
116/* Memory functions, same as I/O accesses on Ultra. */
117static inline u8 _readb(const volatile void __iomem *addr)
118{ u8 ret;
119
120 __asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_readb */"
121 : "=r" (ret)
122 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
123 return ret;
124}
125
126static inline u16 _readw(const volatile void __iomem *addr)
127{ u16 ret;
128
129 __asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_readw */"
130 : "=r" (ret)
131 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
132
133 return ret;
134}
135
136static inline u32 _readl(const volatile void __iomem *addr)
137{ u32 ret;
138
139 __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_readl */"
140 : "=r" (ret)
141 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
142
143 return ret;
144}
145
146static inline u64 _readq(const volatile void __iomem *addr)
147{ u64 ret;
148
149 __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* pci_readq */"
150 : "=r" (ret)
151 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
152
153 return ret;
154}
155
156static inline void _writeb(u8 b, volatile void __iomem *addr)
157{
158 __asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_writeb */"
159 : /* no outputs */
160 : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
161}
162
163static inline void _writew(u16 w, volatile void __iomem *addr)
164{
165 __asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_writew */"
166 : /* no outputs */
167 : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
168}
169
170static inline void _writel(u32 l, volatile void __iomem *addr)
171{
172 __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_writel */"
173 : /* no outputs */
174 : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
175}
176
177static inline void _writeq(u64 q, volatile void __iomem *addr)
178{
179 __asm__ __volatile__("stxa\t%r0, [%1] %2\t/* pci_writeq */"
180 : /* no outputs */
181 : "Jr" (q), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L));
182}
183
184#define readb(__addr) _readb(__addr)
185#define readw(__addr) _readw(__addr)
186#define readl(__addr) _readl(__addr)
187#define readq(__addr) _readq(__addr)
188#define readb_relaxed(__addr) _readb(__addr)
189#define readw_relaxed(__addr) _readw(__addr)
190#define readl_relaxed(__addr) _readl(__addr)
191#define readq_relaxed(__addr) _readq(__addr)
192#define writeb(__b, __addr) _writeb(__b, __addr)
193#define writew(__w, __addr) _writew(__w, __addr)
194#define writel(__l, __addr) _writel(__l, __addr)
195#define writeq(__q, __addr) _writeq(__q, __addr)
196
197/* Now versions without byte-swapping. */
198static __inline__ u8 _raw_readb(unsigned long addr)
199{
200 u8 ret;
201
202 __asm__ __volatile__("lduba\t[%1] %2, %0\t/* pci_raw_readb */"
203 : "=r" (ret)
204 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
205
206 return ret;
207}
208
209static __inline__ u16 _raw_readw(unsigned long addr)
210{
211 u16 ret;
212
213 __asm__ __volatile__("lduha\t[%1] %2, %0\t/* pci_raw_readw */"
214 : "=r" (ret)
215 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
216
217 return ret;
218}
219
220static __inline__ u32 _raw_readl(unsigned long addr)
221{
222 u32 ret;
223
224 __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* pci_raw_readl */"
225 : "=r" (ret)
226 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
227
228 return ret;
229}
230
231static __inline__ u64 _raw_readq(unsigned long addr)
232{
233 u64 ret;
234
235 __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* pci_raw_readq */"
236 : "=r" (ret)
237 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
238
239 return ret;
240}
241
242static __inline__ void _raw_writeb(u8 b, unsigned long addr)
243{
244 __asm__ __volatile__("stba\t%r0, [%1] %2\t/* pci_raw_writeb */"
245 : /* no outputs */
246 : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
247}
248
249static __inline__ void _raw_writew(u16 w, unsigned long addr)
250{
251 __asm__ __volatile__("stha\t%r0, [%1] %2\t/* pci_raw_writew */"
252 : /* no outputs */
253 : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
254}
255
256static __inline__ void _raw_writel(u32 l, unsigned long addr)
257{
258 __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_raw_writel */"
259 : /* no outputs */
260 : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
261}
262
263static __inline__ void _raw_writeq(u64 q, unsigned long addr)
264{
265 __asm__ __volatile__("stxa\t%r0, [%1] %2\t/* pci_raw_writeq */"
266 : /* no outputs */
267 : "Jr" (q), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
268}
269
270#define __raw_readb(__addr) (_raw_readb((unsigned long)(__addr)))
271#define __raw_readw(__addr) (_raw_readw((unsigned long)(__addr)))
272#define __raw_readl(__addr) (_raw_readl((unsigned long)(__addr)))
273#define __raw_readq(__addr) (_raw_readq((unsigned long)(__addr)))
274#define __raw_writeb(__b, __addr) (_raw_writeb((u8)(__b), (unsigned long)(__addr)))
275#define __raw_writew(__w, __addr) (_raw_writew((u16)(__w), (unsigned long)(__addr)))
276#define __raw_writel(__l, __addr) (_raw_writel((u32)(__l), (unsigned long)(__addr)))
277#define __raw_writeq(__q, __addr) (_raw_writeq((u64)(__q), (unsigned long)(__addr)))
278
279/* Valid I/O Space regions are anywhere, because each PCI bus supported
280 * can live in an arbitrary area of the physical address range.
281 */
282#define IO_SPACE_LIMIT 0xffffffffffffffffUL
283
284/* Now, SBUS variants, only difference from PCI is that we do
285 * not use little-endian ASIs.
286 */
287static inline u8 _sbus_readb(const volatile void __iomem *addr)
288{
289 u8 ret;
290
291 __asm__ __volatile__("lduba\t[%1] %2, %0\t/* sbus_readb */"
292 : "=r" (ret)
293 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
294
295 return ret;
296}
297
298static inline u16 _sbus_readw(const volatile void __iomem *addr)
299{
300 u16 ret;
301
302 __asm__ __volatile__("lduha\t[%1] %2, %0\t/* sbus_readw */"
303 : "=r" (ret)
304 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
305
306 return ret;
307}
308
309static inline u32 _sbus_readl(const volatile void __iomem *addr)
310{
311 u32 ret;
312
313 __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* sbus_readl */"
314 : "=r" (ret)
315 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
316
317 return ret;
318}
319
320static inline u64 _sbus_readq(const volatile void __iomem *addr)
321{
322 u64 ret;
323
324 __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* sbus_readq */"
325 : "=r" (ret)
326 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
327
328 return ret;
329}
330
331static inline void _sbus_writeb(u8 b, volatile void __iomem *addr)
332{
333 __asm__ __volatile__("stba\t%r0, [%1] %2\t/* sbus_writeb */"
334 : /* no outputs */
335 : "Jr" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
336}
337
338static inline void _sbus_writew(u16 w, volatile void __iomem *addr)
339{
340 __asm__ __volatile__("stha\t%r0, [%1] %2\t/* sbus_writew */"
341 : /* no outputs */
342 : "Jr" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
343}
344
345static inline void _sbus_writel(u32 l, volatile void __iomem *addr)
346{
347 __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* sbus_writel */"
348 : /* no outputs */
349 : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
350}
351
352static inline void _sbus_writeq(u64 l, volatile void __iomem *addr)
353{
354 __asm__ __volatile__("stxa\t%r0, [%1] %2\t/* sbus_writeq */"
355 : /* no outputs */
356 : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
357}
358
359#define sbus_readb(__addr) _sbus_readb(__addr)
360#define sbus_readw(__addr) _sbus_readw(__addr)
361#define sbus_readl(__addr) _sbus_readl(__addr)
362#define sbus_readq(__addr) _sbus_readq(__addr)
363#define sbus_writeb(__b, __addr) _sbus_writeb(__b, __addr)
364#define sbus_writew(__w, __addr) _sbus_writew(__w, __addr)
365#define sbus_writel(__l, __addr) _sbus_writel(__l, __addr)
366#define sbus_writeq(__l, __addr) _sbus_writeq(__l, __addr)
367
368static inline void _sbus_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
369{
370 while(n--) {
371 sbus_writeb(c, dst);
372 dst++;
373 }
374}
375
376#define sbus_memset_io(d,c,sz) _sbus_memset_io(d,c,sz)
377
378static inline void
379_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
380{
381 volatile void __iomem *d = dst;
382
383 while (n--) {
384 writeb(c, d);
385 d++;
386 }
387}
388
389#define memset_io(d,c,sz) _memset_io(d,c,sz)
390
391static inline void
392_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
393{
394 char *d = dst;
395
396 while (n--) {
397 char tmp = readb(src);
398 *d++ = tmp;
399 src++;
400 }
401}
402
403#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
404
405static inline void
406_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
407{
408 const char *s = src;
409 volatile void __iomem *d = dst;
410
411 while (n--) {
412 char tmp = *s++;
413 writeb(tmp, d);
414 d++;
415 }
416}
417
418#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
419
420static inline int check_signature(void __iomem *io_addr,
421 const unsigned char *signature,
422 int length)
423{
424 int retval = 0;
425 do {
426 if (readb(io_addr) != *signature++)
427 goto out;
428 io_addr++;
429 } while (--length);
430 retval = 1;
431out:
432 return retval;
433}
434
435#define mmiowb()
436
437#ifdef __KERNEL__
438
439/* On sparc64 we have the whole physical IO address space accessible
440 * using physically addressed loads and stores, so this does nothing.
441 */
442static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
443{
444 return (void __iomem *)offset;
445}
446
447#define ioremap_nocache(X,Y) ioremap((X),(Y))
448
449static inline void iounmap(volatile void __iomem *addr)
450{
451}
452
453#define ioread8(X) readb(X)
454#define ioread16(X) readw(X)
455#define ioread32(X) readl(X)
456#define iowrite8(val,X) writeb(val,X)
457#define iowrite16(val,X) writew(val,X)
458#define iowrite32(val,X) writel(val,X)
459
460/* Create a virtual mapping cookie for an IO port range */
461extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
462extern void ioport_unmap(void __iomem *);
463
464/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
465struct pci_dev;
466extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
467extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
468
469/* Similarly for SBUS. */
470#define sbus_ioremap(__res, __offset, __size, __name) \
471({ unsigned long __ret; \
472 __ret = (__res)->start + (((__res)->flags & 0x1ffUL) << 32UL); \
473 __ret += (unsigned long) (__offset); \
474 if (! request_region((__ret), (__size), (__name))) \
475 __ret = 0UL; \
476 (void __iomem *) __ret; \
477})
478
479#define sbus_iounmap(__addr, __size) \
480 release_region((unsigned long)(__addr), (__size))
481
482/* Nothing to do */
483
484#define dma_cache_inv(_start,_size) do { } while (0)
485#define dma_cache_wback(_start,_size) do { } while (0)
486#define dma_cache_wback_inv(_start,_size) do { } while (0)
487
488/*
489 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
490 * access
491 */
492#define xlate_dev_mem_ptr(p) __va(p)
493
494/*
495 * Convert a virtual cached pointer to an uncached pointer
496 */
497#define xlate_dev_kmem_ptr(p) p
498
499#endif
500
501#endif /* !(__SPARC64_IO_H) */
diff --git a/include/asm-sparc64/ioctl.h b/include/asm-sparc64/ioctl.h
new file mode 100644
index 000000000000..253d0b57b316
--- /dev/null
+++ b/include/asm-sparc64/ioctl.h
@@ -0,0 +1,68 @@
1/* $Id: ioctl.h,v 1.2 1998/10/15 05:40:38 jj Exp $ */
2#ifndef _SPARC64_IOCTL_H
3#define _SPARC64_IOCTL_H
4
5/*
6 * Our DIR and SIZE overlap in order to simulteneously provide
7 * a non-zero _IOC_NONE (for binary compatibility) and
8 * 14 bits of size as on i386. Here's the layout:
9 *
10 * 0xE0000000 DIR
11 * 0x80000000 DIR = WRITE
12 * 0x40000000 DIR = READ
13 * 0x20000000 DIR = NONE
14 * 0x3FFF0000 SIZE (overlaps NONE bit)
15 * 0x0000FF00 TYPE
16 * 0x000000FF NR (CMD)
17 */
18
19#define _IOC_NRBITS 8
20#define _IOC_TYPEBITS 8
21#define _IOC_SIZEBITS 13 /* Actually 14, see below. */
22#define _IOC_DIRBITS 3
23
24#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
25#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
26#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
27#define _IOC_XSIZEMASK ((1 << (_IOC_SIZEBITS+1))-1)
28#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
29
30#define _IOC_NRSHIFT 0
31#define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
32#define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
33#define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
34
35#define _IOC_NONE 1U
36#define _IOC_READ 2U
37#define _IOC_WRITE 4U
38
39#define _IOC(dir,type,nr,size) \
40 (((dir) << _IOC_DIRSHIFT) | \
41 ((type) << _IOC_TYPESHIFT) | \
42 ((nr) << _IOC_NRSHIFT) | \
43 ((size) << _IOC_SIZESHIFT))
44
45#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
46#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
47#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
48#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
49
50/* Used to decode ioctl numbers in drivers despite the leading underscore... */
51#define _IOC_DIR(nr) \
52 ( (((((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) & (_IOC_WRITE|_IOC_READ)) != 0)? \
53 (((nr) >> _IOC_DIRSHIFT) & (_IOC_WRITE|_IOC_READ)): \
54 (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) )
55#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
56#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
57#define _IOC_SIZE(nr) \
58 ((((((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) & (_IOC_WRITE|_IOC_READ)) == 0)? \
59 0: (((nr) >> _IOC_SIZESHIFT) & _IOC_XSIZEMASK))
60
61/* ...and for the PCMCIA and sound. */
62#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
63#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
64#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
65#define IOCSIZE_MASK (_IOC_XSIZEMASK << _IOC_SIZESHIFT)
66#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
67
68#endif /* !(_SPARC64_IOCTL_H) */
diff --git a/include/asm-sparc64/ioctls.h b/include/asm-sparc64/ioctls.h
new file mode 100644
index 000000000000..2223b6d0e5ed
--- /dev/null
+++ b/include/asm-sparc64/ioctls.h
@@ -0,0 +1,135 @@
1/* $Id: ioctls.h,v 1.7 1998/02/23 02:49:41 davem Exp $ */
2#ifndef _ASM_SPARC64_IOCTLS_H
3#define _ASM_SPARC64_IOCTLS_H
4
5#include <asm/ioctl.h>
6
7/* Big T */
8#define TCGETA _IOR('T', 1, struct termio)
9#define TCSETA _IOW('T', 2, struct termio)
10#define TCSETAW _IOW('T', 3, struct termio)
11#define TCSETAF _IOW('T', 4, struct termio)
12#define TCSBRK _IO('T', 5)
13#define TCXONC _IO('T', 6)
14#define TCFLSH _IO('T', 7)
15#define TCGETS _IOR('T', 8, struct termios)
16#define TCSETS _IOW('T', 9, struct termios)
17#define TCSETSW _IOW('T', 10, struct termios)
18#define TCSETSF _IOW('T', 11, struct termios)
19
20/* Note that all the ioctls that are not available in Linux have a
21 * double underscore on the front to: a) avoid some programs to
22 * think we support some ioctls under Linux (autoconfiguration stuff)
23 */
24/* Little t */
25#define TIOCGETD _IOR('t', 0, int)
26#define TIOCSETD _IOW('t', 1, int)
27#define __TIOCHPCL _IO('t', 2) /* SunOS Specific */
28#define __TIOCMODG _IOR('t', 3, int) /* SunOS Specific */
29#define __TIOCMODS _IOW('t', 4, int) /* SunOS Specific */
30#define __TIOCGETP _IOR('t', 8, struct sgttyb) /* SunOS Specific */
31#define __TIOCSETP _IOW('t', 9, struct sgttyb) /* SunOS Specific */
32#define __TIOCSETN _IOW('t', 10, struct sgttyb) /* SunOS Specific */
33#define TIOCEXCL _IO('t', 13)
34#define TIOCNXCL _IO('t', 14)
35#define __TIOCFLUSH _IOW('t', 16, int) /* SunOS Specific */
36#define __TIOCSETC _IOW('t', 17, struct tchars) /* SunOS Specific */
37#define __TIOCGETC _IOR('t', 18, struct tchars) /* SunOS Specific */
38#define __TIOCTCNTL _IOW('t', 32, int) /* SunOS Specific */
39#define __TIOCSIGNAL _IOW('t', 33, int) /* SunOS Specific */
40#define __TIOCSETX _IOW('t', 34, int) /* SunOS Specific */
41#define __TIOCGETX _IOR('t', 35, int) /* SunOS Specific */
42#define TIOCCONS _IO('t', 36)
43#define __TIOCSSIZE _IOW('t', 37, struct sunos_ttysize) /* SunOS Specific */
44#define __TIOCGSIZE _IOR('t', 38, struct sunos_ttysize) /* SunOS Specific */
45#define TIOCGSOFTCAR _IOR('t', 100, int)
46#define TIOCSSOFTCAR _IOW('t', 101, int)
47#define __TIOCUCNTL _IOW('t', 102, int) /* SunOS Specific */
48#define TIOCSWINSZ _IOW('t', 103, struct winsize)
49#define TIOCGWINSZ _IOR('t', 104, struct winsize)
50#define __TIOCREMOTE _IOW('t', 105, int) /* SunOS Specific */
51#define TIOCMGET _IOR('t', 106, int)
52#define TIOCMBIC _IOW('t', 107, int)
53#define TIOCMBIS _IOW('t', 108, int)
54#define TIOCMSET _IOW('t', 109, int)
55#define TIOCSTART _IO('t', 110)
56#define TIOCSTOP _IO('t', 111)
57#define TIOCPKT _IOW('t', 112, int)
58#define TIOCNOTTY _IO('t', 113)
59#define TIOCSTI _IOW('t', 114, char)
60#define TIOCOUTQ _IOR('t', 115, int)
61#define __TIOCGLTC _IOR('t', 116, struct ltchars) /* SunOS Specific */
62#define __TIOCSLTC _IOW('t', 117, struct ltchars) /* SunOS Specific */
63/* 118 is the non-posix setpgrp tty ioctl */
64/* 119 is the non-posix getpgrp tty ioctl */
65#define __TIOCCDTR _IO('t', 120) /* SunOS Specific */
66#define __TIOCSDTR _IO('t', 121) /* SunOS Specific */
67#define TIOCCBRK _IO('t', 122)
68#define TIOCSBRK _IO('t', 123)
69#define __TIOCLGET _IOW('t', 124, int) /* SunOS Specific */
70#define __TIOCLSET _IOW('t', 125, int) /* SunOS Specific */
71#define __TIOCLBIC _IOW('t', 126, int) /* SunOS Specific */
72#define __TIOCLBIS _IOW('t', 127, int) /* SunOS Specific */
73#define __TIOCISPACE _IOR('t', 128, int) /* SunOS Specific */
74#define __TIOCISIZE _IOR('t', 129, int) /* SunOS Specific */
75#define TIOCSPGRP _IOW('t', 130, int)
76#define TIOCGPGRP _IOR('t', 131, int)
77#define TIOCSCTTY _IO('t', 132)
78#define TIOCGSID _IOR('t', 133, int)
79/* Get minor device of a pty master's FD -- Solaris equiv is ISPTM */
80#define TIOCGPTN _IOR('t', 134, unsigned int) /* Get Pty Number */
81#define TIOCSPTLCK _IOW('t', 135, int) /* Lock/unlock PTY */
82
83/* Little f */
84#define FIOCLEX _IO('f', 1)
85#define FIONCLEX _IO('f', 2)
86#define FIOASYNC _IOW('f', 125, int)
87#define FIONBIO _IOW('f', 126, int)
88#define FIONREAD _IOR('f', 127, int)
89#define TIOCINQ FIONREAD
90#define FIOQSIZE _IOR('f', 128, loff_t)
91
92/* SCARY Rutgers local SunOS kernel hackery, perhaps I will support it
93 * someday. This is completely bogus, I know...
94 */
95#define __TCGETSTAT _IO('T', 200) /* Rutgers specific */
96#define __TCSETSTAT _IO('T', 201) /* Rutgers specific */
97
98/* Linux specific, no SunOS equivalent. */
99#define TIOCLINUX 0x541C
100#define TIOCGSERIAL 0x541E
101#define TIOCSSERIAL 0x541F
102#define TCSBRKP 0x5425
103#define TIOCSERCONFIG 0x5453
104#define TIOCSERGWILD 0x5454
105#define TIOCSERSWILD 0x5455
106#define TIOCGLCKTRMIOS 0x5456
107#define TIOCSLCKTRMIOS 0x5457
108#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
109#define TIOCSERGETLSR 0x5459 /* Get line status register */
110#define TIOCSERGETMULTI 0x545A /* Get multiport config */
111#define TIOCSERSETMULTI 0x545B /* Set multiport config */
112#define TIOCMIWAIT 0x545C /* Wait for change on serial input line(s) */
113#define TIOCGICOUNT 0x545D /* Read serial port inline interrupt counts */
114
115/* Kernel definitions */
116#ifdef __KERNEL__
117#define TIOCGETC __TIOCGETC
118#define TIOCGETP __TIOCGETP
119#define TIOCGLTC __TIOCGLTC
120#define TIOCSLTC __TIOCSLTC
121#define TIOCSETP __TIOCSETP
122#define TIOCSETN __TIOCSETN
123#define TIOCSETC __TIOCSETC
124#endif
125
126/* Used for packet mode */
127#define TIOCPKT_DATA 0
128#define TIOCPKT_FLUSHREAD 1
129#define TIOCPKT_FLUSHWRITE 2
130#define TIOCPKT_STOP 4
131#define TIOCPKT_START 8
132#define TIOCPKT_NOSTOP 16
133#define TIOCPKT_DOSTOP 32
134
135#endif /* !(_ASM_SPARC64_IOCTLS_H) */
diff --git a/include/asm-sparc64/iommu.h b/include/asm-sparc64/iommu.h
new file mode 100644
index 000000000000..5fd16e42a045
--- /dev/null
+++ b/include/asm-sparc64/iommu.h
@@ -0,0 +1,19 @@
1/* $Id: iommu.h,v 1.10 2001/03/08 09:55:56 davem Exp $
2 * iommu.h: Definitions for the sun5 IOMMU.
3 *
4 * Copyright (C) 1996, 1999 David S. Miller (davem@caip.rutgers.edu)
5 */
6#ifndef _SPARC64_IOMMU_H
7#define _SPARC64_IOMMU_H
8
9/* The format of an iopte in the page tables. */
10#define IOPTE_VALID 0x8000000000000000UL /* IOPTE is valid */
11#define IOPTE_64K 0x2000000000000000UL /* IOPTE is for 64k page */
12#define IOPTE_STBUF 0x1000000000000000UL /* DVMA can use streaming buffer */
13#define IOPTE_INTRA 0x0800000000000000UL /* SBUS slot-->slot direct transfer*/
14#define IOPTE_CONTEXT 0x07ff800000000000UL /* Context number */
15#define IOPTE_PAGE 0x00007fffffffe000UL /* Physical page number (PA[42:13])*/
16#define IOPTE_CACHE 0x0000000000000010UL /* Cached (in UPA E-cache) */
17#define IOPTE_WRITE 0x0000000000000002UL /* Writeable */
18
19#endif /* !(_SPARC_IOMMU_H) */
diff --git a/include/asm-sparc64/ipc.h b/include/asm-sparc64/ipc.h
new file mode 100644
index 000000000000..a46e3d9c2a3f
--- /dev/null
+++ b/include/asm-sparc64/ipc.h
@@ -0,0 +1 @@
#include <asm-generic/ipc.h>
diff --git a/include/asm-sparc64/ipcbuf.h b/include/asm-sparc64/ipcbuf.h
new file mode 100644
index 000000000000..9c5bf1bc423f
--- /dev/null
+++ b/include/asm-sparc64/ipcbuf.h
@@ -0,0 +1,28 @@
1#ifndef _SPARC64_IPCBUF_H
2#define _SPARC64_IPCBUF_H
3
4/*
5 * The ipc64_perm structure for sparc64 architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 32-bit seq
11 * - 2 miscellaneous 64-bit values
12 */
13
14struct ipc64_perm
15{
16 __kernel_key_t key;
17 __kernel_uid_t uid;
18 __kernel_gid_t gid;
19 __kernel_uid_t cuid;
20 __kernel_gid_t cgid;
21 __kernel_mode_t mode;
22 unsigned short __pad1;
23 unsigned short seq;
24 unsigned long __unused1;
25 unsigned long __unused2;
26};
27
28#endif /* _SPARC64_IPCBUF_H */
diff --git a/include/asm-sparc64/irq.h b/include/asm-sparc64/irq.h
new file mode 100644
index 000000000000..3aef0ca67750
--- /dev/null
+++ b/include/asm-sparc64/irq.h
@@ -0,0 +1,157 @@
1/* $Id: irq.h,v 1.21 2002/01/23 11:27:36 davem Exp $
2 * irq.h: IRQ registers on the 64-bit Sparc.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
6 */
7
8#ifndef _SPARC64_IRQ_H
9#define _SPARC64_IRQ_H
10
11#include <linux/config.h>
12#include <linux/linkage.h>
13#include <linux/kernel.h>
14#include <linux/errno.h>
15#include <linux/interrupt.h>
16#include <asm/pil.h>
17#include <asm/ptrace.h>
18
19/* You should not mess with this directly. That's the job of irq.c.
20 *
21 * If you make changes here, please update hand coded assembler of
22 * SBUS/floppy interrupt handler in entry.S -DaveM
23 *
24 * This is currently one DCACHE line, two buckets per L2 cache
25 * line. Keep this in mind please.
26 */
27struct ino_bucket {
28 /* Next handler in per-CPU PIL worklist. We know that
29 * bucket pointers have the high 32-bits clear, so to
30 * save space we only store the bits we need.
31 */
32/*0x00*/unsigned int irq_chain;
33
34 /* PIL to schedule this IVEC at. */
35/*0x04*/unsigned char pil;
36
37 /* If an IVEC arrives while irq_info is NULL, we
38 * set this to notify request_irq() about the event.
39 */
40/*0x05*/unsigned char pending;
41
42 /* Miscellaneous flags. */
43/*0x06*/unsigned char flags;
44
45 /* This is used to deal with IBF_DMA_SYNC on
46 * Sabre systems.
47 */
48/*0x07*/unsigned char synctab_ent;
49
50 /* Reference to handler for this IRQ. If this is
51 * non-NULL this means it is active and should be
52 * serviced. Else the pending member is set to one
53 * and later registry of the interrupt checks for
54 * this condition.
55 *
56 * Normally this is just an irq_action structure.
57 * But, on PCI, if multiple interrupt sources behind
58 * a bridge have multiple interrupt sources that share
59 * the same INO bucket, this points to an array of
60 * pointers to four IRQ action structures.
61 */
62/*0x08*/void *irq_info;
63
64 /* Sun5 Interrupt Clear Register. */
65/*0x10*/unsigned long iclr;
66
67 /* Sun5 Interrupt Mapping Register. */
68/*0x18*/unsigned long imap;
69
70};
71
72#ifdef CONFIG_PCI
73extern unsigned long pci_dma_wsync;
74extern unsigned long dma_sync_reg_table[256];
75extern unsigned char dma_sync_reg_table_entry;
76#endif
77
78/* IMAP/ICLR register defines */
79#define IMAP_VALID 0x80000000 /* IRQ Enabled */
80#define IMAP_TID_UPA 0x7c000000 /* UPA TargetID */
81#define IMAP_TID_JBUS 0x7c000000 /* JBUS TargetID */
82#define IMAP_AID_SAFARI 0x7c000000 /* Safari AgentID */
83#define IMAP_NID_SAFARI 0x03e00000 /* Safari NodeID */
84#define IMAP_IGN 0x000007c0 /* IRQ Group Number */
85#define IMAP_INO 0x0000003f /* IRQ Number */
86#define IMAP_INR 0x000007ff /* Full interrupt number*/
87
88#define ICLR_IDLE 0x00000000 /* Idle state */
89#define ICLR_TRANSMIT 0x00000001 /* Transmit state */
90#define ICLR_PENDING 0x00000003 /* Pending state */
91
92/* Only 8-bits are available, be careful. -DaveM */
93#define IBF_DMA_SYNC 0x01 /* DMA synchronization behind PCI bridge needed. */
94#define IBF_PCI 0x02 /* Indicates PSYCHO/SABRE/SCHIZO PCI interrupt. */
95#define IBF_ACTIVE 0x04 /* This interrupt is active and has a handler. */
96#define IBF_MULTI 0x08 /* On PCI, indicates shared bucket. */
97#define IBF_INPROGRESS 0x10 /* IRQ is being serviced. */
98
99#define NUM_IVECS (IMAP_INR + 1)
100extern struct ino_bucket ivector_table[NUM_IVECS];
101
102#define __irq_ino(irq) \
103 (((struct ino_bucket *)(unsigned long)(irq)) - &ivector_table[0])
104#define __irq_pil(irq) ((struct ino_bucket *)(unsigned long)(irq))->pil
105#define __bucket(irq) ((struct ino_bucket *)(unsigned long)(irq))
106#define __irq(bucket) ((unsigned int)(unsigned long)(bucket))
107
108static __inline__ char *__irq_itoa(unsigned int irq)
109{
110 static char buff[16];
111
112 sprintf(buff, "%d,%x", __irq_pil(irq), (unsigned int)__irq_ino(irq));
113 return buff;
114}
115
116#define NR_IRQS 16
117
118#define irq_canonicalize(irq) (irq)
119extern void disable_irq(unsigned int);
120#define disable_irq_nosync disable_irq
121extern void enable_irq(unsigned int);
122extern unsigned int build_irq(int pil, int inofixup, unsigned long iclr, unsigned long imap);
123extern unsigned int sbus_build_irq(void *sbus, unsigned int ino);
124
125extern int request_fast_irq(unsigned int irq,
126 irqreturn_t (*handler)(int, void *, struct pt_regs *),
127 unsigned long flags, __const__ char *devname,
128 void *dev_id);
129
130static __inline__ void set_softint(unsigned long bits)
131{
132 __asm__ __volatile__("wr %0, 0x0, %%set_softint"
133 : /* No outputs */
134 : "r" (bits));
135}
136
137static __inline__ void clear_softint(unsigned long bits)
138{
139 __asm__ __volatile__("wr %0, 0x0, %%clear_softint"
140 : /* No outputs */
141 : "r" (bits));
142}
143
144static __inline__ unsigned long get_softint(void)
145{
146 unsigned long retval;
147
148 __asm__ __volatile__("rd %%softint, %0"
149 : "=r" (retval));
150 return retval;
151}
152
153struct irqaction;
154struct pt_regs;
155int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
156
157#endif
diff --git a/include/asm-sparc64/isa.h b/include/asm-sparc64/isa.h
new file mode 100644
index 000000000000..4601bbfc3e7b
--- /dev/null
+++ b/include/asm-sparc64/isa.h
@@ -0,0 +1,54 @@
1/* $Id: isa.h,v 1.1 2001/05/11 04:31:55 davem Exp $
2 * isa.h: Sparc64 layer for PCI to ISA bridge devices.
3 *
4 * Copyright (C) 2001 David S. Miller (davem@redhat.com)
5 */
6
7#ifndef __SPARC64_ISA_H
8#define __SPARC64_ISA_H
9
10#include <asm/pbm.h>
11#include <asm/oplib.h>
12
13struct sparc_isa_bridge;
14
15struct sparc_isa_device {
16 struct sparc_isa_device *next;
17 struct sparc_isa_device *child;
18 struct sparc_isa_bridge *bus;
19 int prom_node;
20 char prom_name[64];
21 char compatible[64];
22 struct resource resource;
23 unsigned int irq;
24};
25
26struct sparc_isa_bridge {
27 struct sparc_isa_bridge *next;
28 struct sparc_isa_device *devices;
29 struct pci_pbm_info *parent;
30 struct pci_dev *self;
31 int index;
32 int prom_node;
33 char prom_name[64];
34#define linux_prom_isa_ranges linux_prom_ebus_ranges
35 struct linux_prom_isa_ranges isa_ranges[PROMREG_MAX];
36 int num_isa_ranges;
37#define linux_prom_isa_intmap linux_prom_ebus_intmap
38 struct linux_prom_isa_intmap isa_intmap[PROMREG_MAX];
39 int num_isa_intmap;
40#define linux_prom_isa_intmask linux_prom_ebus_intmask
41 struct linux_prom_isa_intmap isa_intmask;
42};
43
44extern struct sparc_isa_bridge *isa_chain;
45
46extern void isa_init(void);
47
48#define for_each_isa(bus) \
49 for((bus) = isa_chain; (bus); (bus) = (bus)->next)
50
51#define for_each_isadev(dev, bus) \
52 for((dev) = (bus)->devices; (dev); (dev) = (dev)->next)
53
54#endif /* !(__SPARC64_ISA_H) */
diff --git a/include/asm-sparc64/kbio.h b/include/asm-sparc64/kbio.h
new file mode 100644
index 000000000000..3cf496bdf399
--- /dev/null
+++ b/include/asm-sparc64/kbio.h
@@ -0,0 +1,56 @@
1#ifndef __LINUX_KBIO_H
2#define __LINUX_KBIO_H
3
4/* Return keyboard type */
5#define KIOCTYPE _IOR('k', 9, int)
6/* Return Keyboard layout */
7#define KIOCLAYOUT _IOR('k', 20, int)
8
9enum {
10 TR_NONE,
11 TR_ASCII, /* keyboard is in regular state */
12 TR_EVENT, /* keystrokes sent as firm events */
13 TR_UNTRANS_EVENT /* EVENT+up and down+no translation */
14};
15
16/* Return the current keyboard translation */
17#define KIOCGTRANS _IOR('k', 5, int)
18/* Set the keyboard translation */
19#define KIOCTRANS _IOW('k', 0, int)
20
21/* Send a keyboard command */
22#define KIOCCMD _IOW('k', 8, int)
23
24/* Return if keystrokes are being sent to /dev/kbd */
25
26/* Set routing of keystrokes to /dev/kbd */
27#define KIOCSDIRECT _IOW('k', 10, int)
28
29/* Set keyboard leds */
30#define KIOCSLED _IOW('k', 14, unsigned char)
31
32/* Get keyboard leds */
33#define KIOCGLED _IOR('k', 15, unsigned char)
34
35/* Used by KIOC[GS]RATE */
36struct kbd_rate {
37 unsigned char delay; /* Delay in Hz before first repeat. */
38 unsigned char rate; /* In characters per second (0..50). */
39};
40
41/* Set keyboard rate */
42#define KIOCSRATE _IOW('k', 40, struct kbd_rate)
43
44/* Get keyboard rate */
45#define KIOCGRATE _IOW('k', 41, struct kbd_rate)
46
47/* Top bit records if the key is up or down */
48#define KBD_UP 0x80
49
50/* Usable information */
51#define KBD_KEYMASK 0x7f
52
53/* All keys up */
54#define KBD_IDLE 0x75
55
56#endif /* __LINUX_KBIO_H */
diff --git a/include/asm-sparc64/kdebug.h b/include/asm-sparc64/kdebug.h
new file mode 100644
index 000000000000..f70d3dad01f9
--- /dev/null
+++ b/include/asm-sparc64/kdebug.h
@@ -0,0 +1,52 @@
1#ifndef _SPARC64_KDEBUG_H
2#define _SPARC64_KDEBUG_H
3
4/* Nearly identical to x86_64/i386 code. */
5
6#include <linux/notifier.h>
7
8struct pt_regs;
9
10struct die_args {
11 struct pt_regs *regs;
12 const char *str;
13 long err;
14 int trapnr;
15 int signr;
16};
17
18/* Note - you should never unregister because that can race with NMIs.
19 * If you really want to do it first unregister - then synchronize_kernel
20 * - then free.
21 */
22int register_die_notifier(struct notifier_block *nb);
23extern struct notifier_block *sparc64die_chain;
24
25extern void bad_trap(struct pt_regs *, long);
26
27/* Grossly misnamed. */
28enum die_val {
29 DIE_OOPS = 1,
30 DIE_DEBUG, /* ta 0x70 */
31 DIE_DEBUG_2, /* ta 0x71 */
32 DIE_DIE,
33 DIE_TRAP,
34 DIE_TRAP_TL1,
35 DIE_GPF,
36 DIE_CALL,
37 DIE_PAGE_FAULT,
38};
39
40static inline int notify_die(enum die_val val,char *str, struct pt_regs *regs,
41 long err, int trap, int sig)
42{
43 struct die_args args = { .regs = regs,
44 .str = str,
45 .err = err,
46 .trapnr = trap,
47 .signr = sig };
48
49 return notifier_call_chain(&sparc64die_chain, val, &args);
50}
51
52#endif
diff --git a/include/asm-sparc64/kmap_types.h b/include/asm-sparc64/kmap_types.h
new file mode 100644
index 000000000000..34c1d3d9a3b0
--- /dev/null
+++ b/include/asm-sparc64/kmap_types.h
@@ -0,0 +1,25 @@
1#ifndef _ASM_KMAP_TYPES_H
2#define _ASM_KMAP_TYPES_H
3
4/* Dummy header just to define km_type. None of this
5 * is actually used on sparc64. -DaveM
6 */
7
8enum km_type {
9 KM_BOUNCE_READ,
10 KM_SKB_SUNRPC_DATA,
11 KM_SKB_DATA_SOFTIRQ,
12 KM_USER0,
13 KM_USER1,
14 KM_BIO_SRC_IRQ,
15 KM_BIO_DST_IRQ,
16 KM_PTE0,
17 KM_PTE1,
18 KM_IRQ0,
19 KM_IRQ1,
20 KM_SOFTIRQ0,
21 KM_SOFTIRQ1,
22 KM_TYPE_NR
23};
24
25#endif
diff --git a/include/asm-sparc64/kprobes.h b/include/asm-sparc64/kprobes.h
new file mode 100644
index 000000000000..a8d326a598f0
--- /dev/null
+++ b/include/asm-sparc64/kprobes.h
@@ -0,0 +1,32 @@
1#ifndef _SPARC64_KPROBES_H
2#define _SPARC64_KPROBES_H
3
4#include <linux/config.h>
5#include <linux/types.h>
6
7typedef u32 kprobe_opcode_t;
8
9#define BREAKPOINT_INSTRUCTION 0x91d02070 /* ta 0x70 */
10#define BREAKPOINT_INSTRUCTION_2 0x91d02071 /* ta 0x71 */
11#define MAX_INSN_SIZE 2
12
13#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
14
15/* Architecture specific copy of original instruction*/
16struct arch_specific_insn {
17 /* copy of the original instruction */
18 kprobe_opcode_t insn[MAX_INSN_SIZE];
19};
20
21#ifdef CONFIG_KPROBES
22extern int kprobe_exceptions_notify(struct notifier_block *self,
23 unsigned long val, void *data);
24#else /* !CONFIG_KPROBES */
25static inline int kprobe_exceptions_notify(struct notifier_block *self,
26 unsigned long val, void *data)
27{
28 return 0;
29}
30#endif
31
32#endif /* _SPARC64_KPROBES_H */
diff --git a/include/asm-sparc64/linkage.h b/include/asm-sparc64/linkage.h
new file mode 100644
index 000000000000..291c2d01c44f
--- /dev/null
+++ b/include/asm-sparc64/linkage.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4/* Nothing to see here... */
5
6#endif
diff --git a/include/asm-sparc64/local.h b/include/asm-sparc64/local.h
new file mode 100644
index 000000000000..dfde115ac892
--- /dev/null
+++ b/include/asm-sparc64/local.h
@@ -0,0 +1,40 @@
1#ifndef _ARCH_SPARC64_LOCAL_H
2#define _ARCH_SPARC64_LOCAL_H
3
4#include <linux/percpu.h>
5#include <asm/atomic.h>
6
7typedef atomic64_t local_t;
8
9#define LOCAL_INIT(i) ATOMIC64_INIT(i)
10#define local_read(v) atomic64_read(v)
11#define local_set(v,i) atomic64_set(v,i)
12
13#define local_inc(v) atomic64_inc(v)
14#define local_dec(v) atomic64_dec(v)
15#define local_add(i, v) atomic64_add(i, v)
16#define local_sub(i, v) atomic64_sub(i, v)
17
18#define __local_inc(v) ((v)->counter++)
19#define __local_dec(v) ((v)->counter--)
20#define __local_add(i,v) ((v)->counter+=(i))
21#define __local_sub(i,v) ((v)->counter-=(i))
22
23/* Use these for per-cpu local_t variables: on some archs they are
24 * much more efficient than these naive implementations. Note they take
25 * a variable, not an address.
26 */
27#define cpu_local_read(v) local_read(&__get_cpu_var(v))
28#define cpu_local_set(v, i) local_set(&__get_cpu_var(v), (i))
29
30#define cpu_local_inc(v) local_inc(&__get_cpu_var(v))
31#define cpu_local_dec(v) local_dec(&__get_cpu_var(v))
32#define cpu_local_add(i, v) local_add((i), &__get_cpu_var(v))
33#define cpu_local_sub(i, v) local_sub((i), &__get_cpu_var(v))
34
35#define __cpu_local_inc(v) __local_inc(&__get_cpu_var(v))
36#define __cpu_local_dec(v) __local_dec(&__get_cpu_var(v))
37#define __cpu_local_add(i, v) __local_add((i), &__get_cpu_var(v))
38#define __cpu_local_sub(i, v) __local_sub((i), &__get_cpu_var(v))
39
40#endif /* _ARCH_SPARC64_LOCAL_H */
diff --git a/include/asm-sparc64/lsu.h b/include/asm-sparc64/lsu.h
new file mode 100644
index 000000000000..e5329c7f5833
--- /dev/null
+++ b/include/asm-sparc64/lsu.h
@@ -0,0 +1,20 @@
1/* $Id: lsu.h,v 1.2 1997/04/04 00:50:22 davem Exp $ */
2#ifndef _SPARC64_LSU_H
3#define _SPARC64_LSU_H
4
5#include <asm/const.h>
6
7/* LSU Control Register */
8#define LSU_CONTROL_PM _AC(0x000001fe00000000,UL) /* Phys-watchpoint byte mask*/
9#define LSU_CONTROL_VM _AC(0x00000001fe000000,UL) /* Virt-watchpoint byte mask*/
10#define LSU_CONTROL_PR _AC(0x0000000001000000,UL) /* Phys-rd watchpoint enable*/
11#define LSU_CONTROL_PW _AC(0x0000000000800000,UL) /* Phys-wr watchpoint enable*/
12#define LSU_CONTROL_VR _AC(0x0000000000400000,UL) /* Virt-rd watchpoint enable*/
13#define LSU_CONTROL_VW _AC(0x0000000000200000,UL) /* Virt-wr watchpoint enable*/
14#define LSU_CONTROL_FM _AC(0x00000000000ffff0,UL) /* Parity mask enables. */
15#define LSU_CONTROL_DM _AC(0x0000000000000008,UL) /* Data MMU enable. */
16#define LSU_CONTROL_IM _AC(0x0000000000000004,UL) /* Instruction MMU enable. */
17#define LSU_CONTROL_DC _AC(0x0000000000000002,UL) /* Data cache enable. */
18#define LSU_CONTROL_IC _AC(0x0000000000000001,UL) /* Instruction cache enable.*/
19
20#endif /* !(_SPARC64_LSU_H) */
diff --git a/include/asm-sparc64/mc146818rtc.h b/include/asm-sparc64/mc146818rtc.h
new file mode 100644
index 000000000000..75bd572b35fe
--- /dev/null
+++ b/include/asm-sparc64/mc146818rtc.h
@@ -0,0 +1,35 @@
1/*
2 * Machine dependent access functions for RTC registers.
3 */
4#ifndef __ASM_SPARC64_MC146818RTC_H
5#define __ASM_SPARC64_MC146818RTC_H
6
7#include <linux/config.h>
8#include <asm/io.h>
9
10#ifndef RTC_PORT
11#ifdef CONFIG_PCI
12extern unsigned long ds1287_regs;
13#else
14#define ds1287_regs (0UL)
15#endif
16#define RTC_PORT(x) (ds1287_regs + (x))
17#define RTC_ALWAYS_BCD 0
18#endif
19
20/*
21 * The yet supported machines all access the RTC index register via
22 * an ISA port access but the way to access the date register differs ...
23 */
24#define CMOS_READ(addr) ({ \
25outb_p((addr),RTC_PORT(0)); \
26inb_p(RTC_PORT(1)); \
27})
28#define CMOS_WRITE(val, addr) ({ \
29outb_p((addr),RTC_PORT(0)); \
30outb_p((val),RTC_PORT(1)); \
31})
32
33#define RTC_IRQ 8
34
35#endif /* __ASM_SPARC64_MC146818RTC_H */
diff --git a/include/asm-sparc64/mman.h b/include/asm-sparc64/mman.h
new file mode 100644
index 000000000000..01cecf54357b
--- /dev/null
+++ b/include/asm-sparc64/mman.h
@@ -0,0 +1,62 @@
1/* $Id: mman.h,v 1.2 2000/03/15 02:44:26 davem Exp $ */
2#ifndef __SPARC64_MMAN_H__
3#define __SPARC64_MMAN_H__
4
5/* SunOS'ified... */
6
7#define PROT_READ 0x1 /* page can be read */
8#define PROT_WRITE 0x2 /* page can be written */
9#define PROT_EXEC 0x4 /* page can be executed */
10#define PROT_SEM 0x8 /* page may be used for atomic ops */
11#define PROT_NONE 0x0 /* page can not be accessed */
12#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
13#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
14
15#define MAP_SHARED 0x01 /* Share changes */
16#define MAP_PRIVATE 0x02 /* Changes are private */
17#define MAP_TYPE 0x0f /* Mask for type of mapping */
18#define MAP_FIXED 0x10 /* Interpret addr exactly */
19#define MAP_ANONYMOUS 0x20 /* don't use a file */
20#define MAP_RENAME MAP_ANONYMOUS /* In SunOS terminology */
21#define MAP_NORESERVE 0x40 /* don't reserve swap pages */
22#define MAP_INHERIT 0x80 /* SunOS doesn't do this, but... */
23#define MAP_LOCKED 0x100 /* lock the mapping */
24#define _MAP_NEW 0x80000000 /* Binary compatibility is fun... */
25
26#define MAP_GROWSDOWN 0x0200 /* stack-like segment */
27#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
28#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
29
30#define MS_ASYNC 1 /* sync memory asynchronously */
31#define MS_INVALIDATE 2 /* invalidate the caches */
32#define MS_SYNC 4 /* synchronous memory sync */
33
34#define MCL_CURRENT 0x2000 /* lock all currently mapped pages */
35#define MCL_FUTURE 0x4000 /* lock all additions to address space */
36
37#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
38#define MAP_NONBLOCK 0x10000 /* do not block on IO */
39
40/* XXX Need to add flags to SunOS's mctl, mlockall, and madvise system
41 * XXX calls.
42 */
43
44/* SunOS sys_mctl() stuff... */
45#define MC_SYNC 1 /* Sync pages in memory with storage (usu. a file) */
46#define MC_LOCK 2 /* Lock pages into core ram, do not allow swapping of them */
47#define MC_UNLOCK 3 /* Unlock pages locked via previous mctl() with MC_LOCK arg */
48#define MC_LOCKAS 5 /* Lock an entire address space of the calling process */
49#define MC_UNLOCKAS 6 /* Unlock entire address space of calling process */
50
51#define MADV_NORMAL 0x0 /* default page-in behavior */
52#define MADV_RANDOM 0x1 /* page-in minimum required */
53#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
54#define MADV_WILLNEED 0x3 /* pre-fault pages */
55#define MADV_DONTNEED 0x4 /* discard these pages */
56#define MADV_FREE 0x5 /* (Solaris) contents can be freed */
57
58/* compatibility flags */
59#define MAP_ANON MAP_ANONYMOUS
60#define MAP_FILE 0
61
62#endif /* __SPARC64_MMAN_H__ */
diff --git a/include/asm-sparc64/mmu.h b/include/asm-sparc64/mmu.h
new file mode 100644
index 000000000000..8627eed6e83d
--- /dev/null
+++ b/include/asm-sparc64/mmu.h
@@ -0,0 +1,99 @@
1#ifndef __MMU_H
2#define __MMU_H
3
4#include <linux/config.h>
5#include <asm/page.h>
6#include <asm/const.h>
7
8/*
9 * For the 8k pagesize kernel, use only 10 hw context bits to optimize some
10 * shifts in the fast tlbmiss handlers, instead of all 13 bits (specifically
11 * for vpte offset calculation). For other pagesizes, this optimization in
12 * the tlbhandlers can not be done; but still, all 13 bits can not be used
13 * because the tlb handlers use "andcc" instruction which sign extends 13
14 * bit arguments.
15 */
16#if PAGE_SHIFT == 13
17#define CTX_NR_BITS 10
18#else
19#define CTX_NR_BITS 12
20#endif
21
22#define TAG_CONTEXT_BITS ((_AC(1,UL) << CTX_NR_BITS) - _AC(1,UL))
23
24/* UltraSPARC-III+ and later have a feature whereby you can
25 * select what page size the various Data-TLB instances in the
26 * chip. In order to gracefully support this, we put the version
27 * field in a spot outside of the areas of the context register
28 * where this parameter is specified.
29 */
30#define CTX_VERSION_SHIFT 22
31#define CTX_VERSION_MASK ((~0UL) << CTX_VERSION_SHIFT)
32
33#define CTX_PGSZ_8KB _AC(0x0,UL)
34#define CTX_PGSZ_64KB _AC(0x1,UL)
35#define CTX_PGSZ_512KB _AC(0x2,UL)
36#define CTX_PGSZ_4MB _AC(0x3,UL)
37#define CTX_PGSZ_BITS _AC(0x7,UL)
38#define CTX_PGSZ0_NUC_SHIFT 61
39#define CTX_PGSZ1_NUC_SHIFT 58
40#define CTX_PGSZ0_SHIFT 16
41#define CTX_PGSZ1_SHIFT 19
42#define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \
43 (CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT))
44
45#if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
46#define CTX_PGSZ_BASE CTX_PGSZ_8KB
47#elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
48#define CTX_PGSZ_BASE CTX_PGSZ_64KB
49#elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
50#define CTX_PGSZ_BASE CTX_PGSZ_512KB
51#elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
52#define CTX_PGSZ_BASE CTX_PGSZ_4MB
53#else
54#error No page size specified in kernel configuration
55#endif
56
57#if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
58#define CTX_PGSZ_HUGE CTX_PGSZ_4MB
59#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
60#define CTX_PGSZ_HUGE CTX_PGSZ_512KB
61#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
62#define CTX_PGSZ_HUGE CTX_PGSZ_64KB
63#endif
64
65#define CTX_PGSZ_KERN CTX_PGSZ_4MB
66
67/* Thus, when running on UltraSPARC-III+ and later, we use the following
68 * PRIMARY_CONTEXT register values for the kernel context.
69 */
70#define CTX_CHEETAH_PLUS_NUC \
71 ((CTX_PGSZ_KERN << CTX_PGSZ0_NUC_SHIFT) | \
72 (CTX_PGSZ_BASE << CTX_PGSZ1_NUC_SHIFT))
73
74#define CTX_CHEETAH_PLUS_CTX0 \
75 ((CTX_PGSZ_KERN << CTX_PGSZ0_SHIFT) | \
76 (CTX_PGSZ_BASE << CTX_PGSZ1_SHIFT))
77
78/* If you want "the TLB context number" use CTX_NR_MASK. If you
79 * want "the bits I program into the context registers" use
80 * CTX_HW_MASK.
81 */
82#define CTX_NR_MASK TAG_CONTEXT_BITS
83#define CTX_HW_MASK (CTX_NR_MASK | CTX_PGSZ_MASK)
84
85#define CTX_FIRST_VERSION ((_AC(1,UL) << CTX_VERSION_SHIFT) + _AC(1,UL))
86#define CTX_VALID(__ctx) \
87 (!(((__ctx.sparc64_ctx_val) ^ tlb_context_cache) & CTX_VERSION_MASK))
88#define CTX_HWBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_HW_MASK)
89#define CTX_NRBITS(__ctx) ((__ctx.sparc64_ctx_val) & CTX_NR_MASK)
90
91#ifndef __ASSEMBLY__
92
93typedef struct {
94 unsigned long sparc64_ctx_val;
95} mm_context_t;
96
97#endif /* !__ASSEMBLY__ */
98
99#endif /* __MMU_H */
diff --git a/include/asm-sparc64/mmu_context.h b/include/asm-sparc64/mmu_context.h
new file mode 100644
index 000000000000..87c43c67866e
--- /dev/null
+++ b/include/asm-sparc64/mmu_context.h
@@ -0,0 +1,145 @@
1/* $Id: mmu_context.h,v 1.54 2002/02/09 19:49:31 davem Exp $ */
2#ifndef __SPARC64_MMU_CONTEXT_H
3#define __SPARC64_MMU_CONTEXT_H
4
5/* Derived heavily from Linus's Alpha/AXP ASN code... */
6
7#ifndef __ASSEMBLY__
8
9#include <linux/spinlock.h>
10#include <asm/system.h>
11#include <asm/spitfire.h>
12
13static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14{
15}
16
17extern spinlock_t ctx_alloc_lock;
18extern unsigned long tlb_context_cache;
19extern unsigned long mmu_context_bmap[];
20
21extern void get_new_mmu_context(struct mm_struct *mm);
22
23/* Initialize a new mmu context. This is invoked when a new
24 * address space instance (unique or shared) is instantiated.
25 * This just needs to set mm->context to an invalid context.
26 */
27#define init_new_context(__tsk, __mm) \
28 (((__mm)->context.sparc64_ctx_val = 0UL), 0)
29
30/* Destroy a dead context. This occurs when mmput drops the
31 * mm_users count to zero, the mmaps have been released, and
32 * all the page tables have been flushed. Our job is to destroy
33 * any remaining processor-specific state, and in the sparc64
34 * case this just means freeing up the mmu context ID held by
35 * this task if valid.
36 */
37#define destroy_context(__mm) \
38do { spin_lock(&ctx_alloc_lock); \
39 if (CTX_VALID((__mm)->context)) { \
40 unsigned long nr = CTX_NRBITS((__mm)->context); \
41 mmu_context_bmap[nr>>6] &= ~(1UL << (nr & 63)); \
42 } \
43 spin_unlock(&ctx_alloc_lock); \
44} while(0)
45
46/* Reload the two core values used by TLB miss handler
47 * processing on sparc64. They are:
48 * 1) The physical address of mm->pgd, when full page
49 * table walks are necessary, this is where the
50 * search begins.
51 * 2) A "PGD cache". For 32-bit tasks only pgd[0] is
52 * ever used since that maps the entire low 4GB
53 * completely. To speed up TLB miss processing we
54 * make this value available to the handlers. This
55 * decreases the amount of memory traffic incurred.
56 */
57#define reload_tlbmiss_state(__tsk, __mm) \
58do { \
59 register unsigned long paddr asm("o5"); \
60 register unsigned long pgd_cache asm("o4"); \
61 paddr = __pa((__mm)->pgd); \
62 pgd_cache = 0UL; \
63 if ((__tsk)->thread_info->flags & _TIF_32BIT) \
64 pgd_cache = get_pgd_cache((__mm)->pgd); \
65 __asm__ __volatile__("wrpr %%g0, 0x494, %%pstate\n\t" \
66 "mov %3, %%g4\n\t" \
67 "mov %0, %%g7\n\t" \
68 "stxa %1, [%%g4] %2\n\t" \
69 "membar #Sync\n\t" \
70 "wrpr %%g0, 0x096, %%pstate" \
71 : /* no outputs */ \
72 : "r" (paddr), "r" (pgd_cache),\
73 "i" (ASI_DMMU), "i" (TSB_REG)); \
74} while(0)
75
76/* Set MMU context in the actual hardware. */
77#define load_secondary_context(__mm) \
78 __asm__ __volatile__("stxa %0, [%1] %2\n\t" \
79 "flush %%g6" \
80 : /* No outputs */ \
81 : "r" (CTX_HWBITS((__mm)->context)), \
82 "r" (SECONDARY_CONTEXT), "i" (ASI_DMMU))
83
84extern void __flush_tlb_mm(unsigned long, unsigned long);
85
86/* Switch the current MM context. */
87static inline void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, struct task_struct *tsk)
88{
89 unsigned long ctx_valid;
90
91 spin_lock(&mm->page_table_lock);
92 if (CTX_VALID(mm->context))
93 ctx_valid = 1;
94 else
95 ctx_valid = 0;
96
97 if (!ctx_valid || (old_mm != mm)) {
98 if (!ctx_valid)
99 get_new_mmu_context(mm);
100
101 load_secondary_context(mm);
102 reload_tlbmiss_state(tsk, mm);
103 }
104
105 {
106 int cpu = smp_processor_id();
107
108 /* Even if (mm == old_mm) we _must_ check
109 * the cpu_vm_mask. If we do not we could
110 * corrupt the TLB state because of how
111 * smp_flush_tlb_{page,range,mm} on sparc64
112 * and lazy tlb switches work. -DaveM
113 */
114 if (!ctx_valid || !cpu_isset(cpu, mm->cpu_vm_mask)) {
115 cpu_set(cpu, mm->cpu_vm_mask);
116 __flush_tlb_mm(CTX_HWBITS(mm->context),
117 SECONDARY_CONTEXT);
118 }
119 }
120 spin_unlock(&mm->page_table_lock);
121}
122
123#define deactivate_mm(tsk,mm) do { } while (0)
124
125/* Activate a new MM instance for the current task. */
126static inline void activate_mm(struct mm_struct *active_mm, struct mm_struct *mm)
127{
128 int cpu;
129
130 spin_lock(&mm->page_table_lock);
131 if (!CTX_VALID(mm->context))
132 get_new_mmu_context(mm);
133 cpu = smp_processor_id();
134 if (!cpu_isset(cpu, mm->cpu_vm_mask))
135 cpu_set(cpu, mm->cpu_vm_mask);
136 spin_unlock(&mm->page_table_lock);
137
138 load_secondary_context(mm);
139 __flush_tlb_mm(CTX_HWBITS(mm->context), SECONDARY_CONTEXT);
140 reload_tlbmiss_state(current, mm);
141}
142
143#endif /* !(__ASSEMBLY__) */
144
145#endif /* !(__SPARC64_MMU_CONTEXT_H) */
diff --git a/include/asm-sparc64/module.h b/include/asm-sparc64/module.h
new file mode 100644
index 000000000000..3d77ba465783
--- /dev/null
+++ b/include/asm-sparc64/module.h
@@ -0,0 +1,7 @@
1#ifndef _ASM_SPARC64_MODULE_H
2#define _ASM_SPARC64_MODULE_H
3struct mod_arch_specific { };
4#define Elf_Shdr Elf64_Shdr
5#define Elf_Sym Elf64_Sym
6#define Elf_Ehdr Elf64_Ehdr
7#endif /* _ASM_SPARC64_MODULE_H */
diff --git a/include/asm-sparc64/mostek.h b/include/asm-sparc64/mostek.h
new file mode 100644
index 000000000000..ccf2f5f82d7f
--- /dev/null
+++ b/include/asm-sparc64/mostek.h
@@ -0,0 +1,144 @@
1/* $Id: mostek.h,v 1.4 2001/01/11 15:07:09 davem Exp $
2 * mostek.h: Describes the various Mostek time of day clock registers.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
6 */
7
8#ifndef _SPARC64_MOSTEK_H
9#define _SPARC64_MOSTEK_H
10
11#include <asm/idprom.h>
12
13/* M48T02 Register Map (adapted from Sun NVRAM/Hostid FAQ)
14 *
15 * Data
16 * Address Function
17 * Bit 7 Bit 6 Bit 5 Bit 4Bit 3 Bit 2 Bit 1 Bit 0
18 * 7ff - - - - - - - - Year 00-99
19 * 7fe 0 0 0 - - - - - Month 01-12
20 * 7fd 0 0 - - - - - - Date 01-31
21 * 7fc 0 FT 0 0 0 - - - Day 01-07
22 * 7fb KS 0 - - - - - - Hours 00-23
23 * 7fa 0 - - - - - - - Minutes 00-59
24 * 7f9 ST - - - - - - - Seconds 00-59
25 * 7f8 W R S - - - - - Control
26 *
27 * * ST is STOP BIT
28 * * W is WRITE BIT
29 * * R is READ BIT
30 * * S is SIGN BIT
31 * * FT is FREQ TEST BIT
32 * * KS is KICK START BIT
33 */
34
35/* The Mostek 48t02 real time clock and NVRAM chip. The registers
36 * other than the control register are in binary coded decimal. Some
37 * control bits also live outside the control register.
38 *
39 * We now deal with physical addresses for I/O to the chip. -DaveM
40 */
41static __inline__ u8 mostek_read(unsigned long addr)
42{
43 u8 ret;
44
45 __asm__ __volatile__("lduba [%1] %2, %0"
46 : "=r" (ret)
47 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
48 return ret;
49}
50
51static __inline__ void mostek_write(unsigned long addr, u8 val)
52{
53 __asm__ __volatile__("stba %0, [%1] %2"
54 : /* no outputs */
55 : "r" (val), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
56}
57
58#define MOSTEK_EEPROM 0x0000UL
59#define MOSTEK_IDPROM 0x07d8UL
60#define MOSTEK_CREG 0x07f8UL
61#define MOSTEK_SEC 0x07f9UL
62#define MOSTEK_MIN 0x07faUL
63#define MOSTEK_HOUR 0x07fbUL
64#define MOSTEK_DOW 0x07fcUL
65#define MOSTEK_DOM 0x07fdUL
66#define MOSTEK_MONTH 0x07feUL
67#define MOSTEK_YEAR 0x07ffUL
68
69extern spinlock_t mostek_lock;
70extern unsigned long mstk48t02_regs;
71
72/* Control register values. */
73#define MSTK_CREG_WRITE 0x80 /* Must set this before placing values. */
74#define MSTK_CREG_READ 0x40 /* Stop updates to allow a clean read. */
75#define MSTK_CREG_SIGN 0x20 /* Slow/speed clock in calibration mode. */
76
77/* Control bits that live in the other registers. */
78#define MSTK_STOP 0x80 /* Stop the clock oscillator. (sec) */
79#define MSTK_KICK_START 0x80 /* Kick start the clock chip. (hour) */
80#define MSTK_FREQ_TEST 0x40 /* Frequency test mode. (day) */
81
82#define MSTK_YEAR_ZERO 1968 /* If year reg has zero, it is 1968. */
83#define MSTK_CVT_YEAR(yr) ((yr) + MSTK_YEAR_ZERO)
84
85/* Masks that define how much space each value takes up. */
86#define MSTK_SEC_MASK 0x7f
87#define MSTK_MIN_MASK 0x7f
88#define MSTK_HOUR_MASK 0x3f
89#define MSTK_DOW_MASK 0x07
90#define MSTK_DOM_MASK 0x3f
91#define MSTK_MONTH_MASK 0x1f
92#define MSTK_YEAR_MASK 0xff
93
94/* Binary coded decimal conversion macros. */
95#define MSTK_REGVAL_TO_DECIMAL(x) (((x) & 0x0F) + 0x0A * ((x) >> 0x04))
96#define MSTK_DECIMAL_TO_REGVAL(x) ((((x) / 0x0A) << 0x04) + ((x) % 0x0A))
97
98/* Generic register set and get macros for internal use. */
99#define MSTK_GET(regs,name) \
100 (MSTK_REGVAL_TO_DECIMAL(mostek_read(regs + MOSTEK_ ## name) & MSTK_ ## name ## _MASK))
101#define MSTK_SET(regs,name,value) \
102do { u8 __val = mostek_read(regs + MOSTEK_ ## name); \
103 __val &= ~(MSTK_ ## name ## _MASK); \
104 __val |= (MSTK_DECIMAL_TO_REGVAL(value) & \
105 (MSTK_ ## name ## _MASK)); \
106 mostek_write(regs + MOSTEK_ ## name, __val); \
107} while(0)
108
109/* Macros to make register access easier on our fingers. These give you
110 * the decimal value of the register requested if applicable. You pass
111 * the a pointer to a 'struct mostek48t02'.
112 */
113#define MSTK_REG_CREG(regs) (mostek_read((regs) + MOSTEK_CREG))
114#define MSTK_REG_SEC(regs) MSTK_GET(regs,SEC)
115#define MSTK_REG_MIN(regs) MSTK_GET(regs,MIN)
116#define MSTK_REG_HOUR(regs) MSTK_GET(regs,HOUR)
117#define MSTK_REG_DOW(regs) MSTK_GET(regs,DOW)
118#define MSTK_REG_DOM(regs) MSTK_GET(regs,DOM)
119#define MSTK_REG_MONTH(regs) MSTK_GET(regs,MONTH)
120#define MSTK_REG_YEAR(regs) MSTK_GET(regs,YEAR)
121
122#define MSTK_SET_REG_SEC(regs,value) MSTK_SET(regs,SEC,value)
123#define MSTK_SET_REG_MIN(regs,value) MSTK_SET(regs,MIN,value)
124#define MSTK_SET_REG_HOUR(regs,value) MSTK_SET(regs,HOUR,value)
125#define MSTK_SET_REG_DOW(regs,value) MSTK_SET(regs,DOW,value)
126#define MSTK_SET_REG_DOM(regs,value) MSTK_SET(regs,DOM,value)
127#define MSTK_SET_REG_MONTH(regs,value) MSTK_SET(regs,MONTH,value)
128#define MSTK_SET_REG_YEAR(regs,value) MSTK_SET(regs,YEAR,value)
129
130
131/* The Mostek 48t08 clock chip. Found on Sun4m's I think. It has the
132 * same (basically) layout of the 48t02 chip except for the extra
133 * NVRAM on board (8 KB against the 48t02's 2 KB).
134 */
135#define MOSTEK_48T08_OFFSET 0x0000UL /* Lower NVRAM portions */
136#define MOSTEK_48T08_48T02 0x1800UL /* Offset to 48T02 chip */
137
138/* SUN5 systems usually have 48t59 model clock chipsets. But we keep the older
139 * clock chip definitions around just in case.
140 */
141#define MOSTEK_48T59_OFFSET 0x0000UL /* Lower NVRAM portions */
142#define MOSTEK_48T59_48T02 0x1800UL /* Offset to 48T02 chip */
143
144#endif /* !(_SPARC64_MOSTEK_H) */
diff --git a/include/asm-sparc64/msgbuf.h b/include/asm-sparc64/msgbuf.h
new file mode 100644
index 000000000000..55c101bd0e7d
--- /dev/null
+++ b/include/asm-sparc64/msgbuf.h
@@ -0,0 +1,27 @@
1#ifndef _SPARC64_MSGBUF_H
2#define _SPARC64_MSGBUF_H
3
4/*
5 * The msqid64_ds structure for sparc64 architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 2 miscellaneous 64-bit values
11 */
12
13struct msqid64_ds {
14 struct ipc64_perm msg_perm;
15 __kernel_time_t msg_stime; /* last msgsnd time */
16 __kernel_time_t msg_rtime; /* last msgrcv time */
17 __kernel_time_t msg_ctime; /* last change time */
18 unsigned long msg_cbytes; /* current number of bytes on queue */
19 unsigned long msg_qnum; /* number of messages in queue */
20 unsigned long msg_qbytes; /* max number of bytes on queue */
21 __kernel_pid_t msg_lspid; /* pid of last msgsnd */
22 __kernel_pid_t msg_lrpid; /* last receive pid */
23 unsigned long __unused1;
24 unsigned long __unused2;
25};
26
27#endif /* _SPARC64_MSGBUF_H */
diff --git a/include/asm-sparc64/namei.h b/include/asm-sparc64/namei.h
new file mode 100644
index 000000000000..ccda19e28695
--- /dev/null
+++ b/include/asm-sparc64/namei.h
@@ -0,0 +1,26 @@
1/* $Id: namei.h,v 1.17 2000/04/13 00:55:54 davem Exp $
2 * linux/include/asm-sparc64/namei.h
3 *
4 * Routines to handle famous /usr/gnemul/s*.
5 * Included from linux/fs/namei.c
6 */
7
8#ifndef __SPARC64_NAMEI_H
9#define __SPARC64_NAMEI_H
10
11#define SPARC_BSD_EMUL "/usr/gnemul/sunos/"
12#define SPARC_SOL_EMUL "/usr/gnemul/solaris/"
13
14static inline char * __emul_prefix(void)
15{
16 switch (current->personality) {
17 case PER_SUNOS:
18 return SPARC_BSD_EMUL;
19 case PER_SVR4:
20 return SPARC_SOL_EMUL;
21 default:
22 return NULL;
23 }
24}
25
26#endif /* __SPARC64_NAMEI_H */
diff --git a/include/asm-sparc64/ns87303.h b/include/asm-sparc64/ns87303.h
new file mode 100644
index 000000000000..6d58fdf349b5
--- /dev/null
+++ b/include/asm-sparc64/ns87303.h
@@ -0,0 +1,119 @@
1/* $Id: ns87303.h,v 1.3 2000/01/09 15:16:34 ecd Exp $
2 * ns87303.h: Configuration Register Description for the
3 * National Semiconductor PC87303 (SuperIO).
4 *
5 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
6 */
7
8#ifndef _SPARC_NS87303_H
9#define _SPARC_NS87303_H 1
10
11/*
12 * Control Register Index Values
13 */
14#define FER 0x00
15#define FAR 0x01
16#define PTR 0x02
17#define FCR 0x03
18#define PCR 0x04
19#define KRR 0x05
20#define PMC 0x06
21#define TUP 0x07
22#define SID 0x08
23#define ASC 0x09
24#define CS0CF0 0x0a
25#define CS0CF1 0x0b
26#define CS1CF0 0x0c
27#define CS1CF1 0x0d
28
29/* Function Enable Register (FER) bits */
30#define FER_EDM 0x10 /* Encoded Drive and Motor pin information */
31
32/* Function Address Register (FAR) bits */
33#define FAR_LPT_MASK 0x03
34#define FAR_LPTB 0x00
35#define FAR_LPTA 0x01
36#define FAR_LPTC 0x02
37
38/* Power and Test Register (PTR) bits */
39#define PTR_LPTB_IRQ7 0x08
40#define PTR_LEVEL_IRQ 0x80 /* When not ECP/EPP: Use level IRQ */
41#define PTR_LPT_REG_DIR 0x80 /* When ECP/EPP: LPT CTR controlls direction */
42 /* of the parallel port */
43
44/* Function Control Register (FCR) bits */
45#define FCR_LDE 0x10 /* Logical Drive Exchange */
46#define FCR_ZWS_ENA 0x20 /* Enable short host read/write in ECP/EPP */
47
48/* Printer Control Register (PCR) bits */
49#define PCR_EPP_ENABLE 0x01
50#define PCR_EPP_IEEE 0x02 /* Enable EPP Version 1.9 (IEEE 1284) */
51#define PCR_ECP_ENABLE 0x04
52#define PCR_ECP_CLK_ENA 0x08 /* If 0 ECP Clock is stopped on Power down */
53#define PCR_IRQ_POLAR 0x20 /* If 0 IRQ is level high or negative pulse, */
54 /* if 1 polarity is inverted */
55#define PCR_IRQ_ODRAIN 0x40 /* If 1, IRQ is open drain */
56
57/* Tape UARTs and Parallel Port Config Register (TUP) bits */
58#define TUP_EPP_TIMO 0x02 /* Enable EPP timeout IRQ */
59
60/* Advanced SuperIO Config Register (ASC) bits */
61#define ASC_LPT_IRQ7 0x01 /* Always use IRQ7 for LPT */
62#define ASC_DRV2_SEL 0x02 /* Logical Drive Exchange controlled by TDR */
63
64#define FER_RESERVED 0x00
65#define FAR_RESERVED 0x00
66#define PTR_RESERVED 0x73
67#define FCR_RESERVED 0xc4
68#define PCR_RESERVED 0x10
69#define KRR_RESERVED 0x00
70#define PMC_RESERVED 0x98
71#define TUP_RESERVED 0xfb
72#define SIP_RESERVED 0x00
73#define ASC_RESERVED 0x18
74#define CS0CF0_RESERVED 0x00
75#define CS0CF1_RESERVED 0x08
76#define CS1CF0_RESERVED 0x00
77#define CS1CF1_RESERVED 0x08
78
79#ifdef __KERNEL__
80
81#include <linux/spinlock.h>
82
83#include <asm/system.h>
84#include <asm/io.h>
85
86extern spinlock_t ns87303_lock;
87
88static __inline__ int ns87303_modify(unsigned long port, unsigned int index,
89 unsigned char clr, unsigned char set)
90{
91 static unsigned char reserved[] = {
92 FER_RESERVED, FAR_RESERVED, PTR_RESERVED, FCR_RESERVED,
93 PCR_RESERVED, KRR_RESERVED, PMC_RESERVED, TUP_RESERVED,
94 SIP_RESERVED, ASC_RESERVED, CS0CF0_RESERVED, CS0CF1_RESERVED,
95 CS1CF0_RESERVED, CS1CF1_RESERVED
96 };
97 unsigned long flags;
98 unsigned char value;
99
100 if (index > 0x0d)
101 return -EINVAL;
102
103 spin_lock_irqsave(&ns87303_lock, flags);
104
105 outb(index, port);
106 value = inb(port + 1);
107 value &= ~(reserved[index] | clr);
108 value |= set;
109 outb(value, port + 1);
110 outb(value, port + 1);
111
112 spin_unlock_irqrestore(&ns87303_lock, flags);
113
114 return 0;
115}
116
117#endif /* __KERNEL__ */
118
119#endif /* !(_SPARC_NS87303_H) */
diff --git a/include/asm-sparc64/openprom.h b/include/asm-sparc64/openprom.h
new file mode 100644
index 000000000000..0a336901d585
--- /dev/null
+++ b/include/asm-sparc64/openprom.h
@@ -0,0 +1,281 @@
1/* $Id: openprom.h,v 1.9 2001/03/16 10:22:02 davem Exp $ */
2#ifndef __SPARC64_OPENPROM_H
3#define __SPARC64_OPENPROM_H
4
5/* openprom.h: Prom structures and defines for access to the OPENBOOT
6 * prom routines and data areas.
7 *
8 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
9 */
10
11#ifndef __ASSEMBLY__
12/* V0 prom device operations. */
13struct linux_dev_v0_funcs {
14 int (*v0_devopen)(char *device_str);
15 int (*v0_devclose)(int dev_desc);
16 int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
17 int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
18 int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf);
19 int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf);
20 int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
21 int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
22 int (*v0_seekdev)(int dev_desc, long logical_offst, int from);
23};
24
25/* V2 and later prom device operations. */
26struct linux_dev_v2_funcs {
27 int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
28 char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
29 void (*v2_dumb_mem_free)(char *va, unsigned sz);
30
31 /* To map devices into virtual I/O space. */
32 char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned paddr, unsigned sz);
33 void (*v2_dumb_munmap)(char *virta, unsigned size);
34
35 int (*v2_dev_open)(char *devpath);
36 void (*v2_dev_close)(int d);
37 int (*v2_dev_read)(int d, char *buf, int nbytes);
38 int (*v2_dev_write)(int d, char *buf, int nbytes);
39 int (*v2_dev_seek)(int d, int hi, int lo);
40
41 /* Never issued (multistage load support) */
42 void (*v2_wheee2)(void);
43 void (*v2_wheee3)(void);
44};
45
46struct linux_mlist_v0 {
47 struct linux_mlist_v0 *theres_more;
48 unsigned start_adr;
49 unsigned num_bytes;
50};
51
52struct linux_mem_v0 {
53 struct linux_mlist_v0 **v0_totphys;
54 struct linux_mlist_v0 **v0_prommap;
55 struct linux_mlist_v0 **v0_available; /* What we can use */
56};
57
58/* Arguments sent to the kernel from the boot prompt. */
59struct linux_arguments_v0 {
60 char *argv[8];
61 char args[100];
62 char boot_dev[2];
63 int boot_dev_ctrl;
64 int boot_dev_unit;
65 int dev_partition;
66 char *kernel_file_name;
67 void *aieee1; /* XXX */
68};
69
70/* V2 and up boot things. */
71struct linux_bootargs_v2 {
72 char **bootpath;
73 char **bootargs;
74 int *fd_stdin;
75 int *fd_stdout;
76};
77
78/* The top level PROM vector. */
79struct linux_romvec {
80 /* Version numbers. */
81 unsigned int pv_magic_cookie;
82 unsigned int pv_romvers;
83 unsigned int pv_plugin_revision;
84 unsigned int pv_printrev;
85
86 /* Version 0 memory descriptors. */
87 struct linux_mem_v0 pv_v0mem;
88
89 /* Node operations. */
90 struct linux_nodeops *pv_nodeops;
91
92 char **pv_bootstr;
93 struct linux_dev_v0_funcs pv_v0devops;
94
95 char *pv_stdin;
96 char *pv_stdout;
97#define PROMDEV_KBD 0 /* input from keyboard */
98#define PROMDEV_SCREEN 0 /* output to screen */
99#define PROMDEV_TTYA 1 /* in/out to ttya */
100#define PROMDEV_TTYB 2 /* in/out to ttyb */
101
102 /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
103 int (*pv_getchar)(void);
104 void (*pv_putchar)(int ch);
105
106 /* Non-blocking variants. */
107 int (*pv_nbgetchar)(void);
108 int (*pv_nbputchar)(int ch);
109
110 void (*pv_putstr)(char *str, int len);
111
112 /* Miscellany. */
113 void (*pv_reboot)(char *bootstr);
114 void (*pv_printf)(__const__ char *fmt, ...);
115 void (*pv_abort)(void);
116 __volatile__ int *pv_ticks;
117 void (*pv_halt)(void);
118 void (**pv_synchook)(void);
119
120 /* Evaluate a forth string, not different proto for V0 and V2->up. */
121 union {
122 void (*v0_eval)(int len, char *str);
123 void (*v2_eval)(char *str);
124 } pv_fortheval;
125
126 struct linux_arguments_v0 **pv_v0bootargs;
127
128 /* Get ether address. */
129 unsigned int (*pv_enaddr)(int d, char *enaddr);
130
131 struct linux_bootargs_v2 pv_v2bootargs;
132 struct linux_dev_v2_funcs pv_v2devops;
133
134 int filler[15];
135
136 /* This one is sun4c/sun4 only. */
137 void (*pv_setctxt)(int ctxt, char *va, int pmeg);
138
139 /* Prom version 3 Multiprocessor routines. This stuff is crazy.
140 * No joke. Calling these when there is only one cpu probably
141 * crashes the machine, have to test this. :-)
142 */
143
144 /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
145 * 'thiscontext' executing at address 'prog_counter'
146 */
147 int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr,
148 int thiscontext, char *prog_counter);
149
150 /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
151 * until a resume cpu call is made.
152 */
153 int (*v3_cpustop)(unsigned int whichcpu);
154
155 /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
156 * resume cpu call is made.
157 */
158 int (*v3_cpuidle)(unsigned int whichcpu);
159
160 /* v3_cpuresume() will resume processor 'whichcpu' executing
161 * starting with whatever 'pc' and 'npc' were left at the
162 * last 'idle' or 'stop' call.
163 */
164 int (*v3_cpuresume)(unsigned int whichcpu);
165};
166
167/* Routines for traversing the prom device tree. */
168struct linux_nodeops {
169 int (*no_nextnode)(int node);
170 int (*no_child)(int node);
171 int (*no_proplen)(int node, char *name);
172 int (*no_getprop)(int node, char *name, char *val);
173 int (*no_setprop)(int node, char *name, char *val, int len);
174 char * (*no_nextprop)(int node, char *name);
175};
176
177/* More fun PROM structures for device probing. */
178#define PROMREG_MAX 16
179#define PROMVADDR_MAX 16
180#define PROMINTR_MAX 15
181
182struct linux_prom_registers {
183 unsigned which_io; /* hi part of physical address */
184 unsigned phys_addr; /* The physical address of this register */
185 int reg_size; /* How many bytes does this register take up? */
186};
187
188struct linux_prom64_registers {
189 long phys_addr;
190 long reg_size;
191};
192
193struct linux_prom_irqs {
194 int pri; /* IRQ priority */
195 int vector; /* This is foobar, what does it do? */
196};
197
198/* Element of the "ranges" vector */
199struct linux_prom_ranges {
200 unsigned int ot_child_space;
201 unsigned int ot_child_base; /* Bus feels this */
202 unsigned int ot_parent_space;
203 unsigned int ot_parent_base; /* CPU looks from here */
204 unsigned int or_size;
205};
206
207struct linux_prom64_ranges {
208 unsigned long ot_child_base; /* Bus feels this */
209 unsigned long ot_parent_base; /* CPU looks from here */
210 unsigned long or_size;
211};
212
213/* Ranges and reg properties are a bit different for PCI. */
214struct linux_prom_pci_registers {
215 unsigned int phys_hi;
216 unsigned int phys_mid;
217 unsigned int phys_lo;
218
219 unsigned int size_hi;
220 unsigned int size_lo;
221};
222
223struct linux_prom_pci_ranges {
224 unsigned int child_phys_hi; /* Only certain bits are encoded here. */
225 unsigned int child_phys_mid;
226 unsigned int child_phys_lo;
227
228 unsigned int parent_phys_hi;
229 unsigned int parent_phys_lo;
230
231 unsigned int size_hi;
232 unsigned int size_lo;
233};
234
235struct linux_prom_pci_intmap {
236 unsigned int phys_hi;
237 unsigned int phys_mid;
238 unsigned int phys_lo;
239
240 unsigned int interrupt;
241
242 int cnode;
243 unsigned int cinterrupt;
244};
245
246struct linux_prom_pci_intmask {
247 unsigned int phys_hi;
248 unsigned int phys_mid;
249 unsigned int phys_lo;
250 unsigned int interrupt;
251};
252
253struct linux_prom_ebus_ranges {
254 unsigned int child_phys_hi;
255 unsigned int child_phys_lo;
256
257 unsigned int parent_phys_hi;
258 unsigned int parent_phys_mid;
259 unsigned int parent_phys_lo;
260
261 unsigned int size;
262};
263
264struct linux_prom_ebus_intmap {
265 unsigned int phys_hi;
266 unsigned int phys_lo;
267
268 unsigned int interrupt;
269
270 int cnode;
271 unsigned int cinterrupt;
272};
273
274struct linux_prom_ebus_intmask {
275 unsigned int phys_hi;
276 unsigned int phys_lo;
277 unsigned int interrupt;
278};
279#endif /* !(__ASSEMBLY__) */
280
281#endif /* !(__SPARC64_OPENPROM_H) */
diff --git a/include/asm-sparc64/openpromio.h b/include/asm-sparc64/openpromio.h
new file mode 100644
index 000000000000..847ce2326ad5
--- /dev/null
+++ b/include/asm-sparc64/openpromio.h
@@ -0,0 +1,69 @@
1#ifndef _SPARC64_OPENPROMIO_H
2#define _SPARC64_OPENPROMIO_H
3
4#include <linux/compiler.h>
5#include <linux/ioctl.h>
6#include <linux/types.h>
7
8/*
9 * SunOS and Solaris /dev/openprom definitions. The ioctl values
10 * were chosen to be exactly equal to the SunOS equivalents.
11 */
12
13struct openpromio
14{
15 u_int oprom_size; /* Actual size of the oprom_array. */
16 char oprom_array[1]; /* Holds property names and values. */
17};
18
19#define OPROMMAXPARAM 4096 /* Maximum size of oprom_array. */
20
21#define OPROMGETOPT 0x20004F01
22#define OPROMSETOPT 0x20004F02
23#define OPROMNXTOPT 0x20004F03
24#define OPROMSETOPT2 0x20004F04
25#define OPROMNEXT 0x20004F05
26#define OPROMCHILD 0x20004F06
27#define OPROMGETPROP 0x20004F07
28#define OPROMNXTPROP 0x20004F08
29#define OPROMU2P 0x20004F09
30#define OPROMGETCONS 0x20004F0A
31#define OPROMGETFBNAME 0x20004F0B
32#define OPROMGETBOOTARGS 0x20004F0C
33/* Linux extensions */ /* Arguments in oprom_array: */
34#define OPROMSETCUR 0x20004FF0 /* int node - Sets current node */
35#define OPROMPCI2NODE 0x20004FF1 /* int pci_bus, pci_devfn - Sets current node to PCI device's node */
36#define OPROMPATH2NODE 0x20004FF2 /* char path[] - Set current node from fully qualified PROM path */
37
38/*
39 * Return values from OPROMGETCONS:
40 */
41
42#define OPROMCONS_NOT_WSCONS 0
43#define OPROMCONS_STDIN_IS_KBD 0x1 /* stdin device is kbd */
44#define OPROMCONS_STDOUT_IS_FB 0x2 /* stdout is a framebuffer */
45#define OPROMCONS_OPENPROM 0x4 /* supports openboot */
46
47
48/*
49 * NetBSD/OpenBSD /dev/openprom definitions.
50 */
51
52struct opiocdesc
53{
54 int op_nodeid; /* PROM Node ID (value-result) */
55 int op_namelen; /* Length of op_name. */
56 char __user *op_name; /* Pointer to the property name. */
57 int op_buflen; /* Length of op_buf (value-result) */
58 char __user *op_buf; /* Pointer to buffer. */
59};
60
61#define OPIOCGET _IOWR('O', 1, struct opiocdesc)
62#define OPIOCSET _IOW('O', 2, struct opiocdesc)
63#define OPIOCNEXTPROP _IOWR('O', 3, struct opiocdesc)
64#define OPIOCGETOPTNODE _IOR('O', 4, int)
65#define OPIOCGETNEXT _IOWR('O', 5, int)
66#define OPIOCGETCHILD _IOWR('O', 6, int)
67
68#endif /* _SPARC64_OPENPROMIO_H */
69
diff --git a/include/asm-sparc64/oplib.h b/include/asm-sparc64/oplib.h
new file mode 100644
index 000000000000..a432d9e7daaa
--- /dev/null
+++ b/include/asm-sparc64/oplib.h
@@ -0,0 +1,360 @@
1/* $Id: oplib.h,v 1.14 2001/12/19 00:29:51 davem Exp $
2 * oplib.h: Describes the interface and available routines in the
3 * Linux Prom library.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 */
8
9#ifndef __SPARC64_OPLIB_H
10#define __SPARC64_OPLIB_H
11
12#include <linux/config.h>
13#include <asm/openprom.h>
14
15/* Enumeration to describe the prom major version we have detected. */
16enum prom_major_version {
17 PROM_V0, /* Original sun4c V0 prom */
18 PROM_V2, /* sun4c and early sun4m V2 prom */
19 PROM_V3, /* sun4m and later, up to sun4d/sun4e machines V3 */
20 PROM_P1275, /* IEEE compliant ISA based Sun PROM, only sun4u */
21 PROM_AP1000, /* actually no prom at all */
22};
23
24extern enum prom_major_version prom_vers;
25/* Revision, and firmware revision. */
26extern unsigned int prom_rev, prom_prev;
27
28/* Root node of the prom device tree, this stays constant after
29 * initialization is complete.
30 */
31extern int prom_root_node;
32
33/* PROM stdin and stdout */
34extern int prom_stdin, prom_stdout;
35
36/* /chosen node of the prom device tree, this stays constant after
37 * initialization is complete.
38 */
39extern int prom_chosen_node;
40
41struct linux_mlist_p1275 {
42 struct linux_mlist_p1275 *theres_more;
43 unsigned long start_adr;
44 unsigned long num_bytes;
45};
46
47struct linux_mem_p1275 {
48 struct linux_mlist_p1275 **p1275_totphys;
49 struct linux_mlist_p1275 **p1275_prommap;
50 struct linux_mlist_p1275 **p1275_available; /* What we can use */
51};
52
53/* The functions... */
54
55/* You must call prom_init() before using any of the library services,
56 * preferably as early as possible. Pass it the romvec pointer.
57 */
58extern void prom_init(void *cif_handler, void *cif_stack);
59
60/* Boot argument acquisition, returns the boot command line string. */
61extern char *prom_getbootargs(void);
62
63/* Device utilities. */
64
65/* Device operations. */
66
67/* Open the device described by the passed string. Note, that the format
68 * of the string is different on V0 vs. V2->higher proms. The caller must
69 * know what he/she is doing! Returns the device descriptor, an int.
70 */
71extern int prom_devopen(char *device_string);
72
73/* Close a previously opened device described by the passed integer
74 * descriptor.
75 */
76extern int prom_devclose(int device_handle);
77
78/* Do a seek operation on the device described by the passed integer
79 * descriptor.
80 */
81extern void prom_seek(int device_handle, unsigned int seek_hival,
82 unsigned int seek_lowval);
83
84/* Machine memory configuration routine. */
85
86/* This function returns a V0 format memory descriptor table, it has three
87 * entries. One for the total amount of physical ram on the machine, one
88 * for the amount of physical ram available, and one describing the virtual
89 * areas which are allocated by the prom. So, in a sense the physical
90 * available is a calculation of the total physical minus the physical mapped
91 * by the prom with virtual mappings.
92 *
93 * These lists are returned pre-sorted, this should make your life easier
94 * since the prom itself is way too lazy to do such nice things.
95 */
96extern struct linux_mem_p1275 *prom_meminfo(void);
97
98/* Miscellaneous routines, don't really fit in any category per se. */
99
100/* Reboot the machine with the command line passed. */
101extern void prom_reboot(char *boot_command);
102
103/* Evaluate the forth string passed. */
104extern void prom_feval(char *forth_string);
105
106/* Enter the prom, with possibility of continuation with the 'go'
107 * command in newer proms.
108 */
109extern void prom_cmdline(void);
110
111/* Enter the prom, with no chance of continuation for the stand-alone
112 * which calls this.
113 */
114extern void prom_halt(void) __attribute__ ((noreturn));
115
116/* Halt and power-off the machine. */
117extern void prom_halt_power_off(void) __attribute__ ((noreturn));
118
119/* Set the PROM 'sync' callback function to the passed function pointer.
120 * When the user gives the 'sync' command at the prom prompt while the
121 * kernel is still active, the prom will call this routine.
122 *
123 */
124typedef int (*callback_func_t)(long *cmd);
125extern void prom_setcallback(callback_func_t func_ptr);
126
127/* Acquire the IDPROM of the root node in the prom device tree. This
128 * gets passed a buffer where you would like it stuffed. The return value
129 * is the format type of this idprom or 0xff on error.
130 */
131extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
132
133/* Get the prom major version. */
134extern int prom_version(void);
135
136/* Get the prom plugin revision. */
137extern int prom_getrev(void);
138
139/* Get the prom firmware revision. */
140extern int prom_getprev(void);
141
142/* Character operations to/from the console.... */
143
144/* Non-blocking get character from console. */
145extern int prom_nbgetchar(void);
146
147/* Non-blocking put character to console. */
148extern int prom_nbputchar(char character);
149
150/* Blocking get character from console. */
151extern char prom_getchar(void);
152
153/* Blocking put character to console. */
154extern void prom_putchar(char character);
155
156/* Prom's internal routines, don't use in kernel/boot code. */
157extern void prom_printf(char *fmt, ...);
158extern void prom_write(const char *buf, unsigned int len);
159
160/* Query for input device type */
161
162enum prom_input_device {
163 PROMDEV_IKBD, /* input from keyboard */
164 PROMDEV_ITTYA, /* input from ttya */
165 PROMDEV_ITTYB, /* input from ttyb */
166 PROMDEV_I_UNK,
167};
168
169extern enum prom_input_device prom_query_input_device(void);
170
171/* Query for output device type */
172
173enum prom_output_device {
174 PROMDEV_OSCREEN, /* to screen */
175 PROMDEV_OTTYA, /* to ttya */
176 PROMDEV_OTTYB, /* to ttyb */
177 PROMDEV_O_UNK,
178};
179
180extern enum prom_output_device prom_query_output_device(void);
181
182/* Multiprocessor operations... */
183#ifdef CONFIG_SMP
184/* Start the CPU with the given device tree node, context table, and context
185 * at the passed program counter.
186 */
187extern void prom_startcpu(int cpunode, unsigned long pc, unsigned long o0);
188
189/* Stop the current CPU. */
190extern void prom_stopself(void);
191
192/* Idle the current CPU. */
193extern void prom_idleself(void);
194
195/* Resume the CPU with the passed device tree node. */
196extern void prom_resumecpu(int cpunode);
197#endif
198
199/* Power management interfaces. */
200
201/* Put the current CPU to sleep. */
202extern void prom_sleepself(void);
203
204/* Put the entire system to sleep. */
205extern int prom_sleepsystem(void);
206
207/* Initiate a wakeup event. */
208extern int prom_wakeupsystem(void);
209
210/* MMU and memory related OBP interfaces. */
211
212/* Get unique string identifying SIMM at given physical address. */
213extern int prom_getunumber(int syndrome_code,
214 unsigned long phys_addr,
215 char *buf, int buflen);
216
217/* Retain physical memory to the caller across soft resets. */
218extern unsigned long prom_retain(char *name,
219 unsigned long pa_low, unsigned long pa_high,
220 long size, long align);
221
222/* Load explicit I/D TLB entries into the calling processor. */
223extern long prom_itlb_load(unsigned long index,
224 unsigned long tte_data,
225 unsigned long vaddr);
226
227extern long prom_dtlb_load(unsigned long index,
228 unsigned long tte_data,
229 unsigned long vaddr);
230
231/* Map/Unmap client program address ranges. First the format of
232 * the mapping mode argument.
233 */
234#define PROM_MAP_WRITE 0x0001 /* Writable */
235#define PROM_MAP_READ 0x0002 /* Readable - sw */
236#define PROM_MAP_EXEC 0x0004 /* Executable - sw */
237#define PROM_MAP_LOCKED 0x0010 /* Locked, use i/dtlb load calls for this instead */
238#define PROM_MAP_CACHED 0x0020 /* Cacheable in both L1 and L2 caches */
239#define PROM_MAP_SE 0x0040 /* Side-Effects */
240#define PROM_MAP_GLOB 0x0080 /* Global */
241#define PROM_MAP_IE 0x0100 /* Invert-Endianness */
242#define PROM_MAP_DEFAULT (PROM_MAP_WRITE | PROM_MAP_READ | PROM_MAP_EXEC | PROM_MAP_CACHED)
243
244extern int prom_map(int mode, unsigned long size,
245 unsigned long vaddr, unsigned long paddr);
246extern void prom_unmap(unsigned long size, unsigned long vaddr);
247
248
249/* PROM device tree traversal functions... */
250
251#ifdef PROMLIB_INTERNAL
252
253/* Internal version of prom_getchild. */
254extern int __prom_getchild(int parent_node);
255
256/* Internal version of prom_getsibling. */
257extern int __prom_getsibling(int node);
258
259#endif
260
261/* Get the child node of the given node, or zero if no child exists. */
262extern int prom_getchild(int parent_node);
263
264/* Get the next sibling node of the given node, or zero if no further
265 * siblings exist.
266 */
267extern int prom_getsibling(int node);
268
269/* Get the length, at the passed node, of the given property type.
270 * Returns -1 on error (ie. no such property at this node).
271 */
272extern int prom_getproplen(int thisnode, char *property);
273
274/* Fetch the requested property using the given buffer. Returns
275 * the number of bytes the prom put into your buffer or -1 on error.
276 */
277extern int prom_getproperty(int thisnode, char *property,
278 char *prop_buffer, int propbuf_size);
279
280/* Acquire an integer property. */
281extern int prom_getint(int node, char *property);
282
283/* Acquire an integer property, with a default value. */
284extern int prom_getintdefault(int node, char *property, int defval);
285
286/* Acquire a boolean property, 0=FALSE 1=TRUE. */
287extern int prom_getbool(int node, char *prop);
288
289/* Acquire a string property, null string on error. */
290extern void prom_getstring(int node, char *prop, char *buf, int bufsize);
291
292/* Does the passed node have the given "name"? YES=1 NO=0 */
293extern int prom_nodematch(int thisnode, char *name);
294
295/* Puts in buffer a prom name in the form name@x,y or name (x for which_io
296 * and y for first regs phys address
297 */
298extern int prom_getname(int node, char *buf, int buflen);
299
300/* Search all siblings starting at the passed node for "name" matching
301 * the given string. Returns the node on success, zero on failure.
302 */
303extern int prom_searchsiblings(int node_start, char *name);
304
305/* Return the first property type, as a string, for the given node.
306 * Returns a null string on error. Buffer should be at least 32B long.
307 */
308extern char *prom_firstprop(int node, char *buffer);
309
310/* Returns the next property after the passed property for the given
311 * node. Returns null string on failure. Buffer should be at least 32B long.
312 */
313extern char *prom_nextprop(int node, char *prev_property, char *buffer);
314
315/* Returns 1 if the specified node has given property. */
316extern int prom_node_has_property(int node, char *property);
317
318/* Returns phandle of the path specified */
319extern int prom_finddevice(char *name);
320
321/* Set the indicated property at the given node with the passed value.
322 * Returns the number of bytes of your value that the prom took.
323 */
324extern int prom_setprop(int node, char *prop_name, char *prop_value,
325 int value_size);
326
327extern int prom_pathtoinode(char *path);
328extern int prom_inst2pkg(int);
329
330/* CPU probing helpers. */
331int cpu_find_by_instance(int instance, int *prom_node, int *mid);
332int cpu_find_by_mid(int mid, int *prom_node);
333
334/* Client interface level routines. */
335extern void prom_set_trap_table(unsigned long tba);
336
337extern long p1275_cmd (char *, long, ...);
338
339
340#if 0
341#define P1275_SIZE(x) ((((long)((x) / 32)) << 32) | (x))
342#else
343#define P1275_SIZE(x) x
344#endif
345
346/* We support at most 16 input and 1 output argument */
347#define P1275_ARG_NUMBER 0
348#define P1275_ARG_IN_STRING 1
349#define P1275_ARG_OUT_BUF 2
350#define P1275_ARG_OUT_32B 3
351#define P1275_ARG_IN_FUNCTION 4
352#define P1275_ARG_IN_BUF 5
353#define P1275_ARG_IN_64B 6
354
355#define P1275_IN(x) ((x) & 0xf)
356#define P1275_OUT(x) (((x) << 4) & 0xf0)
357#define P1275_INOUT(i,o) (P1275_IN(i)|P1275_OUT(o))
358#define P1275_ARG(n,x) ((x) << ((n)*3 + 8))
359
360#endif /* !(__SPARC64_OPLIB_H) */
diff --git a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h
new file mode 100644
index 000000000000..219ea043a14a
--- /dev/null
+++ b/include/asm-sparc64/page.h
@@ -0,0 +1,172 @@
1/* $Id: page.h,v 1.39 2002/02/09 19:49:31 davem Exp $ */
2
3#ifndef _SPARC64_PAGE_H
4#define _SPARC64_PAGE_H
5
6#include <linux/config.h>
7#include <asm/const.h>
8
9#if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
10#define PAGE_SHIFT 13
11#elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
12#define PAGE_SHIFT 16
13#elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
14#define PAGE_SHIFT 19
15#elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
16#define PAGE_SHIFT 22
17#else
18#error No page size specified in kernel configuration
19#endif
20
21#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
22#define PAGE_MASK (~(PAGE_SIZE-1))
23
24#ifdef __KERNEL__
25
26#ifndef __ASSEMBLY__
27
28extern void _clear_page(void *page);
29#define clear_page(X) _clear_page((void *)(X))
30struct page;
31extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
32#define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
33extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
34
35/* Unlike sparc32, sparc64's parameter passing API is more
36 * sane in that structures which as small enough are passed
37 * in registers instead of on the stack. Thus, setting
38 * STRICT_MM_TYPECHECKS does not generate worse code so
39 * let's enable it to get the type checking.
40 */
41
42#define STRICT_MM_TYPECHECKS
43
44#ifdef STRICT_MM_TYPECHECKS
45/* These are used to make use of C type-checking.. */
46typedef struct { unsigned long pte; } pte_t;
47typedef struct { unsigned long iopte; } iopte_t;
48typedef struct { unsigned int pmd; } pmd_t;
49typedef struct { unsigned int pgd; } pgd_t;
50typedef struct { unsigned long pgprot; } pgprot_t;
51
52#define pte_val(x) ((x).pte)
53#define iopte_val(x) ((x).iopte)
54#define pmd_val(x) ((x).pmd)
55#define pgd_val(x) ((x).pgd)
56#define pgprot_val(x) ((x).pgprot)
57
58#define __pte(x) ((pte_t) { (x) } )
59#define __iopte(x) ((iopte_t) { (x) } )
60#define __pmd(x) ((pmd_t) { (x) } )
61#define __pgd(x) ((pgd_t) { (x) } )
62#define __pgprot(x) ((pgprot_t) { (x) } )
63
64#else
65/* .. while these make it easier on the compiler */
66typedef unsigned long pte_t;
67typedef unsigned long iopte_t;
68typedef unsigned int pmd_t;
69typedef unsigned int pgd_t;
70typedef unsigned long pgprot_t;
71
72#define pte_val(x) (x)
73#define iopte_val(x) (x)
74#define pmd_val(x) (x)
75#define pgd_val(x) (x)
76#define pgprot_val(x) (x)
77
78#define __pte(x) (x)
79#define __iopte(x) (x)
80#define __pmd(x) (x)
81#define __pgd(x) (x)
82#define __pgprot(x) (x)
83
84#endif /* (STRICT_MM_TYPECHECKS) */
85
86#if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
87#define HPAGE_SHIFT 22
88#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
89#define HPAGE_SHIFT 19
90#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
91#define HPAGE_SHIFT 16
92#endif
93
94#ifdef CONFIG_HUGETLB_PAGE
95#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
96#define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
97#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
98#endif
99
100#define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
101 (_AC(0x0000000070000000,UL)) : (PAGE_OFFSET))
102
103#endif /* !(__ASSEMBLY__) */
104
105/* to align the pointer to the (next) page boundary */
106#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
107
108/* We used to stick this into a hard-coded global register (%g4)
109 * but that does not make sense anymore.
110 */
111#define PAGE_OFFSET _AC(0xFFFFF80000000000,UL)
112
113#ifndef __ASSEMBLY__
114
115#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
116#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
117
118/* PFNs are real physical page numbers. However, mem_map only begins to record
119 * per-page information starting at pfn_base. This is to handle systems where
120 * the first physical page in the machine is at some huge physical address,
121 * such as 4GB. This is common on a partitioned E10000, for example.
122 */
123extern struct page *pfn_to_page(unsigned long pfn);
124extern unsigned long page_to_pfn(struct page *);
125
126#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr)>>PAGE_SHIFT)
127
128#define pfn_valid(pfn) (((pfn)-(pfn_base)) < max_mapnr)
129#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
130
131#define virt_to_phys __pa
132#define phys_to_virt __va
133
134/* The following structure is used to hold the physical
135 * memory configuration of the machine. This is filled in
136 * probe_memory() and is later used by mem_init() to set up
137 * mem_map[]. We statically allocate SPARC_PHYS_BANKS of
138 * these structs, this is arbitrary. The entry after the
139 * last valid one has num_bytes==0.
140 */
141
142struct sparc_phys_banks {
143 unsigned long base_addr;
144 unsigned long num_bytes;
145};
146
147#define SPARC_PHYS_BANKS 32
148
149extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
150
151/* Pure 2^n version of get_order */
152static __inline__ int get_order(unsigned long size)
153{
154 int order;
155
156 size = (size-1) >> (PAGE_SHIFT-1);
157 order = -1;
158 do {
159 size >>= 1;
160 order++;
161 } while (size);
162 return order;
163}
164
165#endif /* !(__ASSEMBLY__) */
166
167#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
168 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
169
170#endif /* !(__KERNEL__) */
171
172#endif /* !(_SPARC64_PAGE_H) */
diff --git a/include/asm-sparc64/param.h b/include/asm-sparc64/param.h
new file mode 100644
index 000000000000..6a12f3ac0359
--- /dev/null
+++ b/include/asm-sparc64/param.h
@@ -0,0 +1,23 @@
1/* $Id: param.h,v 1.2 2000/10/30 21:01:41 davem Exp $ */
2#ifndef _ASMSPARC64_PARAM_H
3#define _ASMSPARC64_PARAM_H
4
5#ifdef __KERNEL__
6# define HZ 1000 /* Internal kernel timer frequency */
7# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
8# define CLOCKS_PER_SEC (USER_HZ)
9#endif
10
11#ifndef HZ
12#define HZ 100
13#endif
14
15#define EXEC_PAGESIZE 8192 /* Thanks for sun4's we carry baggage... */
16
17#ifndef NOGROUP
18#define NOGROUP (-1)
19#endif
20
21#define MAXHOSTNAMELEN 64 /* max length of hostname */
22
23#endif /* _ASMSPARC64_PARAM_H */
diff --git a/include/asm-sparc64/parport.h b/include/asm-sparc64/parport.h
new file mode 100644
index 000000000000..ab88349ddadc
--- /dev/null
+++ b/include/asm-sparc64/parport.h
@@ -0,0 +1,175 @@
1/* $Id: parport.h,v 1.11 2001/05/11 07:54:24 davem Exp $
2 * parport.h: sparc64 specific parport initialization and dma.
3 *
4 * Copyright (C) 1999 Eddie C. Dost (ecd@skynet.be)
5 */
6
7#ifndef _ASM_SPARC64_PARPORT_H
8#define _ASM_SPARC64_PARPORT_H 1
9
10#include <asm/ebus.h>
11#include <asm/isa.h>
12#include <asm/ns87303.h>
13
14#define PARPORT_PC_MAX_PORTS PARPORT_MAX
15
16static struct sparc_ebus_info {
17 struct ebus_dma_info info;
18 unsigned int addr;
19 unsigned int count;
20} sparc_ebus_dmas[PARPORT_PC_MAX_PORTS];
21
22static __inline__ void enable_dma(unsigned int dmanr)
23{
24 if (ebus_dma_request(&sparc_ebus_dmas[dmanr].info,
25 sparc_ebus_dmas[dmanr].addr,
26 sparc_ebus_dmas[dmanr].count))
27 BUG();
28
29 ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 1);
30}
31
32static __inline__ void disable_dma(unsigned int dmanr)
33{
34 ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 0);
35}
36
37static __inline__ void clear_dma_ff(unsigned int dmanr)
38{
39 /* nothing */
40}
41
42static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
43{
44 ebus_dma_prepare(&sparc_ebus_dmas[dmanr].info, (mode != DMA_MODE_WRITE));
45}
46
47static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int addr)
48{
49 sparc_ebus_dmas[dmanr].addr = addr;
50}
51
52static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
53{
54 sparc_ebus_dmas[dmanr].count = count;
55}
56
57static __inline__ unsigned int get_dma_residue(unsigned int dmanr)
58{
59 return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info);
60}
61
62static int ebus_ecpp_p(struct linux_ebus_device *edev)
63{
64 if (!strcmp(edev->prom_name, "ecpp"))
65 return 1;
66 if (!strcmp(edev->prom_name, "parallel")) {
67 char compat[19];
68 prom_getstring(edev->prom_node,
69 "compatible",
70 compat, sizeof(compat));
71 compat[18] = '\0';
72 if (!strcmp(compat, "ecpp"))
73 return 1;
74 if (!strcmp(compat, "ns87317-ecpp") &&
75 !strcmp(compat + 13, "ecpp"))
76 return 1;
77 }
78 return 0;
79}
80
81static int parport_isa_probe(int count)
82{
83 struct sparc_isa_bridge *isa_br;
84 struct sparc_isa_device *isa_dev;
85
86 for_each_isa(isa_br) {
87 for_each_isadev(isa_dev, isa_br) {
88 struct sparc_isa_device *child;
89 unsigned long base;
90
91 if (strcmp(isa_dev->prom_name, "dma"))
92 continue;
93
94 child = isa_dev->child;
95 while (child) {
96 if (!strcmp(child->prom_name, "parallel"))
97 break;
98 child = child->next;
99 }
100 if (!child)
101 continue;
102
103 base = child->resource.start;
104
105 /* No DMA, see commentary in
106 * asm-sparc64/floppy.h:isa_floppy_init()
107 */
108 if (parport_pc_probe_port(base, base + 0x400,
109 child->irq, PARPORT_DMA_NOFIFO,
110 child->bus->self))
111 count++;
112 }
113 }
114
115 return count;
116}
117
118static int parport_pc_find_nonpci_ports (int autoirq, int autodma)
119{
120 struct linux_ebus *ebus;
121 struct linux_ebus_device *edev;
122 int count = 0;
123
124 for_each_ebus(ebus) {
125 for_each_ebusdev(edev, ebus) {
126 if (ebus_ecpp_p(edev)) {
127 unsigned long base = edev->resource[0].start;
128 unsigned long config = edev->resource[1].start;
129 unsigned long d_base = edev->resource[2].start;
130 unsigned long d_len;
131
132 spin_lock_init(&sparc_ebus_dmas[count].info.lock);
133 d_len = (edev->resource[2].end -
134 d_base) + 1;
135 sparc_ebus_dmas[count].info.regs =
136 ioremap(d_base, d_len);
137 if (!sparc_ebus_dmas[count].info.regs)
138 continue;
139 sparc_ebus_dmas[count].info.flags = 0;
140 sparc_ebus_dmas[count].info.callback = NULL;
141 sparc_ebus_dmas[count].info.client_cookie = NULL;
142 sparc_ebus_dmas[count].info.irq = 0xdeadbeef;
143 strcpy(sparc_ebus_dmas[count].info.name, "parport");
144 if (ebus_dma_register(&sparc_ebus_dmas[count].info))
145 continue;
146 ebus_dma_irq_enable(&sparc_ebus_dmas[count].info, 1);
147
148 /* Configure IRQ to Push Pull, Level Low */
149 /* Enable ECP, set bit 2 of the CTR first */
150 outb(0x04, base + 0x02);
151 ns87303_modify(config, PCR,
152 PCR_EPP_ENABLE |
153 PCR_IRQ_ODRAIN,
154 PCR_ECP_ENABLE |
155 PCR_ECP_CLK_ENA |
156 PCR_IRQ_POLAR);
157
158 /* CTR bit 5 controls direction of port */
159 ns87303_modify(config, PTR,
160 0, PTR_LPT_REG_DIR);
161
162 if (parport_pc_probe_port(base, base + 0x400,
163 edev->irqs[0],
164 count, ebus->self))
165 count++;
166 }
167 }
168 }
169
170 count = parport_isa_probe(count);
171
172 return count;
173}
174
175#endif /* !(_ASM_SPARC64_PARPORT_H */
diff --git a/include/asm-sparc64/pbm.h b/include/asm-sparc64/pbm.h
new file mode 100644
index 000000000000..92999631c819
--- /dev/null
+++ b/include/asm-sparc64/pbm.h
@@ -0,0 +1,248 @@
1/* $Id: pbm.h,v 1.27 2001/08/12 13:18:23 davem Exp $
2 * pbm.h: UltraSparc PCI controller software state.
3 *
4 * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com)
5 */
6
7#ifndef __SPARC64_PBM_H
8#define __SPARC64_PBM_H
9
10#include <linux/types.h>
11#include <linux/pci.h>
12#include <linux/ioport.h>
13#include <linux/spinlock.h>
14
15#include <asm/io.h>
16#include <asm/page.h>
17#include <asm/oplib.h>
18
19/* The abstraction used here is that there are PCI controllers,
20 * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules
21 * underneath. Each PCI bus module uses an IOMMU (shared by both
22 * PBMs of a controller, or per-PBM), and if a streaming buffer
23 * is present, each PCI bus module has it's own. (ie. the IOMMU
24 * might be shared between PBMs, the STC is never shared)
25 * Furthermore, each PCI bus module controls it's own autonomous
26 * PCI bus.
27 */
28
29#define PBM_LOGCLUSTERS 3
30#define PBM_NCLUSTERS (1 << PBM_LOGCLUSTERS)
31
32struct pci_controller_info;
33
34/* This contains the software state necessary to drive a PCI
35 * controller's IOMMU.
36 */
37struct pci_iommu {
38 /* This protects the controller's IOMMU and all
39 * streaming buffers underneath.
40 */
41 spinlock_t lock;
42
43 /* Context allocator. */
44 unsigned int iommu_cur_ctx;
45
46 /* IOMMU page table, a linear array of ioptes. */
47 iopte_t *page_table; /* The page table itself. */
48 int page_table_sz_bits; /* log2 of ow many pages does it map? */
49
50 /* Base PCI memory space address where IOMMU mappings
51 * begin.
52 */
53 u32 page_table_map_base;
54
55 /* IOMMU Controller Registers */
56 unsigned long iommu_control; /* IOMMU control register */
57 unsigned long iommu_tsbbase; /* IOMMU page table base register */
58 unsigned long iommu_flush; /* IOMMU page flush register */
59 unsigned long iommu_ctxflush; /* IOMMU context flush register */
60
61 /* This is a register in the PCI controller, which if
62 * read will have no side-effects but will guarantee
63 * completion of all previous writes into IOMMU/STC.
64 */
65 unsigned long write_complete_reg;
66
67 /* The lowest used consistent mapping entry. Since
68 * we allocate consistent maps out of cluster 0 this
69 * is relative to the beginning of closter 0.
70 */
71 u32 lowest_consistent_map;
72
73 /* In order to deal with some buggy third-party PCI bridges that
74 * do wrong prefetching, we never mark valid mappings as invalid.
75 * Instead we point them at this dummy page.
76 */
77 unsigned long dummy_page;
78 unsigned long dummy_page_pa;
79
80 /* If PBM_NCLUSTERS is ever decreased to 4 or lower,
81 * or if largest supported page_table_sz * 8K goes above
82 * 2GB, you must increase the size of the type of
83 * these counters. You have been duly warned. -DaveM
84 */
85 struct {
86 u16 next;
87 u16 flush;
88 } alloc_info[PBM_NCLUSTERS];
89
90 /* Here a PCI controller driver describes the areas of
91 * PCI memory space where DMA to/from physical memory
92 * are addressed. Drivers interrogate the PCI layer
93 * if their device has addressing limitations. They
94 * do so via pci_dma_supported, and pass in a mask of
95 * DMA address bits their device can actually drive.
96 *
97 * The test for being usable is:
98 * (device_mask & dma_addr_mask) == dma_addr_mask
99 */
100 u32 dma_addr_mask;
101};
102
103extern void pci_iommu_table_init(struct pci_iommu *, int);
104
105/* This describes a PCI bus module's streaming buffer. */
106struct pci_strbuf {
107 int strbuf_enabled; /* Present and using it? */
108
109 /* Streaming Buffer Control Registers */
110 unsigned long strbuf_control; /* STC control register */
111 unsigned long strbuf_pflush; /* STC page flush register */
112 unsigned long strbuf_fsync; /* STC flush synchronization reg */
113 unsigned long strbuf_ctxflush; /* STC context flush register */
114 unsigned long strbuf_ctxmatch_base; /* STC context flush match reg */
115 unsigned long strbuf_flushflag_pa; /* Physical address of flush flag */
116 volatile unsigned long *strbuf_flushflag; /* The flush flag itself */
117
118 /* And this is the actual flush flag area.
119 * We allocate extra because the chips require
120 * a 64-byte aligned area.
121 */
122 volatile unsigned long __flushflag_buf[(64 + (64 - 1)) / sizeof(long)];
123};
124
125#define PCI_STC_FLUSHFLAG_INIT(STC) \
126 (*((STC)->strbuf_flushflag) = 0UL)
127#define PCI_STC_FLUSHFLAG_SET(STC) \
128 (*((STC)->strbuf_flushflag) != 0UL)
129
130/* There can be quite a few ranges and interrupt maps on a PCI
131 * segment. Thus...
132 */
133#define PROM_PCIRNG_MAX 64
134#define PROM_PCIIMAP_MAX 64
135
136struct pci_pbm_info {
137 /* PCI controller we sit under. */
138 struct pci_controller_info *parent;
139
140 /* Physical address base of controller registers. */
141 unsigned long controller_regs;
142
143 /* Physical address base of PBM registers. */
144 unsigned long pbm_regs;
145
146 /* Opaque 32-bit system bus Port ID. */
147 u32 portid;
148
149 /* Chipset version information. */
150 int chip_type;
151#define PBM_CHIP_TYPE_SABRE 1
152#define PBM_CHIP_TYPE_PSYCHO 2
153#define PBM_CHIP_TYPE_SCHIZO 3
154#define PBM_CHIP_TYPE_SCHIZO_PLUS 4
155#define PBM_CHIP_TYPE_TOMATILLO 5
156 int chip_version;
157 int chip_revision;
158
159 /* Name used for top-level resources. */
160 char name[64];
161
162 /* OBP specific information. */
163 int prom_node;
164 char prom_name[64];
165 struct linux_prom_pci_ranges pbm_ranges[PROM_PCIRNG_MAX];
166 int num_pbm_ranges;
167 struct linux_prom_pci_intmap pbm_intmap[PROM_PCIIMAP_MAX];
168 int num_pbm_intmap;
169 struct linux_prom_pci_intmask pbm_intmask;
170 u64 ino_bitmap;
171
172 /* PBM I/O and Memory space resources. */
173 struct resource io_space;
174 struct resource mem_space;
175
176 /* Base of PCI Config space, can be per-PBM or shared. */
177 unsigned long config_space;
178
179 /* State of 66MHz capabilities on this PBM. */
180 int is_66mhz_capable;
181 int all_devs_66mhz;
182
183 /* This PBM's streaming buffer. */
184 struct pci_strbuf stc;
185
186 /* IOMMU state, potentially shared by both PBM segments. */
187 struct pci_iommu *iommu;
188
189 /* PCI slot mapping. */
190 unsigned int pci_first_slot;
191
192 /* Now things for the actual PCI bus probes. */
193 unsigned int pci_first_busno;
194 unsigned int pci_last_busno;
195 struct pci_bus *pci_bus;
196};
197
198struct pci_controller_info {
199 /* List of all PCI controllers. */
200 struct pci_controller_info *next;
201
202 /* Each controller gets a unique index, used mostly for
203 * error logging purposes.
204 */
205 int index;
206
207 /* Do the PBMs both exist in the same PCI domain? */
208 int pbms_same_domain;
209
210 /* The PCI bus modules controlled by us. */
211 struct pci_pbm_info pbm_A;
212 struct pci_pbm_info pbm_B;
213
214 /* Operations which are controller specific. */
215 void (*scan_bus)(struct pci_controller_info *);
216 unsigned int (*irq_build)(struct pci_pbm_info *, struct pci_dev *, unsigned int);
217 void (*base_address_update)(struct pci_dev *, int);
218 void (*resource_adjust)(struct pci_dev *, struct resource *, struct resource *);
219
220 /* Now things for the actual PCI bus probes. */
221 struct pci_ops *pci_ops;
222 unsigned int pci_first_busno;
223 unsigned int pci_last_busno;
224
225 void *starfire_cookie;
226};
227
228/* PCI devices which are not bridges have this placed in their pci_dev
229 * sysdata member. This makes OBP aware PCI device drivers easier to
230 * code.
231 */
232struct pcidev_cookie {
233 struct pci_pbm_info *pbm;
234 char prom_name[64];
235 int prom_node;
236 struct linux_prom_pci_registers prom_regs[PROMREG_MAX];
237 int num_prom_regs;
238 struct linux_prom_pci_registers prom_assignments[PROMREG_MAX];
239 int num_prom_assignments;
240};
241
242/* Currently these are the same across all PCI controllers
243 * we support. Someday they may not be...
244 */
245#define PCI_IRQ_IGN 0x000007c0 /* Interrupt Group Number */
246#define PCI_IRQ_INO 0x0000003f /* Interrupt Number */
247
248#endif /* !(__SPARC64_PBM_H) */
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
new file mode 100644
index 000000000000..2a0c85cd1c11
--- /dev/null
+++ b/include/asm-sparc64/pci.h
@@ -0,0 +1,264 @@
1#ifndef __SPARC64_PCI_H
2#define __SPARC64_PCI_H
3
4#ifdef __KERNEL__
5
6#include <linux/fs.h>
7#include <linux/mm.h>
8
9/* Can be used to override the logic in pci_scan_bus for skipping
10 * already-configured bus numbers - to be used for buggy BIOSes
11 * or architectures with incomplete PCI setup by the loader.
12 */
13#define pcibios_assign_all_busses() 0
14#define pcibios_scan_all_fns(a, b) 0
15
16#define PCIBIOS_MIN_IO 0UL
17#define PCIBIOS_MIN_MEM 0UL
18
19#define PCI_IRQ_NONE 0xffffffff
20
21static inline void pcibios_set_master(struct pci_dev *dev)
22{
23 /* No special bus mastering setup handling */
24}
25
26static inline void pcibios_penalize_isa_irq(int irq)
27{
28 /* We don't do dynamic PCI IRQ allocation */
29}
30
31/* Dynamic DMA mapping stuff.
32 */
33
34/* The PCI address space does not equal the physical memory
35 * address space. The networking and block device layers use
36 * this boolean for bounce buffer decisions.
37 */
38#define PCI_DMA_BUS_IS_PHYS (0)
39
40#include <asm/scatterlist.h>
41
42struct pci_dev;
43
44/* Allocate and map kernel buffer using consistent mode DMA for a device.
45 * hwdev should be valid struct pci_dev pointer for PCI devices.
46 */
47extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle);
48
49/* Free and unmap a consistent DMA buffer.
50 * cpu_addr is what was returned from pci_alloc_consistent,
51 * size must be the same as what as passed into pci_alloc_consistent,
52 * and likewise dma_addr must be the same as what *dma_addrp was set to.
53 *
54 * References to the memory and mappings associated with cpu_addr/dma_addr
55 * past this call are illegal.
56 */
57extern void pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle);
58
59/* Map a single buffer of the indicated size for DMA in streaming mode.
60 * The 32-bit bus address to use is returned.
61 *
62 * Once the device is given the dma address, the device owns this memory
63 * until either pci_unmap_single or pci_dma_sync_single_for_cpu is performed.
64 */
65extern dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction);
66
67/* Unmap a single streaming mode DMA translation. The dma_addr and size
68 * must match what was provided for in a previous pci_map_single call. All
69 * other usages are undefined.
70 *
71 * After this call, reads by the cpu to the buffer are guaranteed to see
72 * whatever the device wrote there.
73 */
74extern void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction);
75
76/* No highmem on sparc64, plus we have an IOMMU, so mapping pages is easy. */
77#define pci_map_page(dev, page, off, size, dir) \
78 pci_map_single(dev, (page_address(page) + (off)), size, dir)
79#define pci_unmap_page(dev,addr,sz,dir) pci_unmap_single(dev,addr,sz,dir)
80
81/* pci_unmap_{single,page} is not a nop, thus... */
82#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
83 dma_addr_t ADDR_NAME;
84#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
85 __u32 LEN_NAME;
86#define pci_unmap_addr(PTR, ADDR_NAME) \
87 ((PTR)->ADDR_NAME)
88#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
89 (((PTR)->ADDR_NAME) = (VAL))
90#define pci_unmap_len(PTR, LEN_NAME) \
91 ((PTR)->LEN_NAME)
92#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
93 (((PTR)->LEN_NAME) = (VAL))
94
95/* Map a set of buffers described by scatterlist in streaming
96 * mode for DMA. This is the scatter-gather version of the
97 * above pci_map_single interface. Here the scatter gather list
98 * elements are each tagged with the appropriate dma address
99 * and length. They are obtained via sg_dma_{address,length}(SG).
100 *
101 * NOTE: An implementation may be able to use a smaller number of
102 * DMA address/length pairs than there are SG table elements.
103 * (for example via virtual mapping capabilities)
104 * The routine returns the number of addr/length pairs actually
105 * used, at most nents.
106 *
107 * Device ownership issues as mentioned above for pci_map_single are
108 * the same here.
109 */
110extern int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
111 int nents, int direction);
112
113/* Unmap a set of streaming mode DMA translations.
114 * Again, cpu read rules concerning calls here are the same as for
115 * pci_unmap_single() above.
116 */
117extern void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
118 int nhwents, int direction);
119
120/* Make physical memory consistent for a single
121 * streaming mode DMA translation after a transfer.
122 *
123 * If you perform a pci_map_single() but wish to interrogate the
124 * buffer using the cpu, yet do not wish to teardown the PCI dma
125 * mapping, you must call this function before doing so. At the
126 * next point you give the PCI dma address back to the card, you
127 * must first perform a pci_dma_sync_for_device, and then the
128 * device again owns the buffer.
129 */
130extern void pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
131 size_t size, int direction);
132
133static inline void
134pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
135 size_t size, int direction)
136{
137 /* No flushing needed to sync cpu writes to the device. */
138 BUG_ON(direction == PCI_DMA_NONE);
139}
140
141/* Make physical memory consistent for a set of streaming
142 * mode DMA translations after a transfer.
143 *
144 * The same as pci_dma_sync_single_* but for a scatter-gather list,
145 * same rules and usage.
146 */
147extern void pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, int nelems, int direction);
148
149static inline void
150pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
151 int nelems, int direction)
152{
153 /* No flushing needed to sync cpu writes to the device. */
154 BUG_ON(direction == PCI_DMA_NONE);
155}
156
157/* Return whether the given PCI device DMA address mask can
158 * be supported properly. For example, if your device can
159 * only drive the low 24-bits during PCI bus mastering, then
160 * you would pass 0x00ffffff as the mask to this function.
161 */
162extern int pci_dma_supported(struct pci_dev *hwdev, u64 mask);
163
164/* PCI IOMMU mapping bypass support. */
165
166/* PCI 64-bit addressing works for all slots on all controller
167 * types on sparc64. However, it requires that the device
168 * can drive enough of the 64 bits.
169 */
170#define PCI64_REQUIRED_MASK (~(dma64_addr_t)0)
171#define PCI64_ADDR_BASE 0xfffc000000000000UL
172
173/* Usage of the pci_dac_foo interfaces is only valid if this
174 * test passes.
175 */
176#define pci_dac_dma_supported(pci_dev, mask) \
177 ((((mask) & PCI64_REQUIRED_MASK) == PCI64_REQUIRED_MASK) ? 1 : 0)
178
179static inline dma64_addr_t
180pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction)
181{
182 return (PCI64_ADDR_BASE +
183 __pa(page_address(page)) + offset);
184}
185
186static inline struct page *
187pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
188{
189 unsigned long paddr = (dma_addr & PAGE_MASK) - PCI64_ADDR_BASE;
190
191 return virt_to_page(__va(paddr));
192}
193
194static inline unsigned long
195pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
196{
197 return (dma_addr & ~PAGE_MASK);
198}
199
200static inline void
201pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
202{
203 /* DAC cycle addressing does not make use of the
204 * PCI controller's streaming cache, so nothing to do.
205 */
206}
207
208static inline void
209pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
210{
211 /* DAC cycle addressing does not make use of the
212 * PCI controller's streaming cache, so nothing to do.
213 */
214}
215
216#define PCI_DMA_ERROR_CODE (~(dma_addr_t)0x0)
217
218static inline int pci_dma_mapping_error(dma_addr_t dma_addr)
219{
220 return (dma_addr == PCI_DMA_ERROR_CODE);
221}
222
223/* Return the index of the PCI controller for device PDEV. */
224
225extern int pci_domain_nr(struct pci_bus *bus);
226static inline int pci_proc_domain(struct pci_bus *bus)
227{
228 return 1;
229}
230
231/* Platform support for /proc/bus/pci/X/Y mmap()s. */
232
233#define HAVE_PCI_MMAP
234#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA
235#define get_pci_unmapped_area get_fb_unmapped_area
236
237extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
238 enum pci_mmap_state mmap_state,
239 int write_combine);
240
241/* Platform specific MWI support. */
242#define HAVE_ARCH_PCI_MWI
243extern int pcibios_prep_mwi(struct pci_dev *dev);
244
245extern void
246pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
247 struct resource *res);
248
249extern void
250pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
251 struct pci_bus_region *region);
252
253static inline void pcibios_add_platform_entries(struct pci_dev *dev)
254{
255}
256
257static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
258{
259 return PCI_IRQ_NONE;
260}
261
262#endif /* __KERNEL__ */
263
264#endif /* __SPARC64_PCI_H */
diff --git a/include/asm-sparc64/pconf.h b/include/asm-sparc64/pconf.h
new file mode 100644
index 000000000000..aad106a70908
--- /dev/null
+++ b/include/asm-sparc64/pconf.h
@@ -0,0 +1,25 @@
1/* $Id: pconf.h,v 1.1 1996/12/02 00:09:10 davem Exp $
2 * pconf.h: pathconf() and fpathconf() defines for SunOS
3 * system call compatibility.
4 *
5 * Copyright (C) 1995, 1996 David S. Miller (davem@caip.rutgers.edu)
6 */
7
8#ifndef _SPARC64_PCONF_H
9#define _SPARC64_PCONF_H
10
11#include <linux/fs.h>
12#include <linux/limits.h>
13
14#define _PCONF_LINK 1 /* Max number of links to an object */
15#define _PCONF_CANON 2 /* TTY input buffer line size */
16#define _PCONF_INPUT 3 /* Biggest packet a tty can imbibe at once */
17#define _PCONF_NAME 4 /* Filename length max */
18#define _PCONF_PATH 5 /* Max size of a pathname */
19#define _PCONF_PIPE 6 /* Buffer size for a pipe */
20#define _PCONF_CHRESTRICT 7 /* Can only root chown files? */
21#define _PCONF_NOTRUNC 8 /* Are pathnames truncated if too big? */
22#define _PCONF_VDISABLE 9 /* Magic char to disable special tty chars */
23#define _PCONF_MAXPCONF 9
24
25#endif /* !(_SPARC64_PCONF_H) */
diff --git a/include/asm-sparc64/percpu.h b/include/asm-sparc64/percpu.h
new file mode 100644
index 000000000000..aea4e51e7cd1
--- /dev/null
+++ b/include/asm-sparc64/percpu.h
@@ -0,0 +1,49 @@
1#ifndef __ARCH_SPARC64_PERCPU__
2#define __ARCH_SPARC64_PERCPU__
3
4#include <linux/compiler.h>
5
6#ifdef CONFIG_SMP
7
8extern void setup_per_cpu_areas(void);
9
10extern unsigned long __per_cpu_base;
11extern unsigned long __per_cpu_shift;
12#define __per_cpu_offset(__cpu) \
13 (__per_cpu_base + ((unsigned long)(__cpu) << __per_cpu_shift))
14
15/* Separate out the type, so (int[3], foo) works. */
16#define DEFINE_PER_CPU(type, name) \
17 __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
18
19register unsigned long __local_per_cpu_offset asm("g5");
20
21/* var is in discarded region: offset to particular copy we want */
22#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)))
23#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __local_per_cpu_offset))
24
25/* A macro to avoid #include hell... */
26#define percpu_modcopy(pcpudst, src, size) \
27do { \
28 unsigned int __i; \
29 for (__i = 0; __i < NR_CPUS; __i++) \
30 if (cpu_possible(__i)) \
31 memcpy((pcpudst)+__per_cpu_offset(__i), \
32 (src), (size)); \
33} while (0)
34#else /* ! SMP */
35
36#define DEFINE_PER_CPU(type, name) \
37 __typeof__(type) per_cpu__##name
38
39#define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var))
40#define __get_cpu_var(var) per_cpu__##var
41
42#endif /* SMP */
43
44#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
45
46#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
47#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
48
49#endif /* __ARCH_SPARC64_PERCPU__ */
diff --git a/include/asm-sparc64/perfctr.h b/include/asm-sparc64/perfctr.h
new file mode 100644
index 000000000000..836873002b75
--- /dev/null
+++ b/include/asm-sparc64/perfctr.h
@@ -0,0 +1,173 @@
1/*----------------------------------------
2 PERFORMANCE INSTRUMENTATION
3 Guillaume Thouvenin 08/10/98
4 David S. Miller 10/06/98
5 ---------------------------------------*/
6#ifndef PERF_COUNTER_API
7#define PERF_COUNTER_API
8
9/* sys_perfctr() interface. First arg is operation code
10 * from enumeration below. The meaning of further arguments
11 * are determined by the operation code.
12 *
13 * int sys_perfctr(int opcode, unsigned long arg0,
14 * unsigned long arg1, unsigned long arg2)
15 *
16 * Pointers which are passed by the user are pointers to 64-bit
17 * integers.
18 *
19 * Once enabled, performance counter state is retained until the
20 * process either exits or performs an exec. That is, performance
21 * counters remain enabled for fork/clone children.
22 */
23enum perfctr_opcode {
24 /* Enable UltraSparc performance counters, ARG0 is pointer
25 * to 64-bit accumulator for D0 counter in PIC, ARG1 is pointer
26 * to 64-bit accumulator for D1 counter. ARG2 is a pointer to
27 * the initial PCR register value to use.
28 */
29 PERFCTR_ON,
30
31 /* Disable UltraSparc performance counters. The PCR is written
32 * with zero and the user counter accumulator pointers and
33 * working PCR register value are forgotten.
34 */
35 PERFCTR_OFF,
36
37 /* Add current D0 and D1 PIC values into user pointers given
38 * in PERFCTR_ON operation. The PIC is cleared before returning.
39 */
40 PERFCTR_READ,
41
42 /* Clear the PIC register. */
43 PERFCTR_CLRPIC,
44
45 /* Begin using a new PCR value, the pointer to which is passed
46 * in ARG0. The PIC is also cleared after the new PCR value is
47 * written.
48 */
49 PERFCTR_SETPCR,
50
51 /* Store in pointer given in ARG0 the current PCR register value
52 * being used.
53 */
54 PERFCTR_GETPCR
55};
56
57/* I don't want the kernel's namespace to be polluted with this
58 * stuff when this file is included. --DaveM
59 */
60#ifndef __KERNEL__
61
62#define PRIV 0x00000001
63#define SYS 0x00000002
64#define USR 0x00000004
65
66/* Pic.S0 Selection Bit Field Encoding, Ultra-I/II */
67#define CYCLE_CNT 0x00000000
68#define INSTR_CNT 0x00000010
69#define DISPATCH0_IC_MISS 0x00000020
70#define DISPATCH0_STOREBUF 0x00000030
71#define IC_REF 0x00000080
72#define DC_RD 0x00000090
73#define DC_WR 0x000000A0
74#define LOAD_USE 0x000000B0
75#define EC_REF 0x000000C0
76#define EC_WRITE_HIT_RDO 0x000000D0
77#define EC_SNOOP_INV 0x000000E0
78#define EC_RD_HIT 0x000000F0
79
80/* Pic.S0 Selection Bit Field Encoding, Ultra-III */
81#define US3_CYCLE_CNT 0x00000000
82#define US3_INSTR_CNT 0x00000010
83#define US3_DISPATCH0_IC_MISS 0x00000020
84#define US3_DISPATCH0_BR_TGT 0x00000030
85#define US3_DISPATCH0_2ND_BR 0x00000040
86#define US3_RSTALL_STOREQ 0x00000050
87#define US3_RSTALL_IU_USE 0x00000060
88#define US3_IC_REF 0x00000080
89#define US3_DC_RD 0x00000090
90#define US3_DC_WR 0x000000a0
91#define US3_EC_REF 0x000000c0
92#define US3_EC_WR_HIT_RTO 0x000000d0
93#define US3_EC_SNOOP_INV 0x000000e0
94#define US3_EC_RD_MISS 0x000000f0
95#define US3_PC_PORT0_RD 0x00000100
96#define US3_SI_SNOOP 0x00000110
97#define US3_SI_CIQ_FLOW 0x00000120
98#define US3_SI_OWNED 0x00000130
99#define US3_SW_COUNT_0 0x00000140
100#define US3_IU_BR_MISS_TAKEN 0x00000150
101#define US3_IU_BR_COUNT_TAKEN 0x00000160
102#define US3_DISP_RS_MISPRED 0x00000170
103#define US3_FA_PIPE_COMPL 0x00000180
104#define US3_MC_READS_0 0x00000200
105#define US3_MC_READS_1 0x00000210
106#define US3_MC_READS_2 0x00000220
107#define US3_MC_READS_3 0x00000230
108#define US3_MC_STALLS_0 0x00000240
109#define US3_MC_STALLS_2 0x00000250
110
111/* Pic.S1 Selection Bit Field Encoding, Ultra-I/II */
112#define CYCLE_CNT_D1 0x00000000
113#define INSTR_CNT_D1 0x00000800
114#define DISPATCH0_IC_MISPRED 0x00001000
115#define DISPATCH0_FP_USE 0x00001800
116#define IC_HIT 0x00004000
117#define DC_RD_HIT 0x00004800
118#define DC_WR_HIT 0x00005000
119#define LOAD_USE_RAW 0x00005800
120#define EC_HIT 0x00006000
121#define EC_WB 0x00006800
122#define EC_SNOOP_CB 0x00007000
123#define EC_IT_HIT 0x00007800
124
125/* Pic.S1 Selection Bit Field Encoding, Ultra-III */
126#define US3_CYCLE_CNT_D1 0x00000000
127#define US3_INSTR_CNT_D1 0x00000800
128#define US3_DISPATCH0_MISPRED 0x00001000
129#define US3_IC_MISS_CANCELLED 0x00001800
130#define US3_RE_ENDIAN_MISS 0x00002000
131#define US3_RE_FPU_BYPASS 0x00002800
132#define US3_RE_DC_MISS 0x00003000
133#define US3_RE_EC_MISS 0x00003800
134#define US3_IC_MISS 0x00004000
135#define US3_DC_RD_MISS 0x00004800
136#define US3_DC_WR_MISS 0x00005000
137#define US3_RSTALL_FP_USE 0x00005800
138#define US3_EC_MISSES 0x00006000
139#define US3_EC_WB 0x00006800
140#define US3_EC_SNOOP_CB 0x00007000
141#define US3_EC_IC_MISS 0x00007800
142#define US3_RE_PC_MISS 0x00008000
143#define US3_ITLB_MISS 0x00008800
144#define US3_DTLB_MISS 0x00009000
145#define US3_WC_MISS 0x00009800
146#define US3_WC_SNOOP_CB 0x0000a000
147#define US3_WC_SCRUBBED 0x0000a800
148#define US3_WC_WB_WO_READ 0x0000b000
149#define US3_PC_SOFT_HIT 0x0000c000
150#define US3_PC_SNOOP_INV 0x0000c800
151#define US3_PC_HARD_HIT 0x0000d000
152#define US3_PC_PORT1_RD 0x0000d800
153#define US3_SW_COUNT_1 0x0000e000
154#define US3_IU_STAT_BR_MIS_UNTAKEN 0x0000e800
155#define US3_IU_STAT_BR_COUNT_UNTAKEN 0x0000f000
156#define US3_PC_MS_MISSES 0x0000f800
157#define US3_MC_WRITES_0 0x00010800
158#define US3_MC_WRITES_1 0x00011000
159#define US3_MC_WRITES_2 0x00011800
160#define US3_MC_WRITES_3 0x00012000
161#define US3_MC_STALLS_1 0x00012800
162#define US3_MC_STALLS_3 0x00013000
163#define US3_RE_RAW_MISS 0x00013800
164#define US3_FM_PIPE_COMPLETION 0x00014000
165
166struct vcounter_struct {
167 unsigned long long vcnt0;
168 unsigned long long vcnt1;
169};
170
171#endif /* !(__KERNEL__) */
172
173#endif /* !(PERF_COUNTER_API) */
diff --git a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h
new file mode 100644
index 000000000000..2c28e1f605b7
--- /dev/null
+++ b/include/asm-sparc64/pgalloc.h
@@ -0,0 +1,188 @@
1/* $Id: pgalloc.h,v 1.30 2001/12/21 04:56:17 davem Exp $ */
2#ifndef _SPARC64_PGALLOC_H
3#define _SPARC64_PGALLOC_H
4
5#include <linux/config.h>
6#include <linux/kernel.h>
7#include <linux/sched.h>
8#include <linux/mm.h>
9
10#include <asm/spitfire.h>
11#include <asm/cpudata.h>
12#include <asm/cacheflush.h>
13
14/* Page table allocation/freeing. */
15#ifdef CONFIG_SMP
16/* Sliiiicck */
17#define pgt_quicklists local_cpu_data()
18#else
19extern struct pgtable_cache_struct {
20 unsigned long *pgd_cache;
21 unsigned long *pte_cache[2];
22 unsigned int pgcache_size;
23} pgt_quicklists;
24#endif
25#define pgd_quicklist (pgt_quicklists.pgd_cache)
26#define pmd_quicklist ((unsigned long *)0)
27#define pte_quicklist (pgt_quicklists.pte_cache)
28#define pgtable_cache_size (pgt_quicklists.pgcache_size)
29
30static __inline__ void free_pgd_fast(pgd_t *pgd)
31{
32 preempt_disable();
33 *(unsigned long *)pgd = (unsigned long) pgd_quicklist;
34 pgd_quicklist = (unsigned long *) pgd;
35 pgtable_cache_size++;
36 preempt_enable();
37}
38
39static __inline__ pgd_t *get_pgd_fast(void)
40{
41 unsigned long *ret;
42
43 preempt_disable();
44 if((ret = pgd_quicklist) != NULL) {
45 pgd_quicklist = (unsigned long *)(*ret);
46 ret[0] = 0;
47 pgtable_cache_size--;
48 preempt_enable();
49 } else {
50 preempt_enable();
51 ret = (unsigned long *) __get_free_page(GFP_KERNEL|__GFP_REPEAT);
52 if(ret)
53 memset(ret, 0, PAGE_SIZE);
54 }
55 return (pgd_t *)ret;
56}
57
58static __inline__ void free_pgd_slow(pgd_t *pgd)
59{
60 free_page((unsigned long)pgd);
61}
62
63#ifdef DCACHE_ALIASING_POSSIBLE
64#define VPTE_COLOR(address) (((address) >> (PAGE_SHIFT + 10)) & 1UL)
65#define DCACHE_COLOR(address) (((address) >> PAGE_SHIFT) & 1UL)
66#else
67#define VPTE_COLOR(address) 0
68#define DCACHE_COLOR(address) 0
69#endif
70
71#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
72
73static __inline__ pmd_t *pmd_alloc_one_fast(struct mm_struct *mm, unsigned long address)
74{
75 unsigned long *ret;
76 int color = 0;
77
78 preempt_disable();
79 if (pte_quicklist[color] == NULL)
80 color = 1;
81
82 if((ret = (unsigned long *)pte_quicklist[color]) != NULL) {
83 pte_quicklist[color] = (unsigned long *)(*ret);
84 ret[0] = 0;
85 pgtable_cache_size--;
86 }
87 preempt_enable();
88
89 return (pmd_t *)ret;
90}
91
92static __inline__ pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
93{
94 pmd_t *pmd;
95
96 pmd = pmd_alloc_one_fast(mm, address);
97 if (!pmd) {
98 pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
99 if (pmd)
100 memset(pmd, 0, PAGE_SIZE);
101 }
102 return pmd;
103}
104
105static __inline__ void free_pmd_fast(pmd_t *pmd)
106{
107 unsigned long color = DCACHE_COLOR((unsigned long)pmd);
108
109 preempt_disable();
110 *(unsigned long *)pmd = (unsigned long) pte_quicklist[color];
111 pte_quicklist[color] = (unsigned long *) pmd;
112 pgtable_cache_size++;
113 preempt_enable();
114}
115
116static __inline__ void free_pmd_slow(pmd_t *pmd)
117{
118 free_page((unsigned long)pmd);
119}
120
121#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE)
122#define pmd_populate(MM,PMD,PTE_PAGE) \
123 pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE))
124
125extern pte_t *__pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address);
126
127static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
128{
129 return __pte_alloc_one_kernel(mm, address);
130}
131
132static inline struct page *
133pte_alloc_one(struct mm_struct *mm, unsigned long addr)
134{
135 pte_t *pte = __pte_alloc_one_kernel(mm, addr);
136
137 if (pte)
138 return virt_to_page(pte);
139
140 return NULL;
141}
142
143static __inline__ pte_t *pte_alloc_one_fast(struct mm_struct *mm, unsigned long address)
144{
145 unsigned long color = VPTE_COLOR(address);
146 unsigned long *ret;
147
148 preempt_disable();
149 if((ret = (unsigned long *)pte_quicklist[color]) != NULL) {
150 pte_quicklist[color] = (unsigned long *)(*ret);
151 ret[0] = 0;
152 pgtable_cache_size--;
153 }
154 preempt_enable();
155 return (pte_t *)ret;
156}
157
158static __inline__ void free_pte_fast(pte_t *pte)
159{
160 unsigned long color = DCACHE_COLOR((unsigned long)pte);
161
162 preempt_disable();
163 *(unsigned long *)pte = (unsigned long) pte_quicklist[color];
164 pte_quicklist[color] = (unsigned long *) pte;
165 pgtable_cache_size++;
166 preempt_enable();
167}
168
169static __inline__ void free_pte_slow(pte_t *pte)
170{
171 free_page((unsigned long)pte);
172}
173
174static inline void pte_free_kernel(pte_t *pte)
175{
176 free_pte_fast(pte);
177}
178
179static inline void pte_free(struct page *ptepage)
180{
181 free_pte_fast(page_address(ptepage));
182}
183
184#define pmd_free(pmd) free_pmd_fast(pmd)
185#define pgd_free(pgd) free_pgd_fast(pgd)
186#define pgd_alloc(mm) get_pgd_fast()
187
188#endif /* _SPARC64_PGALLOC_H */
diff --git a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h
new file mode 100644
index 000000000000..ca04ac105b69
--- /dev/null
+++ b/include/asm-sparc64/pgtable.h
@@ -0,0 +1,464 @@
1/* $Id: pgtable.h,v 1.156 2002/02/09 19:49:31 davem Exp $
2 * pgtable.h: SpitFire page table operations.
3 *
4 * Copyright 1996,1997 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 */
7
8#ifndef _SPARC64_PGTABLE_H
9#define _SPARC64_PGTABLE_H
10
11/* This file contains the functions and defines necessary to modify and use
12 * the SpitFire page tables.
13 */
14
15#include <asm-generic/pgtable-nopud.h>
16
17#include <linux/config.h>
18#include <linux/compiler.h>
19#include <asm/types.h>
20#include <asm/spitfire.h>
21#include <asm/asi.h>
22#include <asm/system.h>
23#include <asm/page.h>
24#include <asm/processor.h>
25#include <asm/const.h>
26
27/* The kernel image occupies 0x4000000 to 0x1000000 (4MB --> 16MB).
28 * The page copy blockops use 0x1000000 to 0x18000000 (16MB --> 24MB).
29 * The PROM resides in an area spanning 0xf0000000 to 0x100000000.
30 * The vmalloc area spans 0x140000000 to 0x200000000.
31 * There is a single static kernel PMD which maps from 0x0 to address
32 * 0x400000000.
33 */
34#define TLBTEMP_BASE _AC(0x0000000001000000,UL)
35#define MODULES_VADDR _AC(0x0000000002000000,UL)
36#define MODULES_LEN _AC(0x000000007e000000,UL)
37#define MODULES_END _AC(0x0000000080000000,UL)
38#define VMALLOC_START _AC(0x0000000140000000,UL)
39#define VMALLOC_END _AC(0x0000000200000000,UL)
40#define LOW_OBP_ADDRESS _AC(0x00000000f0000000,UL)
41#define HI_OBP_ADDRESS _AC(0x0000000100000000,UL)
42
43/* XXX All of this needs to be rethought so we can take advantage
44 * XXX cheetah's full 64-bit virtual address space, ie. no more hole
45 * XXX in the middle like on spitfire. -DaveM
46 */
47/*
48 * Given a virtual address, the lowest PAGE_SHIFT bits determine offset
49 * into the page; the next higher PAGE_SHIFT-3 bits determine the pte#
50 * in the proper pagetable (the -3 is from the 8 byte ptes, and each page
51 * table is a single page long). The next higher PMD_BITS determine pmd#
52 * in the proper pmdtable (where we must have PMD_BITS <= (PAGE_SHIFT-2)
53 * since the pmd entries are 4 bytes, and each pmd page is a single page
54 * long). Finally, the higher few bits determine pgde#.
55 */
56
57/* PMD_SHIFT determines the size of the area a second-level page
58 * table can map
59 */
60#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3))
61#define PMD_SIZE (1UL << PMD_SHIFT)
62#define PMD_MASK (~(PMD_SIZE-1))
63#define PMD_BITS (PAGE_SHIFT - 2)
64
65/* PGDIR_SHIFT determines what a third-level page table entry can map */
66#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3) + PMD_BITS)
67#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
68#define PGDIR_MASK (~(PGDIR_SIZE-1))
69#define PGDIR_BITS (PAGE_SHIFT - 2)
70
71#ifndef __ASSEMBLY__
72
73#include <linux/sched.h>
74
75/* Entries per page directory level. */
76#define PTRS_PER_PTE (1UL << (PAGE_SHIFT-3))
77#define PTRS_PER_PMD (1UL << PMD_BITS)
78#define PTRS_PER_PGD (1UL << PGDIR_BITS)
79
80/* Kernel has a separate 44bit address space. */
81#define FIRST_USER_PGD_NR 0
82
83#define pte_ERROR(e) __builtin_trap()
84#define pmd_ERROR(e) __builtin_trap()
85#define pgd_ERROR(e) __builtin_trap()
86
87#endif /* !(__ASSEMBLY__) */
88
89/* Spitfire/Cheetah TTE bits. */
90#define _PAGE_VALID _AC(0x8000000000000000,UL) /* Valid TTE */
91#define _PAGE_R _AC(0x8000000000000000,UL) /* Keep ref bit up to date*/
92#define _PAGE_SZ4MB _AC(0x6000000000000000,UL) /* 4MB Page */
93#define _PAGE_SZ512K _AC(0x4000000000000000,UL) /* 512K Page */
94#define _PAGE_SZ64K _AC(0x2000000000000000,UL) /* 64K Page */
95#define _PAGE_SZ8K _AC(0x0000000000000000,UL) /* 8K Page */
96#define _PAGE_NFO _AC(0x1000000000000000,UL) /* No Fault Only */
97#define _PAGE_IE _AC(0x0800000000000000,UL) /* Invert Endianness */
98#define _PAGE_SOFT2 _AC(0x07FC000000000000,UL) /* Software bits, set 2 */
99#define _PAGE_RES1 _AC(0x0003000000000000,UL) /* Reserved */
100#define _PAGE_SN _AC(0x0000800000000000,UL) /* (Cheetah) Snoop */
101#define _PAGE_RES2 _AC(0x0000780000000000,UL) /* Reserved */
102#define _PAGE_PADDR_SF _AC(0x000001FFFFFFE000,UL) /* (Spitfire) paddr[40:13]*/
103#define _PAGE_PADDR _AC(0x000007FFFFFFE000,UL) /* (Cheetah) paddr[42:13] */
104#define _PAGE_SOFT _AC(0x0000000000001F80,UL) /* Software bits */
105#define _PAGE_L _AC(0x0000000000000040,UL) /* Locked TTE */
106#define _PAGE_CP _AC(0x0000000000000020,UL) /* Cacheable in P-Cache */
107#define _PAGE_CV _AC(0x0000000000000010,UL) /* Cacheable in V-Cache */
108#define _PAGE_E _AC(0x0000000000000008,UL) /* side-Effect */
109#define _PAGE_P _AC(0x0000000000000004,UL) /* Privileged Page */
110#define _PAGE_W _AC(0x0000000000000002,UL) /* Writable */
111#define _PAGE_G _AC(0x0000000000000001,UL) /* Global */
112
113/* Here are the SpitFire software bits we use in the TTE's.
114 *
115 * WARNING: If you are going to try and start using some
116 * of the soft2 bits, you will need to make
117 * modifications to the swap entry implementation.
118 * For example, one thing that could happen is that
119 * swp_entry_to_pte() would BUG_ON() if you tried
120 * to use one of the soft2 bits for _PAGE_FILE.
121 *
122 * Like other architectures, I have aliased _PAGE_FILE with
123 * _PAGE_MODIFIED. This works because _PAGE_FILE is never
124 * interpreted that way unless _PAGE_PRESENT is clear.
125 */
126#define _PAGE_EXEC _AC(0x0000000000001000,UL) /* Executable SW bit */
127#define _PAGE_MODIFIED _AC(0x0000000000000800,UL) /* Modified (dirty) */
128#define _PAGE_FILE _AC(0x0000000000000800,UL) /* Pagecache page */
129#define _PAGE_ACCESSED _AC(0x0000000000000400,UL) /* Accessed (ref'd) */
130#define _PAGE_READ _AC(0x0000000000000200,UL) /* Readable SW Bit */
131#define _PAGE_WRITE _AC(0x0000000000000100,UL) /* Writable SW Bit */
132#define _PAGE_PRESENT _AC(0x0000000000000080,UL) /* Present */
133
134#if PAGE_SHIFT == 13
135#define _PAGE_SZBITS _PAGE_SZ8K
136#elif PAGE_SHIFT == 16
137#define _PAGE_SZBITS _PAGE_SZ64K
138#elif PAGE_SHIFT == 19
139#define _PAGE_SZBITS _PAGE_SZ512K
140#elif PAGE_SHIFT == 22
141#define _PAGE_SZBITS _PAGE_SZ4MB
142#else
143#error Wrong PAGE_SHIFT specified
144#endif
145
146#if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
147#define _PAGE_SZHUGE _PAGE_SZ4MB
148#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
149#define _PAGE_SZHUGE _PAGE_SZ512K
150#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
151#define _PAGE_SZHUGE _PAGE_SZ64K
152#endif
153
154#define _PAGE_CACHE (_PAGE_CP | _PAGE_CV)
155
156#define __DIRTY_BITS (_PAGE_MODIFIED | _PAGE_WRITE | _PAGE_W)
157#define __ACCESS_BITS (_PAGE_ACCESSED | _PAGE_READ | _PAGE_R)
158#define __PRIV_BITS _PAGE_P
159
160#define PAGE_NONE __pgprot (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_CACHE)
161
162/* Don't set the TTE _PAGE_W bit here, else the dirty bit never gets set. */
163#define PAGE_SHARED __pgprot (_PAGE_PRESENT | _PAGE_VALID | _PAGE_CACHE | \
164 __ACCESS_BITS | _PAGE_WRITE | _PAGE_EXEC)
165
166#define PAGE_COPY __pgprot (_PAGE_PRESENT | _PAGE_VALID | _PAGE_CACHE | \
167 __ACCESS_BITS | _PAGE_EXEC)
168
169#define PAGE_READONLY __pgprot (_PAGE_PRESENT | _PAGE_VALID | _PAGE_CACHE | \
170 __ACCESS_BITS | _PAGE_EXEC)
171
172#define PAGE_KERNEL __pgprot (_PAGE_PRESENT | _PAGE_VALID | _PAGE_CACHE | \
173 __PRIV_BITS | \
174 __ACCESS_BITS | __DIRTY_BITS | _PAGE_EXEC)
175
176#define PAGE_SHARED_NOEXEC __pgprot (_PAGE_PRESENT | _PAGE_VALID | \
177 _PAGE_CACHE | \
178 __ACCESS_BITS | _PAGE_WRITE)
179
180#define PAGE_COPY_NOEXEC __pgprot (_PAGE_PRESENT | _PAGE_VALID | \
181 _PAGE_CACHE | __ACCESS_BITS)
182
183#define PAGE_READONLY_NOEXEC __pgprot (_PAGE_PRESENT | _PAGE_VALID | \
184 _PAGE_CACHE | __ACCESS_BITS)
185
186#define _PFN_MASK _PAGE_PADDR
187
188#define pg_iobits (_PAGE_VALID | _PAGE_PRESENT | __DIRTY_BITS | \
189 __ACCESS_BITS | _PAGE_E)
190
191#define __P000 PAGE_NONE
192#define __P001 PAGE_READONLY_NOEXEC
193#define __P010 PAGE_COPY_NOEXEC
194#define __P011 PAGE_COPY_NOEXEC
195#define __P100 PAGE_READONLY
196#define __P101 PAGE_READONLY
197#define __P110 PAGE_COPY
198#define __P111 PAGE_COPY
199
200#define __S000 PAGE_NONE
201#define __S001 PAGE_READONLY_NOEXEC
202#define __S010 PAGE_SHARED_NOEXEC
203#define __S011 PAGE_SHARED_NOEXEC
204#define __S100 PAGE_READONLY
205#define __S101 PAGE_READONLY
206#define __S110 PAGE_SHARED
207#define __S111 PAGE_SHARED
208
209#ifndef __ASSEMBLY__
210
211extern unsigned long phys_base;
212extern unsigned long pfn_base;
213
214extern struct page *mem_map_zero;
215#define ZERO_PAGE(vaddr) (mem_map_zero)
216
217/* PFNs are real physical page numbers. However, mem_map only begins to record
218 * per-page information starting at pfn_base. This is to handle systems where
219 * the first physical page in the machine is at some huge physical address,
220 * such as 4GB. This is common on a partitioned E10000, for example.
221 */
222
223#define pfn_pte(pfn, prot) \
224 __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot) | _PAGE_SZBITS)
225#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
226
227#define pte_pfn(x) ((pte_val(x) & _PAGE_PADDR)>>PAGE_SHIFT)
228#define pte_page(x) pfn_to_page(pte_pfn(x))
229
230#define page_pte_prot(page, prot) mk_pte(page, prot)
231#define page_pte(page) page_pte_prot(page, __pgprot(0))
232
233static inline pte_t pte_modify(pte_t orig_pte, pgprot_t new_prot)
234{
235 pte_t __pte;
236 const unsigned long preserve_mask = (_PFN_MASK |
237 _PAGE_MODIFIED | _PAGE_ACCESSED |
238 _PAGE_CACHE | _PAGE_E |
239 _PAGE_PRESENT | _PAGE_SZBITS);
240
241 pte_val(__pte) = (pte_val(orig_pte) & preserve_mask) |
242 (pgprot_val(new_prot) & ~preserve_mask);
243
244 return __pte;
245}
246#define pmd_set(pmdp, ptep) \
247 (pmd_val(*(pmdp)) = (__pa((unsigned long) (ptep)) >> 11UL))
248#define pud_set(pudp, pmdp) \
249 (pud_val(*(pudp)) = (__pa((unsigned long) (pmdp)) >> 11UL))
250#define __pmd_page(pmd) \
251 ((unsigned long) __va((((unsigned long)pmd_val(pmd))<<11UL)))
252#define pmd_page(pmd) virt_to_page((void *)__pmd_page(pmd))
253#define pud_page(pud) \
254 ((unsigned long) __va((((unsigned long)pud_val(pud))<<11UL)))
255#define pte_none(pte) (!pte_val(pte))
256#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
257#define pmd_none(pmd) (!pmd_val(pmd))
258#define pmd_bad(pmd) (0)
259#define pmd_present(pmd) (pmd_val(pmd) != 0U)
260#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0U)
261#define pud_none(pud) (!pud_val(pud))
262#define pud_bad(pud) (0)
263#define pud_present(pud) (pud_val(pud) != 0U)
264#define pud_clear(pudp) (pud_val(*(pudp)) = 0U)
265
266/* The following only work if pte_present() is true.
267 * Undefined behaviour if not..
268 */
269#define pte_read(pte) (pte_val(pte) & _PAGE_READ)
270#define pte_exec(pte) (pte_val(pte) & _PAGE_EXEC)
271#define pte_write(pte) (pte_val(pte) & _PAGE_WRITE)
272#define pte_dirty(pte) (pte_val(pte) & _PAGE_MODIFIED)
273#define pte_young(pte) (pte_val(pte) & _PAGE_ACCESSED)
274#define pte_wrprotect(pte) (__pte(pte_val(pte) & ~(_PAGE_WRITE|_PAGE_W)))
275#define pte_rdprotect(pte) \
276 (__pte(((pte_val(pte)<<1UL)>>1UL) & ~_PAGE_READ))
277#define pte_mkclean(pte) \
278 (__pte(pte_val(pte) & ~(_PAGE_MODIFIED|_PAGE_W)))
279#define pte_mkold(pte) \
280 (__pte(((pte_val(pte)<<1UL)>>1UL) & ~_PAGE_ACCESSED))
281
282/* Permanent address of a page. */
283#define __page_address(page) page_address(page)
284
285/* Be very careful when you change these three, they are delicate. */
286#define pte_mkyoung(pte) (__pte(pte_val(pte) | _PAGE_ACCESSED | _PAGE_R))
287#define pte_mkwrite(pte) (__pte(pte_val(pte) | _PAGE_WRITE))
288#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_MODIFIED | _PAGE_W))
289
290/* to find an entry in a page-table-directory. */
291#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
292#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
293
294/* to find an entry in a kernel page-table-directory */
295#define pgd_offset_k(address) pgd_offset(&init_mm, address)
296
297/* extract the pgd cache used for optimizing the tlb miss
298 * slow path when executing 32-bit compat processes
299 */
300#define get_pgd_cache(pgd) ((unsigned long) pgd_val(*pgd) << 11)
301
302/* Find an entry in the second-level page table.. */
303#define pmd_offset(pudp, address) \
304 ((pmd_t *) pud_page(*(pudp)) + \
305 (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)))
306
307/* Find an entry in the third-level page table.. */
308#define pte_index(dir, address) \
309 ((pte_t *) __pmd_page(*(dir)) + \
310 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
311#define pte_offset_kernel pte_index
312#define pte_offset_map pte_index
313#define pte_offset_map_nested pte_index
314#define pte_unmap(pte) do { } while (0)
315#define pte_unmap_nested(pte) do { } while (0)
316
317/* Actual page table PTE updates. */
318extern void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig);
319
320static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
321{
322 pte_t orig = *ptep;
323
324 *ptep = pte;
325
326 /* It is more efficient to let flush_tlb_kernel_range()
327 * handle init_mm tlb flushes.
328 */
329 if (likely(mm != &init_mm) && (pte_val(orig) & _PAGE_VALID))
330 tlb_batch_add(mm, addr, ptep, orig);
331}
332
333#define pte_clear(mm,addr,ptep) \
334 set_pte_at((mm), (addr), (ptep), __pte(0UL))
335
336extern pgd_t swapper_pg_dir[1];
337
338/* These do nothing with the way I have things setup. */
339#define mmu_lockarea(vaddr, len) (vaddr)
340#define mmu_unlockarea(vaddr, len) do { } while(0)
341
342struct vm_area_struct;
343extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
344
345/* Make a non-present pseudo-TTE. */
346static inline pte_t mk_pte_io(unsigned long page, pgprot_t prot, int space)
347{
348 pte_t pte;
349 pte_val(pte) = (((page) | pgprot_val(prot) | _PAGE_E) &
350 ~(unsigned long)_PAGE_CACHE);
351 pte_val(pte) |= (((unsigned long)space) << 32);
352 return pte;
353}
354
355/* Encode and de-code a swap entry */
356#define __swp_type(entry) (((entry).val >> PAGE_SHIFT) & 0xffUL)
357#define __swp_offset(entry) ((entry).val >> (PAGE_SHIFT + 8UL))
358#define __swp_entry(type, offset) \
359 ( (swp_entry_t) \
360 { \
361 (((long)(type) << PAGE_SHIFT) | \
362 ((long)(offset) << (PAGE_SHIFT + 8UL))) \
363 } )
364#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
365#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
366
367/* File offset in PTE support. */
368#define pte_file(pte) (pte_val(pte) & _PAGE_FILE)
369#define pte_to_pgoff(pte) (pte_val(pte) >> PAGE_SHIFT)
370#define pgoff_to_pte(off) (__pte(((off) << PAGE_SHIFT) | _PAGE_FILE))
371#define PTE_FILE_MAX_BITS (64UL - PAGE_SHIFT - 1UL)
372
373extern unsigned long prom_virt_to_phys(unsigned long, int *);
374
375static __inline__ unsigned long
376sun4u_get_pte (unsigned long addr)
377{
378 pgd_t *pgdp;
379 pud_t *pudp;
380 pmd_t *pmdp;
381 pte_t *ptep;
382
383 if (addr >= PAGE_OFFSET)
384 return addr & _PAGE_PADDR;
385 if ((addr >= LOW_OBP_ADDRESS) && (addr < HI_OBP_ADDRESS))
386 return prom_virt_to_phys(addr, NULL);
387 pgdp = pgd_offset_k(addr);
388 pudp = pud_offset(pgdp, addr);
389 pmdp = pmd_offset(pudp, addr);
390 ptep = pte_offset_kernel(pmdp, addr);
391 return pte_val(*ptep) & _PAGE_PADDR;
392}
393
394static __inline__ unsigned long
395__get_phys (unsigned long addr)
396{
397 return sun4u_get_pte (addr);
398}
399
400static __inline__ int
401__get_iospace (unsigned long addr)
402{
403 return ((sun4u_get_pte (addr) & 0xf0000000) >> 28);
404}
405
406extern unsigned long *sparc64_valid_addr_bitmap;
407
408/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
409#define kern_addr_valid(addr) \
410 (test_bit(__pa((unsigned long)(addr))>>22, sparc64_valid_addr_bitmap))
411
412extern int io_remap_page_range(struct vm_area_struct *vma, unsigned long from,
413 unsigned long offset,
414 unsigned long size, pgprot_t prot, int space);
415extern int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
416 unsigned long pfn,
417 unsigned long size, pgprot_t prot);
418
419/*
420 * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in
421 * its high 4 bits. These macros/functions put it there or get it from there.
422 */
423#define MK_IOSPACE_PFN(space, pfn) (pfn | (space << (BITS_PER_LONG - 4)))
424#define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4))
425#define GET_PFN(pfn) (pfn & 0x0fffffffffffffffUL)
426
427/* Override for {pgd,pmd}_addr_end() to deal with the virtual address
428 * space hole. We simply sign extend bit 43.
429 */
430#define pgd_addr_end(addr, end) \
431({ unsigned long __boundary = ((addr) + PGDIR_SIZE) & PGDIR_MASK; \
432 __boundary = ((long) (__boundary << 20)) >> 20; \
433 (__boundary - 1 < (end) - 1)? __boundary: (end); \
434})
435
436#define pmd_addr_end(addr, end) \
437({ unsigned long __boundary = ((addr) + PMD_SIZE) & PMD_MASK; \
438 __boundary = ((long) (__boundary << 20)) >> 20; \
439 (__boundary - 1 < (end) - 1)? __boundary: (end); \
440})
441
442#include <asm-generic/pgtable.h>
443
444/* We provide our own get_unmapped_area to cope with VA holes for userland */
445#define HAVE_ARCH_UNMAPPED_AREA
446
447/* We provide a special get_unmapped_area for framebuffer mmaps to try and use
448 * the largest alignment possible such that larget PTEs can be used.
449 */
450extern unsigned long get_fb_unmapped_area(struct file *filp, unsigned long,
451 unsigned long, unsigned long,
452 unsigned long);
453#define HAVE_ARCH_FB_UNMAPPED_AREA
454
455/*
456 * No page table caches to initialise
457 */
458#define pgtable_cache_init() do { } while (0)
459
460extern void check_pgt_cache(void);
461
462#endif /* !(__ASSEMBLY__) */
463
464#endif /* !(_SPARC64_PGTABLE_H) */
diff --git a/include/asm-sparc64/pil.h b/include/asm-sparc64/pil.h
new file mode 100644
index 000000000000..8f87750c3517
--- /dev/null
+++ b/include/asm-sparc64/pil.h
@@ -0,0 +1,26 @@
1/* $Id: pil.h,v 1.1 2002/01/23 11:27:36 davem Exp $ */
2#ifndef _SPARC64_PIL_H
3#define _SPARC64_PIL_H
4
5/* To avoid some locking problems, we hard allocate certain PILs
6 * for SMP cross call messages that must do a etrap/rtrap.
7 *
8 * A cli() does not block the cross call delivery, so when SMP
9 * locking is an issue we reschedule the event into a PIL interrupt
10 * which is blocked by cli().
11 *
12 * In fact any XCALL which has to etrap/rtrap has a problem because
13 * it is difficult to prevent rtrap from running BH's, and that would
14 * need to be done if the XCALL arrived while %pil==15.
15 */
16#define PIL_SMP_CALL_FUNC 1
17#define PIL_SMP_RECEIVE_SIGNAL 2
18#define PIL_SMP_CAPTURE 3
19
20#ifndef __ASSEMBLY__
21#define PIL_RESERVED(PIL) ((PIL) == PIL_SMP_CALL_FUNC || \
22 (PIL) == PIL_SMP_RECEIVE_SIGNAL || \
23 (PIL) == PIL_SMP_CAPTURE)
24#endif
25
26#endif /* !(_SPARC64_PIL_H) */
diff --git a/include/asm-sparc64/poll.h b/include/asm-sparc64/poll.h
new file mode 100644
index 000000000000..31b611aa7468
--- /dev/null
+++ b/include/asm-sparc64/poll.h
@@ -0,0 +1,23 @@
1#ifndef __SPARC64_POLL_H
2#define __SPARC64_POLL_H
3
4#define POLLIN 1
5#define POLLPRI 2
6#define POLLOUT 4
7#define POLLERR 8
8#define POLLHUP 16
9#define POLLNVAL 32
10#define POLLRDNORM 64
11#define POLLWRNORM POLLOUT
12#define POLLRDBAND 128
13#define POLLWRBAND 256
14#define POLLMSG 512
15#define POLLREMOVE 1024
16
17struct pollfd {
18 int fd;
19 short events;
20 short revents;
21};
22
23#endif
diff --git a/include/asm-sparc64/posix_types.h b/include/asm-sparc64/posix_types.h
new file mode 100644
index 000000000000..c86b9452c683
--- /dev/null
+++ b/include/asm-sparc64/posix_types.h
@@ -0,0 +1,126 @@
1#ifndef __ARCH_SPARC64_POSIX_TYPES_H
2#define __ARCH_SPARC64_POSIX_TYPES_H
3
4/*
5 * This file is generally used by user-level software, so you need to
6 * be a little careful about namespace pollution etc. Also, we cannot
7 * assume GCC is being used.
8 */
9
10typedef unsigned long __kernel_size_t;
11typedef long __kernel_ssize_t;
12typedef long __kernel_ptrdiff_t;
13typedef long __kernel_time_t;
14typedef long __kernel_clock_t;
15typedef int __kernel_pid_t;
16typedef int __kernel_ipc_pid_t;
17typedef unsigned int __kernel_uid_t;
18typedef unsigned int __kernel_gid_t;
19typedef unsigned long __kernel_ino_t;
20typedef unsigned int __kernel_mode_t;
21typedef unsigned short __kernel_umode_t;
22typedef unsigned int __kernel_nlink_t;
23typedef int __kernel_daddr_t;
24typedef long __kernel_off_t;
25typedef char * __kernel_caddr_t;
26typedef unsigned short __kernel_uid16_t;
27typedef unsigned short __kernel_gid16_t;
28typedef int __kernel_clockid_t;
29typedef int __kernel_timer_t;
30
31typedef unsigned short __kernel_old_uid_t;
32typedef unsigned short __kernel_old_gid_t;
33typedef __kernel_uid_t __kernel_uid32_t;
34typedef __kernel_gid_t __kernel_gid32_t;
35
36typedef unsigned int __kernel_old_dev_t;
37
38/* Note this piece of asymmetry from the v9 ABI. */
39typedef int __kernel_suseconds_t;
40
41#ifdef __GNUC__
42typedef long long __kernel_loff_t;
43#endif
44
45typedef struct {
46#if defined(__KERNEL__) || defined(__USE_ALL)
47 int val[2];
48#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
49 int __val[2];
50#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
51} __kernel_fsid_t;
52
53#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
54
55#undef __FD_SET
56static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
57{
58 unsigned long _tmp = fd / __NFDBITS;
59 unsigned long _rem = fd % __NFDBITS;
60 fdsetp->fds_bits[_tmp] |= (1UL<<_rem);
61}
62
63#undef __FD_CLR
64static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
65{
66 unsigned long _tmp = fd / __NFDBITS;
67 unsigned long _rem = fd % __NFDBITS;
68 fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem);
69}
70
71#undef __FD_ISSET
72static __inline__ int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p)
73{
74 unsigned long _tmp = fd / __NFDBITS;
75 unsigned long _rem = fd % __NFDBITS;
76 return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0;
77}
78
79/*
80 * This will unroll the loop for the normal constant cases (8 or 32 longs,
81 * for 256 and 1024-bit fd_sets respectively)
82 */
83#undef __FD_ZERO
84static __inline__ void __FD_ZERO(__kernel_fd_set *p)
85{
86 unsigned long *tmp = p->fds_bits;
87 int i;
88
89 if (__builtin_constant_p(__FDSET_LONGS)) {
90 switch (__FDSET_LONGS) {
91 case 32:
92 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
93 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
94 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
95 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
96 tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0;
97 tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0;
98 tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0;
99 tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0;
100 return;
101 case 16:
102 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
103 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
104 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
105 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
106 return;
107 case 8:
108 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
109 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
110 return;
111 case 4:
112 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
113 return;
114 }
115 }
116 i = __FDSET_LONGS;
117 while (i) {
118 i--;
119 *tmp = 0;
120 tmp++;
121 }
122}
123
124#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
125
126#endif /* !(__ARCH_SPARC64_POSIX_TYPES_H) */
diff --git a/include/asm-sparc64/processor.h b/include/asm-sparc64/processor.h
new file mode 100644
index 000000000000..bc1445b904ef
--- /dev/null
+++ b/include/asm-sparc64/processor.h
@@ -0,0 +1,197 @@
1/* $Id: processor.h,v 1.83 2002/02/10 06:04:33 davem Exp $
2 * include/asm-sparc64/processor.h
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef __ASM_SPARC64_PROCESSOR_H
8#define __ASM_SPARC64_PROCESSOR_H
9
10/*
11 * Sparc64 implementation of macro that returns current
12 * instruction pointer ("program counter").
13 */
14#define current_text_addr() ({ void *pc; __asm__("rd %%pc, %0" : "=r" (pc)); pc; })
15
16#include <linux/config.h>
17#include <asm/asi.h>
18#include <asm/a.out.h>
19#include <asm/pstate.h>
20#include <asm/ptrace.h>
21#include <asm/segment.h>
22#include <asm/page.h>
23
24/* The sparc has no problems with write protection */
25#define wp_works_ok 1
26#define wp_works_ok__is_a_macro /* for versions in ksyms.c */
27
28/*
29 * User lives in his very own context, and cannot reference us. Note
30 * that TASK_SIZE is a misnomer, it really gives maximum user virtual
31 * address that the kernel will allocate out.
32 */
33#define VA_BITS 44
34#ifndef __ASSEMBLY__
35#define VPTE_SIZE (1UL << (VA_BITS - PAGE_SHIFT + 3))
36#else
37#define VPTE_SIZE (1 << (VA_BITS - PAGE_SHIFT + 3))
38#endif
39#define TASK_SIZE ((unsigned long)-VPTE_SIZE)
40
41/*
42 * The vpte base must be able to hold the entire vpte, half
43 * of which lives above, and half below, the base. And it
44 * is placed as close to the highest address range as possible.
45 */
46#define VPTE_BASE_SPITFIRE (-(VPTE_SIZE/2))
47#if 1
48#define VPTE_BASE_CHEETAH VPTE_BASE_SPITFIRE
49#else
50#define VPTE_BASE_CHEETAH 0xffe0000000000000
51#endif
52
53#ifndef __ASSEMBLY__
54
55typedef struct {
56 unsigned char seg;
57} mm_segment_t;
58
59/* The Sparc processor specific thread struct. */
60/* XXX This should die, everything can go into thread_info now. */
61struct thread_struct {
62#ifdef CONFIG_DEBUG_SPINLOCK
63 /* How many spinlocks held by this thread.
64 * Used with spin lock debugging to catch tasks
65 * sleeping illegally with locks held.
66 */
67 int smp_lock_count;
68 unsigned int smp_lock_pc;
69#else
70 int dummy; /* f'in gcc bug... */
71#endif
72};
73
74#endif /* !(__ASSEMBLY__) */
75
76#ifndef CONFIG_DEBUG_SPINLOCK
77#define INIT_THREAD { \
78 0, \
79}
80#else /* CONFIG_DEBUG_SPINLOCK */
81#define INIT_THREAD { \
82/* smp_lock_count, smp_lock_pc, */ \
83 0, 0, \
84}
85#endif /* !(CONFIG_DEBUG_SPINLOCK) */
86
87#ifndef __ASSEMBLY__
88
89#include <linux/types.h>
90
91/* Return saved PC of a blocked thread. */
92struct task_struct;
93extern unsigned long thread_saved_pc(struct task_struct *);
94
95/* On Uniprocessor, even in RMO processes see TSO semantics */
96#ifdef CONFIG_SMP
97#define TSTATE_INITIAL_MM TSTATE_TSO
98#else
99#define TSTATE_INITIAL_MM TSTATE_RMO
100#endif
101
102/* Do necessary setup to start up a newly executed thread. */
103#define start_thread(regs, pc, sp) \
104do { \
105 regs->tstate = (regs->tstate & (TSTATE_CWP)) | (TSTATE_INITIAL_MM|TSTATE_IE) | (ASI_PNF << 24); \
106 regs->tpc = ((pc & (~3)) - 4); \
107 regs->tnpc = regs->tpc + 4; \
108 regs->y = 0; \
109 set_thread_wstate(1 << 3); \
110 if (current_thread_info()->utraps) { \
111 if (*(current_thread_info()->utraps) < 2) \
112 kfree(current_thread_info()->utraps); \
113 else \
114 (*(current_thread_info()->utraps))--; \
115 current_thread_info()->utraps = NULL; \
116 } \
117 __asm__ __volatile__( \
118 "stx %%g0, [%0 + %2 + 0x00]\n\t" \
119 "stx %%g0, [%0 + %2 + 0x08]\n\t" \
120 "stx %%g0, [%0 + %2 + 0x10]\n\t" \
121 "stx %%g0, [%0 + %2 + 0x18]\n\t" \
122 "stx %%g0, [%0 + %2 + 0x20]\n\t" \
123 "stx %%g0, [%0 + %2 + 0x28]\n\t" \
124 "stx %%g0, [%0 + %2 + 0x30]\n\t" \
125 "stx %%g0, [%0 + %2 + 0x38]\n\t" \
126 "stx %%g0, [%0 + %2 + 0x40]\n\t" \
127 "stx %%g0, [%0 + %2 + 0x48]\n\t" \
128 "stx %%g0, [%0 + %2 + 0x50]\n\t" \
129 "stx %%g0, [%0 + %2 + 0x58]\n\t" \
130 "stx %%g0, [%0 + %2 + 0x60]\n\t" \
131 "stx %%g0, [%0 + %2 + 0x68]\n\t" \
132 "stx %1, [%0 + %2 + 0x70]\n\t" \
133 "stx %%g0, [%0 + %2 + 0x78]\n\t" \
134 "wrpr %%g0, (1 << 3), %%wstate\n\t" \
135 : \
136 : "r" (regs), "r" (sp - sizeof(struct reg_window) - STACK_BIAS), \
137 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
138} while (0)
139
140#define start_thread32(regs, pc, sp) \
141do { \
142 pc &= 0x00000000ffffffffUL; \
143 sp &= 0x00000000ffffffffUL; \
144\
145 regs->tstate = (regs->tstate & (TSTATE_CWP))|(TSTATE_INITIAL_MM|TSTATE_IE|TSTATE_AM); \
146 regs->tpc = ((pc & (~3)) - 4); \
147 regs->tnpc = regs->tpc + 4; \
148 regs->y = 0; \
149 set_thread_wstate(2 << 3); \
150 if (current_thread_info()->utraps) { \
151 if (*(current_thread_info()->utraps) < 2) \
152 kfree(current_thread_info()->utraps); \
153 else \
154 (*(current_thread_info()->utraps))--; \
155 current_thread_info()->utraps = NULL; \
156 } \
157 __asm__ __volatile__( \
158 "stx %%g0, [%0 + %2 + 0x00]\n\t" \
159 "stx %%g0, [%0 + %2 + 0x08]\n\t" \
160 "stx %%g0, [%0 + %2 + 0x10]\n\t" \
161 "stx %%g0, [%0 + %2 + 0x18]\n\t" \
162 "stx %%g0, [%0 + %2 + 0x20]\n\t" \
163 "stx %%g0, [%0 + %2 + 0x28]\n\t" \
164 "stx %%g0, [%0 + %2 + 0x30]\n\t" \
165 "stx %%g0, [%0 + %2 + 0x38]\n\t" \
166 "stx %%g0, [%0 + %2 + 0x40]\n\t" \
167 "stx %%g0, [%0 + %2 + 0x48]\n\t" \
168 "stx %%g0, [%0 + %2 + 0x50]\n\t" \
169 "stx %%g0, [%0 + %2 + 0x58]\n\t" \
170 "stx %%g0, [%0 + %2 + 0x60]\n\t" \
171 "stx %%g0, [%0 + %2 + 0x68]\n\t" \
172 "stx %1, [%0 + %2 + 0x70]\n\t" \
173 "stx %%g0, [%0 + %2 + 0x78]\n\t" \
174 "wrpr %%g0, (2 << 3), %%wstate\n\t" \
175 : \
176 : "r" (regs), "r" (sp - sizeof(struct reg_window32)), \
177 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
178} while (0)
179
180/* Free all resources held by a thread. */
181#define release_thread(tsk) do { } while (0)
182
183/* Prepare to copy thread state - unlazy all lazy status */
184#define prepare_to_copy(tsk) do { } while (0)
185
186extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
187
188extern unsigned long get_wchan(struct task_struct *task);
189
190#define KSTK_EIP(tsk) ((tsk)->thread_info->kregs->tpc)
191#define KSTK_ESP(tsk) ((tsk)->thread_info->kregs->u_regs[UREG_FP])
192
193#define cpu_relax() barrier()
194
195#endif /* !(__ASSEMBLY__) */
196
197#endif /* !(__ASM_SPARC64_PROCESSOR_H) */
diff --git a/include/asm-sparc64/psrcompat.h b/include/asm-sparc64/psrcompat.h
new file mode 100644
index 000000000000..5590ce6bd076
--- /dev/null
+++ b/include/asm-sparc64/psrcompat.h
@@ -0,0 +1,44 @@
1/* $Id: psrcompat.h,v 1.5 1998/10/06 09:28:39 jj Exp $ */
2#ifndef _SPARC64_PSRCOMPAT_H
3#define _SPARC64_PSRCOMPAT_H
4
5#include <asm/pstate.h>
6
7/* Old 32-bit PSR fields for the compatibility conversion code. */
8#define PSR_CWP 0x0000001f /* current window pointer */
9#define PSR_ET 0x00000020 /* enable traps field */
10#define PSR_PS 0x00000040 /* previous privilege level */
11#define PSR_S 0x00000080 /* current privilege level */
12#define PSR_PIL 0x00000f00 /* processor interrupt level */
13#define PSR_EF 0x00001000 /* enable floating point */
14#define PSR_EC 0x00002000 /* enable co-processor */
15#define PSR_LE 0x00008000 /* SuperSparcII little-endian */
16#define PSR_ICC 0x00f00000 /* integer condition codes */
17#define PSR_C 0x00100000 /* carry bit */
18#define PSR_V 0x00200000 /* overflow bit */
19#define PSR_Z 0x00400000 /* zero bit */
20#define PSR_N 0x00800000 /* negative bit */
21#define PSR_VERS 0x0f000000 /* cpu-version field */
22#define PSR_IMPL 0xf0000000 /* cpu-implementation field */
23
24#define PSR_V8PLUS 0xff000000 /* fake impl/ver, meaning a 64bit CPU is present */
25#define PSR_XCC 0x000f0000 /* if PSR_V8PLUS, this is %xcc */
26
27static inline unsigned int tstate_to_psr(unsigned long tstate)
28{
29 return ((tstate & TSTATE_CWP) |
30 PSR_S |
31 ((tstate & TSTATE_ICC) >> 12) |
32 ((tstate & TSTATE_XCC) >> 20) |
33 PSR_V8PLUS);
34}
35
36static inline unsigned long psr_to_tstate_icc(unsigned int psr)
37{
38 unsigned long tstate = ((unsigned long)(psr & PSR_ICC)) << 12;
39 if ((psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS)
40 tstate |= ((unsigned long)(psr & PSR_XCC)) << 20;
41 return tstate;
42}
43
44#endif /* !(_SPARC64_PSRCOMPAT_H) */
diff --git a/include/asm-sparc64/pstate.h b/include/asm-sparc64/pstate.h
new file mode 100644
index 000000000000..29fb74aa805d
--- /dev/null
+++ b/include/asm-sparc64/pstate.h
@@ -0,0 +1,90 @@
1/* $Id: pstate.h,v 1.6 1997/06/25 07:39:45 jj Exp $ */
2#ifndef _SPARC64_PSTATE_H
3#define _SPARC64_PSTATE_H
4
5#include <asm/const.h>
6
7/* The V9 PSTATE Register (with SpitFire extensions).
8 *
9 * -----------------------------------------------------------------------
10 * | Resv | IG | MG | CLE | TLE | MM | RED | PEF | AM | PRIV | IE | AG |
11 * -----------------------------------------------------------------------
12 * 63 12 11 10 9 8 7 6 5 4 3 2 1 0
13 */
14#define PSTATE_IG _AC(0x0000000000000800,UL) /* Interrupt Globals. */
15#define PSTATE_MG _AC(0x0000000000000400,UL) /* MMU Globals. */
16#define PSTATE_CLE _AC(0x0000000000000200,UL) /* Current Little Endian.*/
17#define PSTATE_TLE _AC(0x0000000000000100,UL) /* Trap Little Endian. */
18#define PSTATE_MM _AC(0x00000000000000c0,UL) /* Memory Model. */
19#define PSTATE_TSO _AC(0x0000000000000000,UL) /* MM: TotalStoreOrder */
20#define PSTATE_PSO _AC(0x0000000000000040,UL) /* MM: PartialStoreOrder */
21#define PSTATE_RMO _AC(0x0000000000000080,UL) /* MM: RelaxedMemoryOrder*/
22#define PSTATE_RED _AC(0x0000000000000020,UL) /* Reset Error Debug. */
23#define PSTATE_PEF _AC(0x0000000000000010,UL) /* Floating Point Enable.*/
24#define PSTATE_AM _AC(0x0000000000000008,UL) /* Address Mask. */
25#define PSTATE_PRIV _AC(0x0000000000000004,UL) /* Privilege. */
26#define PSTATE_IE _AC(0x0000000000000002,UL) /* Interrupt Enable. */
27#define PSTATE_AG _AC(0x0000000000000001,UL) /* Alternate Globals. */
28
29/* The V9 TSTATE Register (with SpitFire and Linux extensions).
30 *
31 * ---------------------------------------------------------------
32 * | Resv | CCR | ASI | %pil | PSTATE | Resv | CWP |
33 * ---------------------------------------------------------------
34 * 63 40 39 32 31 24 23 20 19 8 7 5 4 0
35 */
36#define TSTATE_CCR _AC(0x000000ff00000000,UL) /* Condition Codes. */
37#define TSTATE_XCC _AC(0x000000f000000000,UL) /* Condition Codes. */
38#define TSTATE_XNEG _AC(0x0000008000000000,UL) /* %xcc Negative. */
39#define TSTATE_XZERO _AC(0x0000004000000000,UL) /* %xcc Zero. */
40#define TSTATE_XOVFL _AC(0x0000002000000000,UL) /* %xcc Overflow. */
41#define TSTATE_XCARRY _AC(0x0000001000000000,UL) /* %xcc Carry. */
42#define TSTATE_ICC _AC(0x0000000f00000000,UL) /* Condition Codes. */
43#define TSTATE_INEG _AC(0x0000000800000000,UL) /* %icc Negative. */
44#define TSTATE_IZERO _AC(0x0000000400000000,UL) /* %icc Zero. */
45#define TSTATE_IOVFL _AC(0x0000000200000000,UL) /* %icc Overflow. */
46#define TSTATE_ICARRY _AC(0x0000000100000000,UL) /* %icc Carry. */
47#define TSTATE_ASI _AC(0x00000000ff000000,UL) /* AddrSpace ID. */
48#define TSTATE_PIL _AC(0x0000000000f00000,UL) /* %pil (Linux traps)*/
49#define TSTATE_PSTATE _AC(0x00000000000fff00,UL) /* PSTATE. */
50#define TSTATE_IG _AC(0x0000000000080000,UL) /* Interrupt Globals.*/
51#define TSTATE_MG _AC(0x0000000000040000,UL) /* MMU Globals. */
52#define TSTATE_CLE _AC(0x0000000000020000,UL) /* CurrLittleEndian. */
53#define TSTATE_TLE _AC(0x0000000000010000,UL) /* TrapLittleEndian. */
54#define TSTATE_MM _AC(0x000000000000c000,UL) /* Memory Model. */
55#define TSTATE_TSO _AC(0x0000000000000000,UL) /* MM: TSO */
56#define TSTATE_PSO _AC(0x0000000000004000,UL) /* MM: PSO */
57#define TSTATE_RMO _AC(0x0000000000008000,UL) /* MM: RMO */
58#define TSTATE_RED _AC(0x0000000000002000,UL) /* Reset Error Debug.*/
59#define TSTATE_PEF _AC(0x0000000000001000,UL) /* FPU Enable. */
60#define TSTATE_AM _AC(0x0000000000000800,UL) /* Address Mask. */
61#define TSTATE_PRIV _AC(0x0000000000000400,UL) /* Privilege. */
62#define TSTATE_IE _AC(0x0000000000000200,UL) /* Interrupt Enable. */
63#define TSTATE_AG _AC(0x0000000000000100,UL) /* Alternate Globals.*/
64#define TSTATE_CWP _AC(0x000000000000001f,UL) /* Curr Win-Pointer. */
65
66/* Floating-Point Registers State Register.
67 *
68 * --------------------------------
69 * | Resv | FEF | DU | DL |
70 * --------------------------------
71 * 63 3 2 1 0
72 */
73#define FPRS_FEF _AC(0x0000000000000004,UL) /* FPU Enable. */
74#define FPRS_DU _AC(0x0000000000000002,UL) /* Dirty Upper. */
75#define FPRS_DL _AC(0x0000000000000001,UL) /* Dirty Lower. */
76
77/* Version Register.
78 *
79 * ------------------------------------------------------
80 * | MANUF | IMPL | MASK | Resv | MAXTL | Resv | MAXWIN |
81 * ------------------------------------------------------
82 * 63 48 47 32 31 24 23 16 15 8 7 5 4 0
83 */
84#define VERS_MANUF _AC(0xffff000000000000,UL) /* Manufacturer. */
85#define VERS_IMPL _AC(0x0000ffff00000000,UL) /* Implementation. */
86#define VERS_MASK _AC(0x00000000ff000000,UL) /* Mask Set Revision.*/
87#define VERS_MAXTL _AC(0x000000000000ff00,UL) /* Max Trap Level. */
88#define VERS_MAXWIN _AC(0x000000000000001f,UL) /* Max RegWindow Idx.*/
89
90#endif /* !(_SPARC64_PSTATE_H) */
diff --git a/include/asm-sparc64/ptrace.h b/include/asm-sparc64/ptrace.h
new file mode 100644
index 000000000000..2d2b5a113d24
--- /dev/null
+++ b/include/asm-sparc64/ptrace.h
@@ -0,0 +1,297 @@
1/* $Id: ptrace.h,v 1.14 2002/02/09 19:49:32 davem Exp $ */
2#ifndef _SPARC64_PTRACE_H
3#define _SPARC64_PTRACE_H
4
5#include <asm/pstate.h>
6
7/* This struct defines the way the registers are stored on the
8 * stack during a system call and basically all traps.
9 */
10
11#ifndef __ASSEMBLY__
12
13struct pt_regs {
14 unsigned long u_regs[16]; /* globals and ins */
15 unsigned long tstate;
16 unsigned long tpc;
17 unsigned long tnpc;
18 unsigned int y;
19 unsigned int fprs;
20};
21
22struct pt_regs32 {
23 unsigned int psr;
24 unsigned int pc;
25 unsigned int npc;
26 unsigned int y;
27 unsigned int u_regs[16]; /* globals and ins */
28};
29
30#define UREG_G0 0
31#define UREG_G1 1
32#define UREG_G2 2
33#define UREG_G3 3
34#define UREG_G4 4
35#define UREG_G5 5
36#define UREG_G6 6
37#define UREG_G7 7
38#define UREG_I0 8
39#define UREG_I1 9
40#define UREG_I2 10
41#define UREG_I3 11
42#define UREG_I4 12
43#define UREG_I5 13
44#define UREG_I6 14
45#define UREG_I7 15
46#define UREG_FP UREG_I6
47#define UREG_RETPC UREG_I7
48
49/* A V9 register window */
50struct reg_window {
51 unsigned long locals[8];
52 unsigned long ins[8];
53};
54
55/* A 32-bit register window. */
56struct reg_window32 {
57 unsigned int locals[8];
58 unsigned int ins[8];
59};
60
61/* A V9 Sparc stack frame */
62struct sparc_stackf {
63 unsigned long locals[8];
64 unsigned long ins[6];
65 struct sparc_stackf *fp;
66 unsigned long callers_pc;
67 char *structptr;
68 unsigned long xargs[6];
69 unsigned long xxargs[1];
70};
71
72/* A 32-bit Sparc stack frame */
73struct sparc_stackf32 {
74 unsigned int locals[8];
75 unsigned int ins[6];
76 unsigned int fp;
77 unsigned int callers_pc;
78 unsigned int structptr;
79 unsigned int xargs[6];
80 unsigned int xxargs[1];
81};
82
83struct sparc_trapf {
84 unsigned long locals[8];
85 unsigned long ins[8];
86 unsigned long _unused;
87 struct pt_regs *regs;
88};
89
90#define TRACEREG_SZ sizeof(struct pt_regs)
91#define STACKFRAME_SZ sizeof(struct sparc_stackf)
92
93#define TRACEREG32_SZ sizeof(struct pt_regs32)
94#define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
95
96#ifdef __KERNEL__
97#define force_successful_syscall_return() \
98 set_thread_flag(TIF_SYSCALL_SUCCESS)
99#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
100#define instruction_pointer(regs) ((regs)->tpc)
101#ifdef CONFIG_SMP
102extern unsigned long profile_pc(struct pt_regs *);
103#else
104#define profile_pc(regs) instruction_pointer(regs)
105#endif
106extern void show_regs(struct pt_regs *);
107#endif
108
109#else /* __ASSEMBLY__ */
110/* For assembly code. */
111#define TRACEREG_SZ 0xa0
112#define STACKFRAME_SZ 0xc0
113
114#define TRACEREG32_SZ 0x50
115#define STACKFRAME32_SZ 0x60
116#endif
117
118#ifdef __KERNEL__
119#define STACK_BIAS 2047
120#endif
121
122/* These are for pt_regs. */
123#define PT_V9_G0 0x00
124#define PT_V9_G1 0x08
125#define PT_V9_G2 0x10
126#define PT_V9_G3 0x18
127#define PT_V9_G4 0x20
128#define PT_V9_G5 0x28
129#define PT_V9_G6 0x30
130#define PT_V9_G7 0x38
131#define PT_V9_I0 0x40
132#define PT_V9_I1 0x48
133#define PT_V9_I2 0x50
134#define PT_V9_I3 0x58
135#define PT_V9_I4 0x60
136#define PT_V9_I5 0x68
137#define PT_V9_I6 0x70
138#define PT_V9_FP PT_V9_I6
139#define PT_V9_I7 0x78
140#define PT_V9_TSTATE 0x80
141#define PT_V9_TPC 0x88
142#define PT_V9_TNPC 0x90
143#define PT_V9_Y 0x98
144#define PT_V9_FPRS 0x9c
145#define PT_TSTATE PT_V9_TSTATE
146#define PT_TPC PT_V9_TPC
147#define PT_TNPC PT_V9_TNPC
148
149/* These for pt_regs32. */
150#define PT_PSR 0x0
151#define PT_PC 0x4
152#define PT_NPC 0x8
153#define PT_Y 0xc
154#define PT_G0 0x10
155#define PT_WIM PT_G0
156#define PT_G1 0x14
157#define PT_G2 0x18
158#define PT_G3 0x1c
159#define PT_G4 0x20
160#define PT_G5 0x24
161#define PT_G6 0x28
162#define PT_G7 0x2c
163#define PT_I0 0x30
164#define PT_I1 0x34
165#define PT_I2 0x38
166#define PT_I3 0x3c
167#define PT_I4 0x40
168#define PT_I5 0x44
169#define PT_I6 0x48
170#define PT_FP PT_I6
171#define PT_I7 0x4c
172
173/* Reg_window offsets */
174#define RW_V9_L0 0x00
175#define RW_V9_L1 0x08
176#define RW_V9_L2 0x10
177#define RW_V9_L3 0x18
178#define RW_V9_L4 0x20
179#define RW_V9_L5 0x28
180#define RW_V9_L6 0x30
181#define RW_V9_L7 0x38
182#define RW_V9_I0 0x40
183#define RW_V9_I1 0x48
184#define RW_V9_I2 0x50
185#define RW_V9_I3 0x58
186#define RW_V9_I4 0x60
187#define RW_V9_I5 0x68
188#define RW_V9_I6 0x70
189#define RW_V9_I7 0x78
190
191#define RW_L0 0x00
192#define RW_L1 0x04
193#define RW_L2 0x08
194#define RW_L3 0x0c
195#define RW_L4 0x10
196#define RW_L5 0x14
197#define RW_L6 0x18
198#define RW_L7 0x1c
199#define RW_I0 0x20
200#define RW_I1 0x24
201#define RW_I2 0x28
202#define RW_I3 0x2c
203#define RW_I4 0x30
204#define RW_I5 0x34
205#define RW_I6 0x38
206#define RW_I7 0x3c
207
208/* Stack_frame offsets */
209#define SF_V9_L0 0x00
210#define SF_V9_L1 0x08
211#define SF_V9_L2 0x10
212#define SF_V9_L3 0x18
213#define SF_V9_L4 0x20
214#define SF_V9_L5 0x28
215#define SF_V9_L6 0x30
216#define SF_V9_L7 0x38
217#define SF_V9_I0 0x40
218#define SF_V9_I1 0x48
219#define SF_V9_I2 0x50
220#define SF_V9_I3 0x58
221#define SF_V9_I4 0x60
222#define SF_V9_I5 0x68
223#define SF_V9_FP 0x70
224#define SF_V9_PC 0x78
225#define SF_V9_RETP 0x80
226#define SF_V9_XARG0 0x88
227#define SF_V9_XARG1 0x90
228#define SF_V9_XARG2 0x98
229#define SF_V9_XARG3 0xa0
230#define SF_V9_XARG4 0xa8
231#define SF_V9_XARG5 0xb0
232#define SF_V9_XXARG 0xb8
233
234#define SF_L0 0x00
235#define SF_L1 0x04
236#define SF_L2 0x08
237#define SF_L3 0x0c
238#define SF_L4 0x10
239#define SF_L5 0x14
240#define SF_L6 0x18
241#define SF_L7 0x1c
242#define SF_I0 0x20
243#define SF_I1 0x24
244#define SF_I2 0x28
245#define SF_I3 0x2c
246#define SF_I4 0x30
247#define SF_I5 0x34
248#define SF_FP 0x38
249#define SF_PC 0x3c
250#define SF_RETP 0x40
251#define SF_XARG0 0x44
252#define SF_XARG1 0x48
253#define SF_XARG2 0x4c
254#define SF_XARG3 0x50
255#define SF_XARG4 0x54
256#define SF_XARG5 0x58
257#define SF_XXARG 0x5c
258
259/* Stuff for the ptrace system call */
260#define PTRACE_SUNATTACH 10
261#define PTRACE_SUNDETACH 11
262#define PTRACE_GETREGS 12
263#define PTRACE_SETREGS 13
264#define PTRACE_GETFPREGS 14
265#define PTRACE_SETFPREGS 15
266#define PTRACE_READDATA 16
267#define PTRACE_WRITEDATA 17
268#define PTRACE_READTEXT 18
269#define PTRACE_WRITETEXT 19
270#define PTRACE_GETFPAREGS 20
271#define PTRACE_SETFPAREGS 21
272
273/* There are for debugging 64-bit processes, either from a 32 or 64 bit
274 * parent. Thus their complements are for debugging 32-bit processes only.
275 */
276
277#define PTRACE_GETREGS64 22
278#define PTRACE_SETREGS64 23
279/* PTRACE_SYSCALL is 24 */
280#define PTRACE_GETFPREGS64 25
281#define PTRACE_SETFPREGS64 26
282
283#define PTRACE_GETUCODE 29 /* stupid bsd-ism */
284
285/* These are for 32-bit processes debugging 64-bit ones.
286 * Here addr and addr2 are passed in %g2 and %g3 respectively.
287 */
288#define PTRACE_PEEKTEXT64 (30 + PTRACE_PEEKTEXT)
289#define PTRACE_POKETEXT64 (30 + PTRACE_POKETEXT)
290#define PTRACE_PEEKDATA64 (30 + PTRACE_PEEKDATA)
291#define PTRACE_POKEDATA64 (30 + PTRACE_POKEDATA)
292#define PTRACE_READDATA64 (30 + PTRACE_READDATA)
293#define PTRACE_WRITEDATA64 (30 + PTRACE_WRITEDATA)
294#define PTRACE_READTEXT64 (30 + PTRACE_READTEXT)
295#define PTRACE_WRITETEXT64 (30 + PTRACE_WRITETEXT)
296
297#endif /* !(_SPARC64_PTRACE_H) */
diff --git a/include/asm-sparc64/reg.h b/include/asm-sparc64/reg.h
new file mode 100644
index 000000000000..fc68f90181b3
--- /dev/null
+++ b/include/asm-sparc64/reg.h
@@ -0,0 +1,56 @@
1/* $Id: reg.h,v 1.6 1999/09/06 08:22:10 jj Exp $
2 * linux/asm-sparc64/reg.h
3 * Layout of the registers as expected by gdb on the Sparc
4 * we should replace the user.h definitions with those in
5 * this file, we don't even use the other
6 * -miguel
7 *
8 * The names of the structures, constants and aliases in this file
9 * have the same names as the sunos ones, some programs rely on these
10 * names (gdb for example).
11 *
12 */
13
14#ifndef __SPARC64_REG_H
15#define __SPARC64_REG_H
16
17struct regs {
18 unsigned long r_g1;
19 unsigned long r_g2;
20 unsigned long r_g3;
21 unsigned long r_g4;
22 unsigned long r_g5;
23 unsigned long r_g6;
24 unsigned long r_g7;
25 unsigned long r_o0;
26 unsigned long r_o1;
27 unsigned long r_o2;
28 unsigned long r_o3;
29 unsigned long r_o4;
30 unsigned long r_o5;
31 unsigned long r_o6;
32 unsigned long r_o7;
33 unsigned long __pad;
34 unsigned long r_tstate;
35 unsigned long r_tpc;
36 unsigned long r_tnpc;
37 unsigned int r_y;
38 unsigned int r_fprs;
39};
40
41#define FPU_REGS_TYPE unsigned int
42#define FPU_FSR_TYPE unsigned long
43
44struct fp_status {
45 unsigned long fpu_fr[32];
46 unsigned long Fpu_fsr;
47};
48
49struct fpu {
50 struct fp_status f_fpstatus;
51};
52
53#define fpu_regs f_fpstatus.fpu_fr
54#define fpu_fsr f_fpstatus.Fpu_fsr
55
56#endif /* __SPARC64_REG_H */
diff --git a/include/asm-sparc64/resource.h b/include/asm-sparc64/resource.h
new file mode 100644
index 000000000000..aa469795a6b0
--- /dev/null
+++ b/include/asm-sparc64/resource.h
@@ -0,0 +1,19 @@
1/* $Id: resource.h,v 1.8 2000/09/23 02:09:21 davem Exp $
2 * resource.h: Resource definitions.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_RESOURCE_H
8#define _SPARC64_RESOURCE_H
9
10/*
11 * These two resource limit IDs have a Sparc/Linux-specific ordering,
12 * the rest comes from the generic header:
13 */
14#define RLIMIT_NOFILE 6 /* max number of open files */
15#define RLIMIT_NPROC 7 /* max number of processes */
16
17#include <asm-generic/resource.h>
18
19#endif /* !(_SPARC64_RESOURCE_H) */
diff --git a/include/asm-sparc64/rtc.h b/include/asm-sparc64/rtc.h
new file mode 100644
index 000000000000..cb17334595c9
--- /dev/null
+++ b/include/asm-sparc64/rtc.h
@@ -0,0 +1,27 @@
1/* $Id: rtc.h,v 1.1 1996/12/26 14:22:35 davem Exp $
2 *
3 * rtc.h: Definitions for access to the Mostek real time clock
4 *
5 * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
6 */
7
8#ifndef _RTC_H
9#define _RTC_H
10
11#include <linux/ioctl.h>
12
13struct rtc_time
14{
15 int sec; /* Seconds (0-59) */
16 int min; /* Minutes (0-59) */
17 int hour; /* Hour (0-23) */
18 int dow; /* Day of the week (1-7) */
19 int dom; /* Day of the month (1-31) */
20 int month; /* Month of year (1-12) */
21 int year; /* Year (0-99) */
22};
23
24#define RTCGET _IOR('p', 20, struct rtc_time)
25#define RTCSET _IOW('p', 21, struct rtc_time)
26
27#endif
diff --git a/include/asm-sparc64/rwsem-const.h b/include/asm-sparc64/rwsem-const.h
new file mode 100644
index 000000000000..a303c9d64d84
--- /dev/null
+++ b/include/asm-sparc64/rwsem-const.h
@@ -0,0 +1,12 @@
1/* rwsem-const.h: RW semaphore counter constants. */
2#ifndef _SPARC64_RWSEM_CONST_H
3#define _SPARC64_RWSEM_CONST_H
4
5#define RWSEM_UNLOCKED_VALUE 0x00000000
6#define RWSEM_ACTIVE_BIAS 0x00000001
7#define RWSEM_ACTIVE_MASK 0x0000ffff
8#define RWSEM_WAITING_BIAS 0xffff0000
9#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
10#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
11
12#endif /* _SPARC64_RWSEM_CONST_H */
diff --git a/include/asm-sparc64/rwsem.h b/include/asm-sparc64/rwsem.h
new file mode 100644
index 000000000000..bf2ae90ed3df
--- /dev/null
+++ b/include/asm-sparc64/rwsem.h
@@ -0,0 +1,100 @@
1/* $Id: rwsem.h,v 1.5 2001/11/18 00:12:56 davem Exp $
2 * rwsem.h: R/W semaphores implemented using CAS
3 *
4 * Written by David S. Miller (davem@redhat.com), 2001.
5 * Derived from asm-i386/rwsem.h
6 */
7#ifndef _SPARC64_RWSEM_H
8#define _SPARC64_RWSEM_H
9
10#ifndef _LINUX_RWSEM_H
11#error "please don't include asm/rwsem.h directly, use linux/rwsem.h instead"
12#endif
13
14#ifdef __KERNEL__
15
16#include <linux/list.h>
17#include <linux/spinlock.h>
18#include <asm/rwsem-const.h>
19
20struct rwsem_waiter;
21
22struct rw_semaphore {
23 signed int count;
24 spinlock_t wait_lock;
25 struct list_head wait_list;
26};
27
28#define __RWSEM_INITIALIZER(name) \
29{ RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) }
30
31#define DECLARE_RWSEM(name) \
32 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
33
34static __inline__ void init_rwsem(struct rw_semaphore *sem)
35{
36 sem->count = RWSEM_UNLOCKED_VALUE;
37 spin_lock_init(&sem->wait_lock);
38 INIT_LIST_HEAD(&sem->wait_list);
39}
40
41extern void __down_read(struct rw_semaphore *sem);
42extern int __down_read_trylock(struct rw_semaphore *sem);
43extern void __down_write(struct rw_semaphore *sem);
44extern int __down_write_trylock(struct rw_semaphore *sem);
45extern void __up_read(struct rw_semaphore *sem);
46extern void __up_write(struct rw_semaphore *sem);
47extern void __downgrade_write(struct rw_semaphore *sem);
48
49static __inline__ int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
50{
51 int tmp = delta;
52
53 __asm__ __volatile__(
54 "1:\tlduw [%2], %%g1\n\t"
55 "add %%g1, %1, %%g7\n\t"
56 "cas [%2], %%g1, %%g7\n\t"
57 "cmp %%g1, %%g7\n\t"
58 "bne,pn %%icc, 1b\n\t"
59 " membar #StoreLoad | #StoreStore\n\t"
60 "mov %%g7, %0\n\t"
61 : "=&r" (tmp)
62 : "0" (tmp), "r" (sem)
63 : "g1", "g7", "memory", "cc");
64
65 return tmp + delta;
66}
67
68#define rwsem_atomic_add rwsem_atomic_update
69
70static __inline__ __u16 rwsem_cmpxchgw(struct rw_semaphore *sem, __u16 __old, __u16 __new)
71{
72 u32 old = (sem->count & 0xffff0000) | (u32) __old;
73 u32 new = (old & 0xffff0000) | (u32) __new;
74 u32 prev;
75
76again:
77 __asm__ __volatile__("cas [%2], %3, %0\n\t"
78 "membar #StoreLoad | #StoreStore"
79 : "=&r" (prev)
80 : "0" (new), "r" (sem), "r" (old)
81 : "memory");
82
83 /* To give the same semantics as x86 cmpxchgw, keep trying
84 * if only the upper 16-bits changed.
85 */
86 if (prev != old &&
87 ((prev & 0xffff) == (old & 0xffff)))
88 goto again;
89
90 return prev & 0xffff;
91}
92
93static __inline__ signed long rwsem_cmpxchg(struct rw_semaphore *sem, signed long old, signed long new)
94{
95 return cmpxchg(&sem->count,old,new);
96}
97
98#endif /* __KERNEL__ */
99
100#endif /* _SPARC64_RWSEM_H */
diff --git a/include/asm-sparc64/sbus.h b/include/asm-sparc64/sbus.h
new file mode 100644
index 000000000000..48279e10f385
--- /dev/null
+++ b/include/asm-sparc64/sbus.h
@@ -0,0 +1,122 @@
1/* $Id: sbus.h,v 1.14 2000/02/18 13:50:55 davem Exp $
2 * sbus.h: Defines for the Sun SBus.
3 *
4 * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com)
5 */
6
7#ifndef _SPARC64_SBUS_H
8#define _SPARC64_SBUS_H
9
10#include <linux/dma-mapping.h>
11#include <linux/ioport.h>
12
13#include <asm/oplib.h>
14#include <asm/iommu.h>
15#include <asm/scatterlist.h>
16
17/* We scan which devices are on the SBus using the PROM node device
18 * tree. SBus devices are described in two different ways. You can
19 * either get an absolute address at which to access the device, or
20 * you can get a SBus 'slot' number and an offset within that slot.
21 */
22
23/* The base address at which to calculate device OBIO addresses. */
24#define SUN_SBUS_BVADDR 0x00000000
25#define SBUS_OFF_MASK 0x0fffffff
26
27/* These routines are used to calculate device address from slot
28 * numbers + offsets, and vice versa.
29 */
30
31static __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
32{
33 return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<28)+(offset));
34}
35
36static __inline__ int sbus_dev_slot(unsigned long dev_addr)
37{
38 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>28);
39}
40
41struct sbus_bus;
42
43/* Linux SBUS device tables */
44struct sbus_dev {
45 struct sbus_bus *bus; /* Our toplevel parent SBUS */
46 struct sbus_dev *next; /* Chain of siblings */
47 struct sbus_dev *child; /* Chain of children */
48 struct sbus_dev *parent;/* Parent device if not toplevel*/
49 int prom_node; /* OBP node of this device */
50 char prom_name[64]; /* OBP device name property */
51 int slot; /* SBUS slot number */
52
53 struct resource resource[PROMREG_MAX];
54
55 struct linux_prom_registers reg_addrs[PROMREG_MAX];
56 int num_registers, ranges_applied;
57
58 struct linux_prom_ranges device_ranges[PROMREG_MAX];
59 int num_device_ranges;
60
61 unsigned int irqs[4];
62 int num_irqs;
63};
64
65/* This struct describes the SBus(s) found on this machine. */
66struct sbus_bus {
67 void *iommu; /* Opaque IOMMU cookie */
68 struct sbus_dev *devices; /* Tree of SBUS devices */
69 struct sbus_bus *next; /* Next SBUS in system */
70 int prom_node; /* OBP node of SBUS */
71 char prom_name[64]; /* Usually "sbus" or "sbi" */
72 int clock_freq;
73
74 struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
75 int num_sbus_ranges;
76
77 int portid;
78 void *starfire_cookie;
79};
80
81extern struct sbus_bus *sbus_root;
82
83/* Device probing routines could find these handy */
84#define for_each_sbus(bus) \
85 for((bus) = sbus_root; (bus); (bus)=(bus)->next)
86
87#define for_each_sbusdev(device, bus) \
88 for((device) = (bus)->devices; (device); (device)=(device)->next)
89
90#define for_all_sbusdev(device, bus) \
91 for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
92 for ((device) = (bus)->devices; (device); (device) = (device)->next)
93
94/* Driver DVMA interfaces. */
95#define sbus_can_dma_64bit(sdev) (1)
96#define sbus_can_burst64(sdev) (1)
97extern void sbus_set_sbus64(struct sbus_dev *, int);
98
99/* These yield IOMMU mappings in consistent mode. */
100extern void *sbus_alloc_consistent(struct sbus_dev *, size_t, dma_addr_t *dma_addrp);
101extern void sbus_free_consistent(struct sbus_dev *, size_t, void *, dma_addr_t);
102
103#define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL
104#define SBUS_DMA_TODEVICE DMA_TO_DEVICE
105#define SBUS_DMA_FROMDEVICE DMA_FROM_DEVICE
106#define SBUS_DMA_NONE DMA_NONE
107
108/* All the rest use streaming mode mappings. */
109extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
110extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
111extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
112extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
113
114/* Finally, allow explicit synchronization of streamable mappings. */
115extern void sbus_dma_sync_single_for_cpu(struct sbus_dev *, dma_addr_t, size_t, int);
116#define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
117extern void sbus_dma_sync_single_for_device(struct sbus_dev *, dma_addr_t, size_t, int);
118extern void sbus_dma_sync_sg_for_cpu(struct sbus_dev *, struct scatterlist *, int, int);
119#define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
120extern void sbus_dma_sync_sg_for_device(struct sbus_dev *, struct scatterlist *, int, int);
121
122#endif /* !(_SPARC64_SBUS_H) */
diff --git a/include/asm-sparc64/scatterlist.h b/include/asm-sparc64/scatterlist.h
new file mode 100644
index 000000000000..ec4f3c63fe98
--- /dev/null
+++ b/include/asm-sparc64/scatterlist.h
@@ -0,0 +1,22 @@
1/* $Id: scatterlist.h,v 1.11 2001/12/17 07:05:15 davem Exp $ */
2#ifndef _SPARC64_SCATTERLIST_H
3#define _SPARC64_SCATTERLIST_H
4
5#include <asm/page.h>
6
7struct scatterlist {
8 struct page *page;
9 unsigned int offset;
10
11 unsigned int length;
12
13 dma_addr_t dma_address;
14 __u32 dma_length;
15};
16
17#define sg_dma_address(sg) ((sg)->dma_address)
18#define sg_dma_len(sg) ((sg)->dma_length)
19
20#define ISA_DMA_THRESHOLD (~0UL)
21
22#endif /* !(_SPARC64_SCATTERLIST_H) */
diff --git a/include/asm-sparc64/sections.h b/include/asm-sparc64/sections.h
new file mode 100644
index 000000000000..3f4b9fdc28d0
--- /dev/null
+++ b/include/asm-sparc64/sections.h
@@ -0,0 +1,9 @@
1#ifndef _SPARC64_SECTIONS_H
2#define _SPARC64_SECTIONS_H
3
4/* nothing to see, move along */
5#include <asm-generic/sections.h>
6
7extern char _start[];
8
9#endif
diff --git a/include/asm-sparc64/segment.h b/include/asm-sparc64/segment.h
new file mode 100644
index 000000000000..b03e709fc945
--- /dev/null
+++ b/include/asm-sparc64/segment.h
@@ -0,0 +1,6 @@
1#ifndef __SPARC64_SEGMENT_H
2#define __SPARC64_SEGMENT_H
3
4/* Only here because we have some old header files that expect it.. */
5
6#endif
diff --git a/include/asm-sparc64/semaphore.h b/include/asm-sparc64/semaphore.h
new file mode 100644
index 000000000000..7419dd88b49e
--- /dev/null
+++ b/include/asm-sparc64/semaphore.h
@@ -0,0 +1,57 @@
1#ifndef _SPARC64_SEMAPHORE_H
2#define _SPARC64_SEMAPHORE_H
3
4/* These are actually reasonable on the V9.
5 *
6 * See asm-ppc/semaphore.h for implementation commentary,
7 * only sparc64 specific issues are commented here.
8 */
9#ifdef __KERNEL__
10
11#include <asm/atomic.h>
12#include <asm/system.h>
13#include <linux/wait.h>
14#include <linux/rwsem.h>
15
16struct semaphore {
17 atomic_t count;
18 wait_queue_head_t wait;
19};
20
21#define __SEMAPHORE_INITIALIZER(name, count) \
22 { ATOMIC_INIT(count), \
23 __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) }
24
25#define __MUTEX_INITIALIZER(name) \
26 __SEMAPHORE_INITIALIZER(name, 1)
27
28#define __DECLARE_SEMAPHORE_GENERIC(name, count) \
29 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
30
31#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
32#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name, 0)
33
34static inline void sema_init (struct semaphore *sem, int val)
35{
36 atomic_set(&sem->count, val);
37 init_waitqueue_head(&sem->wait);
38}
39
40static inline void init_MUTEX (struct semaphore *sem)
41{
42 sema_init(sem, 1);
43}
44
45static inline void init_MUTEX_LOCKED (struct semaphore *sem)
46{
47 sema_init(sem, 0);
48}
49
50extern void up(struct semaphore *sem);
51extern void down(struct semaphore *sem);
52extern int down_trylock(struct semaphore *sem);
53extern int down_interruptible(struct semaphore *sem);
54
55#endif /* __KERNEL__ */
56
57#endif /* !(_SPARC64_SEMAPHORE_H) */
diff --git a/include/asm-sparc64/sembuf.h b/include/asm-sparc64/sembuf.h
new file mode 100644
index 000000000000..99f04e4e288c
--- /dev/null
+++ b/include/asm-sparc64/sembuf.h
@@ -0,0 +1,22 @@
1#ifndef _SPARC64_SEMBUF_H
2#define _SPARC64_SEMBUF_H
3
4/*
5 * The semid64_ds structure for sparc64 architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 2 miscellaneous 64-bit values
11 */
12
13struct semid64_ds {
14 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
15 __kernel_time_t sem_otime; /* last semop time */
16 __kernel_time_t sem_ctime; /* last change time */
17 unsigned long sem_nsems; /* no. of semaphores in array */
18 unsigned long __unused1;
19 unsigned long __unused2;
20};
21
22#endif /* _SPARC64_SEMBUF_H */
diff --git a/include/asm-sparc64/setup.h b/include/asm-sparc64/setup.h
new file mode 100644
index 000000000000..b356ee2cda92
--- /dev/null
+++ b/include/asm-sparc64/setup.h
@@ -0,0 +1,10 @@
1/*
2 * Just a place holder.
3 */
4
5#ifndef _SPARC64_SETUP_H
6#define _SPARC64_SETUP_H
7
8#define COMMAND_LINE_SIZE 256
9
10#endif /* _SPARC64_SETUP_H */
diff --git a/include/asm-sparc64/sfp-machine.h b/include/asm-sparc64/sfp-machine.h
new file mode 100644
index 000000000000..5015bb8d6c32
--- /dev/null
+++ b/include/asm-sparc64/sfp-machine.h
@@ -0,0 +1,91 @@
1/* Machine-dependent software floating-point definitions.
2 Sparc64 kernel version.
3 Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Richard Henderson (rth@cygnus.com),
6 Jakub Jelinek (jj@ultra.linux.cz) and
7 David S. Miller (davem@redhat.com).
8
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
13
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Library General Public
20 License along with the GNU C Library; see the file COPYING.LIB. If
21 not, write to the Free Software Foundation, Inc.,
22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23
24#ifndef _SFP_MACHINE_H
25#define _SFP_MACHINE_H
26
27#define _FP_W_TYPE_SIZE 64
28#define _FP_W_TYPE unsigned long
29#define _FP_WS_TYPE signed long
30#define _FP_I_TYPE long
31
32#define _FP_MUL_MEAT_S(R,X,Y) \
33 _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
34#define _FP_MUL_MEAT_D(R,X,Y) \
35 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
36#define _FP_MUL_MEAT_Q(R,X,Y) \
37 _FP_MUL_MEAT_2_wide_3mul(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
38
39#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
40#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
41#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
42
43#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
44#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1)
45#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1
46#define _FP_NANSIGN_S 0
47#define _FP_NANSIGN_D 0
48#define _FP_NANSIGN_Q 0
49
50#define _FP_KEEPNANFRACP 1
51
52/* If one NaN is signaling and the other is not,
53 * we choose that one, otherwise we choose X.
54 */
55/* For _Qp_* and _Q_*, this should prefer X, for
56 * CPU instruction emulation this should prefer Y.
57 * (see SPAMv9 B.2.2 section).
58 */
59#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
60 do { \
61 if ((_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs) \
62 && !(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
63 { \
64 R##_s = X##_s; \
65 _FP_FRAC_COPY_##wc(R,X); \
66 } \
67 else \
68 { \
69 R##_s = Y##_s; \
70 _FP_FRAC_COPY_##wc(R,Y); \
71 } \
72 R##_c = FP_CLS_NAN; \
73 } while (0)
74
75/* Obtain the current rounding mode. */
76#ifndef FP_ROUNDMODE
77#define FP_ROUNDMODE ((current_thread_info()->xfsr[0] >> 30) & 0x3)
78#endif
79
80/* Exception flags. */
81#define FP_EX_INVALID (1 << 4)
82#define FP_EX_OVERFLOW (1 << 3)
83#define FP_EX_UNDERFLOW (1 << 2)
84#define FP_EX_DIVZERO (1 << 1)
85#define FP_EX_INEXACT (1 << 0)
86
87#define FP_HANDLE_EXCEPTIONS return _fex
88
89#define FP_INHIBIT_RESULTS ((current_thread_info()->xfsr[0] >> 23) & _fex)
90
91#endif
diff --git a/include/asm-sparc64/shmbuf.h b/include/asm-sparc64/shmbuf.h
new file mode 100644
index 000000000000..61c2ef42eba3
--- /dev/null
+++ b/include/asm-sparc64/shmbuf.h
@@ -0,0 +1,38 @@
1#ifndef _SPARC64_SHMBUF_H
2#define _SPARC64_SHMBUF_H
3
4/*
5 * The shmid64_ds structure for sparc64 architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 2 miscellaneous 64-bit values
11 */
12
13struct shmid64_ds {
14 struct ipc64_perm shm_perm; /* operation perms */
15 __kernel_time_t shm_atime; /* last attach time */
16 __kernel_time_t shm_dtime; /* last detach time */
17 __kernel_time_t shm_ctime; /* last change time */
18 size_t shm_segsz; /* size of segment (bytes) */
19 __kernel_pid_t shm_cpid; /* pid of creator */
20 __kernel_pid_t shm_lpid; /* pid of last operator */
21 unsigned long shm_nattch; /* no. of current attaches */
22 unsigned long __unused1;
23 unsigned long __unused2;
24};
25
26struct shminfo64 {
27 unsigned long shmmax;
28 unsigned long shmmin;
29 unsigned long shmmni;
30 unsigned long shmseg;
31 unsigned long shmall;
32 unsigned long __unused1;
33 unsigned long __unused2;
34 unsigned long __unused3;
35 unsigned long __unused4;
36};
37
38#endif /* _SPARC64_SHMBUF_H */
diff --git a/include/asm-sparc64/shmparam.h b/include/asm-sparc64/shmparam.h
new file mode 100644
index 000000000000..8c66fded8a32
--- /dev/null
+++ b/include/asm-sparc64/shmparam.h
@@ -0,0 +1,11 @@
1/* $Id: shmparam.h,v 1.5 2001/09/24 21:17:57 kanoj Exp $ */
2#ifndef _ASMSPARC64_SHMPARAM_H
3#define _ASMSPARC64_SHMPARAM_H
4
5#include <asm/spitfire.h>
6
7#define __ARCH_FORCE_SHMLBA 1
8/* attach addr a multiple of this */
9#define SHMLBA ((PAGE_SIZE > L1DCACHE_SIZE) ? PAGE_SIZE : L1DCACHE_SIZE)
10
11#endif /* _ASMSPARC64_SHMPARAM_H */
diff --git a/include/asm-sparc64/sigcontext.h b/include/asm-sparc64/sigcontext.h
new file mode 100644
index 000000000000..d8073373db8c
--- /dev/null
+++ b/include/asm-sparc64/sigcontext.h
@@ -0,0 +1,88 @@
1/* $Id: sigcontext.h,v 1.12 1999/09/06 08:22:09 jj Exp $ */
2#ifndef __SPARC64_SIGCONTEXT_H
3#define __SPARC64_SIGCONTEXT_H
4
5#ifdef __KERNEL__
6#include <asm/ptrace.h>
7#endif
8
9#ifndef __ASSEMBLY__
10
11#ifdef __KERNEL__
12
13#define __SUNOS_MAXWIN 31
14
15/* This is what SunOS does, so shall I unless we use new 32bit signals or rt signals. */
16struct sigcontext32 {
17 int sigc_onstack; /* state to restore */
18 int sigc_mask; /* sigmask to restore */
19 int sigc_sp; /* stack pointer */
20 int sigc_pc; /* program counter */
21 int sigc_npc; /* next program counter */
22 int sigc_psr; /* for condition codes etc */
23 int sigc_g1; /* User uses these two registers */
24 int sigc_o0; /* within the trampoline code. */
25
26 /* Now comes information regarding the users window set
27 * at the time of the signal.
28 */
29 int sigc_oswins; /* outstanding windows */
30
31 /* stack ptrs for each regwin buf */
32 unsigned sigc_spbuf[__SUNOS_MAXWIN];
33
34 /* Windows to restore after signal */
35 struct reg_window32 sigc_wbuf[__SUNOS_MAXWIN];
36};
37
38#endif
39
40#ifdef __KERNEL__
41
42/* This is what we use for 32bit new non-rt signals. */
43
44typedef struct {
45 struct {
46 unsigned int psr;
47 unsigned int pc;
48 unsigned int npc;
49 unsigned int y;
50 unsigned int u_regs[16]; /* globals and ins */
51 } si_regs;
52 int si_mask;
53} __siginfo32_t;
54
55#endif
56
57typedef struct {
58 unsigned int si_float_regs [64];
59 unsigned long si_fsr;
60 unsigned long si_gsr;
61 unsigned long si_fprs;
62} __siginfo_fpu_t;
63
64/* This is what SunOS doesn't, so we have to write this alone
65 and do it properly. */
66struct sigcontext {
67 /* The size of this array has to match SI_MAX_SIZE from siginfo.h */
68 char sigc_info[128];
69 struct {
70 unsigned long u_regs[16]; /* globals and ins */
71 unsigned long tstate;
72 unsigned long tpc;
73 unsigned long tnpc;
74 unsigned int y;
75 unsigned int fprs;
76 } sigc_regs;
77 __siginfo_fpu_t * sigc_fpu_save;
78 struct {
79 void * ss_sp;
80 int ss_flags;
81 unsigned long ss_size;
82 } sigc_stack;
83 unsigned long sigc_mask;
84};
85
86#endif /* !(__ASSEMBLY__) */
87
88#endif /* !(__SPARC64_SIGCONTEXT_H) */
diff --git a/include/asm-sparc64/siginfo.h b/include/asm-sparc64/siginfo.h
new file mode 100644
index 000000000000..7160449e7cab
--- /dev/null
+++ b/include/asm-sparc64/siginfo.h
@@ -0,0 +1,35 @@
1#ifndef _SPARC64_SIGINFO_H
2#define _SPARC64_SIGINFO_H
3
4#define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
5
6#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 4)
7
8#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
9#define __ARCH_SI_TRAPNO
10#define __ARCH_SI_BAND_T int
11
12#include <asm-generic/siginfo.h>
13
14#ifdef __KERNEL__
15
16#include <linux/config.h>
17#include <linux/compat.h>
18
19#ifdef CONFIG_COMPAT
20
21struct compat_siginfo;
22
23#endif /* CONFIG_COMPAT */
24
25#endif /* __KERNEL__ */
26
27#define SI_NOINFO 32767 /* no information in siginfo_t */
28
29/*
30 * SIGEMT si_codes
31 */
32#define EMT_TAGOVF (__SI_FAULT|1) /* tag overflow */
33#define NSIGEMT 1
34
35#endif
diff --git a/include/asm-sparc64/signal.h b/include/asm-sparc64/signal.h
new file mode 100644
index 000000000000..6428e366c38c
--- /dev/null
+++ b/include/asm-sparc64/signal.h
@@ -0,0 +1,276 @@
1/* $Id: signal.h,v 1.9 1999/09/06 08:22:11 jj Exp $ */
2#ifndef _ASMSPARC64_SIGNAL_H
3#define _ASMSPARC64_SIGNAL_H
4
5#include <asm/sigcontext.h>
6
7#ifdef __KERNEL__
8#ifndef __ASSEMBLY__
9#include <linux/config.h>
10#include <linux/personality.h>
11#include <linux/types.h>
12#include <linux/compat.h>
13#endif
14#endif
15
16/* On the Sparc the signal handlers get passed a 'sub-signal' code
17 * for certain signal types, which we document here.
18 */
19#define SIGHUP 1
20#define SIGINT 2
21#define SIGQUIT 3
22#define SIGILL 4
23#define SUBSIG_STACK 0
24#define SUBSIG_ILLINST 2
25#define SUBSIG_PRIVINST 3
26#define SUBSIG_BADTRAP(t) (0x80 + (t))
27
28#define SIGTRAP 5
29#define SIGABRT 6
30#define SIGIOT 6
31
32#define SIGEMT 7
33#define SUBSIG_TAG 10
34
35#define SIGFPE 8
36#define SUBSIG_FPDISABLED 0x400
37#define SUBSIG_FPERROR 0x404
38#define SUBSIG_FPINTOVFL 0x001
39#define SUBSIG_FPSTSIG 0x002
40#define SUBSIG_IDIVZERO 0x014
41#define SUBSIG_FPINEXACT 0x0c4
42#define SUBSIG_FPDIVZERO 0x0c8
43#define SUBSIG_FPUNFLOW 0x0cc
44#define SUBSIG_FPOPERROR 0x0d0
45#define SUBSIG_FPOVFLOW 0x0d4
46
47#define SIGKILL 9
48#define SIGBUS 10
49#define SUBSIG_BUSTIMEOUT 1
50#define SUBSIG_ALIGNMENT 2
51#define SUBSIG_MISCERROR 5
52
53#define SIGSEGV 11
54#define SUBSIG_NOMAPPING 3
55#define SUBSIG_PROTECTION 4
56#define SUBSIG_SEGERROR 5
57
58#define SIGSYS 12
59
60#define SIGPIPE 13
61#define SIGALRM 14
62#define SIGTERM 15
63#define SIGURG 16
64
65/* SunOS values which deviate from the Linux/i386 ones */
66#define SIGSTOP 17
67#define SIGTSTP 18
68#define SIGCONT 19
69#define SIGCHLD 20
70#define SIGTTIN 21
71#define SIGTTOU 22
72#define SIGIO 23
73#define SIGPOLL SIGIO /* SysV name for SIGIO */
74#define SIGXCPU 24
75#define SIGXFSZ 25
76#define SIGVTALRM 26
77#define SIGPROF 27
78#define SIGWINCH 28
79#define SIGLOST 29
80#define SIGPWR SIGLOST
81#define SIGUSR1 30
82#define SIGUSR2 31
83
84/* Most things should be clean enough to redefine this at will, if care
85 is taken to make libc match. */
86
87#define __OLD_NSIG 32
88#define __NEW_NSIG 64
89#define _NSIG_BPW 64
90#define _NSIG_WORDS (__NEW_NSIG / _NSIG_BPW)
91
92#define SIGRTMIN 32
93#define SIGRTMAX __NEW_NSIG
94
95#if defined(__KERNEL__) || defined(__WANT_POSIX1B_SIGNALS__)
96#define _NSIG __NEW_NSIG
97#define __new_sigset_t sigset_t
98#define __new_sigaction sigaction
99#define __new_sigaction32 sigaction32
100#define __old_sigset_t old_sigset_t
101#define __old_sigaction old_sigaction
102#define __old_sigaction32 old_sigaction32
103#else
104#define _NSIG __OLD_NSIG
105#define NSIG _NSIG
106#define __old_sigset_t sigset_t
107#define __old_sigaction sigaction
108#define __old_sigaction32 sigaction32
109#endif
110
111#ifndef __ASSEMBLY__
112
113typedef unsigned long __old_sigset_t; /* at least 32 bits */
114
115typedef struct {
116 unsigned long sig[_NSIG_WORDS];
117} __new_sigset_t;
118
119/* A SunOS sigstack */
120struct sigstack {
121 /* XXX 32-bit pointers pinhead XXX */
122 char *the_stack;
123 int cur_status;
124};
125
126/* Sigvec flags */
127#define _SV_SSTACK 1u /* This signal handler should use sig-stack */
128#define _SV_INTR 2u /* Sig return should not restart system call */
129#define _SV_RESET 4u /* Set handler to SIG_DFL upon taken signal */
130#define _SV_IGNCHILD 8u /* Do not send SIGCHLD */
131
132/*
133 * sa_flags values: SA_STACK is not currently supported, but will allow the
134 * usage of signal stacks by using the (now obsolete) sa_restorer field in
135 * the sigaction structure as a stack pointer. This is now possible due to
136 * the changes in signal handling. LBT 010493.
137 * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
138 * SA_RESTART flag to get restarting signals (which were the default long ago)
139 * SA_SHIRQ flag is for shared interrupt support on PCI and EISA.
140 */
141#define SA_NOCLDSTOP _SV_IGNCHILD
142#define SA_STACK _SV_SSTACK
143#define SA_ONSTACK _SV_SSTACK
144#define SA_RESTART _SV_INTR
145#define SA_ONESHOT _SV_RESET
146#define SA_INTERRUPT 0x10u
147#define SA_NOMASK 0x20u
148#define SA_SHIRQ 0x40u
149#define SA_NOCLDWAIT 0x100u
150#define SA_SIGINFO 0x200u
151
152
153#define SIG_BLOCK 0x01 /* for blocking signals */
154#define SIG_UNBLOCK 0x02 /* for unblocking signals */
155#define SIG_SETMASK 0x04 /* for setting the signal mask */
156
157/*
158 * sigaltstack controls
159 */
160#define SS_ONSTACK 1
161#define SS_DISABLE 2
162
163#define MINSIGSTKSZ 4096
164#define SIGSTKSZ 16384
165
166#ifdef __KERNEL__
167/*
168 * These values of sa_flags are used only by the kernel as part of the
169 * irq handling routines.
170 *
171 * SA_INTERRUPT is also used by the irq handling routines.
172 *
173 * DJHR
174 * SA_STATIC_ALLOC is used for the SPARC system to indicate that this
175 * interrupt handler's irq structure should be statically allocated
176 * by the request_irq routine.
177 * The alternative is that arch/sparc/kernel/irq.c has carnal knowledge
178 * of interrupt usage and that sucks. Also without a flag like this
179 * it may be possible for the free_irq routine to attempt to free
180 * statically allocated data.. which is NOT GOOD.
181 *
182 */
183#define SA_PROBE SA_ONESHOT
184#define SA_SAMPLE_RANDOM SA_RESTART
185#define SA_STATIC_ALLOC 0x80
186#endif
187
188/* Type of a signal handler. */
189#ifdef __KERNEL__
190typedef void __signalfn_t(int);
191typedef __signalfn_t __user *__sighandler_t;
192
193typedef void __restorefn_t(void);
194typedef __restorefn_t __user *__sigrestore_t;
195#else
196typedef void (*__sighandler_t)(int);
197typedef void (*__sigrestore_t)(void);
198#endif
199
200#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
201#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
202#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
203
204struct __new_sigaction {
205 __sighandler_t sa_handler;
206 unsigned long sa_flags;
207 __sigrestore_t sa_restorer; /* not used by Linux/SPARC yet */
208 __new_sigset_t sa_mask;
209};
210
211#ifdef __KERNEL__
212
213#ifdef CONFIG_COMPAT
214struct __new_sigaction32 {
215 unsigned sa_handler;
216 unsigned int sa_flags;
217 unsigned sa_restorer; /* not used by Linux/SPARC yet */
218 compat_sigset_t sa_mask;
219};
220#endif
221
222struct k_sigaction {
223 struct __new_sigaction sa;
224 void __user *ka_restorer;
225};
226#endif
227
228struct __old_sigaction {
229 __sighandler_t sa_handler;
230 __old_sigset_t sa_mask;
231 unsigned long sa_flags;
232 void (*sa_restorer)(void); /* not used by Linux/SPARC yet */
233};
234
235#ifdef __KERNEL__
236
237#ifdef CONFIG_COMPAT
238struct __old_sigaction32 {
239 unsigned sa_handler;
240 compat_old_sigset_t sa_mask;
241 unsigned int sa_flags;
242 unsigned sa_restorer; /* not used by Linux/SPARC yet */
243};
244#endif
245
246#endif
247
248typedef struct sigaltstack {
249 void __user *ss_sp;
250 int ss_flags;
251 size_t ss_size;
252} stack_t;
253
254#ifdef __KERNEL__
255
256#ifdef CONFIG_COMPAT
257typedef struct sigaltstack32 {
258 u32 ss_sp;
259 int ss_flags;
260 compat_size_t ss_size;
261} stack_t32;
262#endif
263
264struct signal_deliver_cookie {
265 int restart_syscall;
266 unsigned long orig_i0;
267};
268
269struct pt_regs;
270extern void ptrace_signal_deliver(struct pt_regs *regs, void *cookie);
271
272#endif /* !(__KERNEL__) */
273
274#endif /* !(__ASSEMBLY__) */
275
276#endif /* !(_ASMSPARC64_SIGNAL_H) */
diff --git a/include/asm-sparc64/smp.h b/include/asm-sparc64/smp.h
new file mode 100644
index 000000000000..5e3e06d908fe
--- /dev/null
+++ b/include/asm-sparc64/smp.h
@@ -0,0 +1,75 @@
1/* smp.h: Sparc64 specific SMP stuff.
2 *
3 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
4 */
5
6#ifndef _SPARC64_SMP_H
7#define _SPARC64_SMP_H
8
9#include <linux/config.h>
10#include <linux/threads.h>
11#include <asm/asi.h>
12#include <asm/starfire.h>
13#include <asm/spitfire.h>
14
15#ifndef __ASSEMBLY__
16
17#include <linux/cpumask.h>
18#include <linux/cache.h>
19
20#endif /* !(__ASSEMBLY__) */
21
22#ifdef CONFIG_SMP
23
24#ifndef __ASSEMBLY__
25
26/*
27 * Private routines/data
28 */
29
30#include <asm/bitops.h>
31#include <asm/atomic.h>
32
33extern cpumask_t phys_cpu_present_map;
34#define cpu_possible_map phys_cpu_present_map
35
36/*
37 * General functions that each host system must provide.
38 */
39
40static __inline__ int hard_smp_processor_id(void)
41{
42 if (tlb_type == cheetah || tlb_type == cheetah_plus) {
43 unsigned long cfg, ver;
44 __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
45 if ((ver >> 32) == 0x003e0016) {
46 __asm__ __volatile__("ldxa [%%g0] %1, %0"
47 : "=r" (cfg)
48 : "i" (ASI_JBUS_CONFIG));
49 return ((cfg >> 17) & 0x1f);
50 } else {
51 __asm__ __volatile__("ldxa [%%g0] %1, %0"
52 : "=r" (cfg)
53 : "i" (ASI_SAFARI_CONFIG));
54 return ((cfg >> 17) & 0x3ff);
55 }
56 } else if (this_is_starfire != 0) {
57 return starfire_hard_smp_processor_id();
58 } else {
59 unsigned long upaconfig;
60 __asm__ __volatile__("ldxa [%%g0] %1, %0"
61 : "=r" (upaconfig)
62 : "i" (ASI_UPA_CONFIG));
63 return ((upaconfig >> 17) & 0x1f);
64 }
65}
66
67#define smp_processor_id() (current_thread_info()->cpu)
68
69#endif /* !(__ASSEMBLY__) */
70
71#endif /* !(CONFIG_SMP) */
72
73#define NO_PROC_ID 0xFF
74
75#endif /* !(_SPARC64_SMP_H) */
diff --git a/include/asm-sparc64/socket.h b/include/asm-sparc64/socket.h
new file mode 100644
index 000000000000..865547a23908
--- /dev/null
+++ b/include/asm-sparc64/socket.h
@@ -0,0 +1,55 @@
1/* $Id: socket.h,v 1.10 2001/06/13 16:25:03 davem Exp $ */
2#ifndef _ASM_SOCKET_H
3#define _ASM_SOCKET_H
4
5#include <asm/sockios.h>
6
7/* For setsockopt(2) */
8#define SOL_SOCKET 0xffff
9
10#define SO_DEBUG 0x0001
11#define SO_PASSCRED 0x0002
12#define SO_REUSEADDR 0x0004
13#define SO_KEEPALIVE 0x0008
14#define SO_DONTROUTE 0x0010
15#define SO_BROADCAST 0x0020
16#define SO_PEERCRED 0x0040
17#define SO_LINGER 0x0080
18#define SO_OOBINLINE 0x0100
19/* To add :#define SO_REUSEPORT 0x0200 */
20#define SO_BSDCOMPAT 0x0400
21#define SO_RCVLOWAT 0x0800
22#define SO_SNDLOWAT 0x1000
23#define SO_RCVTIMEO 0x2000
24#define SO_SNDTIMEO 0x4000
25#define SO_ACCEPTCONN 0x8000
26
27/* wha!??? */
28#define SO_DONTLINGER (~SO_LINGER) /* Older SunOS compat. hack */
29
30#define SO_SNDBUF 0x1001
31#define SO_RCVBUF 0x1002
32#define SO_ERROR 0x1007
33#define SO_TYPE 0x1008
34
35/* Linux specific, keep the same. */
36#define SO_NO_CHECK 0x000b
37#define SO_PRIORITY 0x000c
38
39#define SO_BINDTODEVICE 0x000d
40
41#define SO_ATTACH_FILTER 0x001a
42#define SO_DETACH_FILTER 0x001b
43
44#define SO_PEERNAME 0x001c
45#define SO_TIMESTAMP 0x001d
46#define SCM_TIMESTAMP SO_TIMESTAMP
47
48#define SO_PEERSEC 0x001e
49
50/* Security levels - as per NRL IPv6 - don't actually do anything */
51#define SO_SECURITY_AUTHENTICATION 0x5001
52#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
53#define SO_SECURITY_ENCRYPTION_NETWORK 0x5004
54
55#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-sparc64/sockios.h b/include/asm-sparc64/sockios.h
new file mode 100644
index 000000000000..6735bab4f39d
--- /dev/null
+++ b/include/asm-sparc64/sockios.h
@@ -0,0 +1,13 @@
1#ifndef _ASM_SPARC64_SOCKIOS_H
2#define _ASM_SPARC64_SOCKIOS_H
3
4/* Socket-level I/O control calls. */
5#define FIOSETOWN 0x8901
6#define SIOCSPGRP 0x8902
7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp */
11
12#endif /* !(_ASM_SPARC64_SOCKIOS_H) */
13
diff --git a/include/asm-sparc64/solerrno.h b/include/asm-sparc64/solerrno.h
new file mode 100644
index 000000000000..a2ea6fcf3446
--- /dev/null
+++ b/include/asm-sparc64/solerrno.h
@@ -0,0 +1,132 @@
1/* $Id: solerrno.h,v 1.1 1996/12/26 14:22:40 davem Exp $
2 * solerrno.h: Solaris error return codes for compatibility.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_SOLERRNO_H
8#define _SPARC64_SOLERRNO_H
9
10#define SOL_EPERM 1 /* Required superuser access perms */
11#define SOL_ENOENT 2 /* File or directory does not exist */
12#define SOL_ESRCH 3 /* Process did not exist */
13#define SOL_EINTR 4 /* System call was interrupted */
14#define SOL_EIO 5 /* An i/o error occurred */
15#define SOL_ENXIO 6 /* Device or Address does not exist */
16#define SOL_E2BIG 7 /* Too many arguments were given */
17#define SOL_ENOEXEC 8 /* Header of executable was munged */
18#define SOL_EBADF 9 /* Bogus file number */
19#define SOL_ECHILD 10 /* No children of process exist */
20#define SOL_EAGAIN 11 /* beep beep, "try again later" */
21#define SOL_ENOMEM 12 /* No memory available */
22#define SOL_EACCES 13 /* Access not allowed */
23#define SOL_EFAULT 14 /* Address passed was invalid */
24#define SOL_ENOTBLK 15 /* blkdev op on non-block device */
25#define SOL_EBUSY 16 /* Mounted device was busy */
26#define SOL_EEXIST 17 /* File specified already exists */
27#define SOL_EXDEV 18 /* Link request across diff devices */
28#define SOL_ENODEV 19 /* Device does not exist on system */
29#define SOL_ENOTDIR 20 /* Dir operation on non-directory */
30#define SOL_EISDIR 21 /* File was of directory type */
31#define SOL_EINVAL 22 /* Argument passed was invalid */
32#define SOL_ENFILE 23 /* No more room in file table */
33#define SOL_EMFILE 24 /* Proc has too many files open */
34#define SOL_ENOTTY 25 /* Ioctl was invalid for req device */
35#define SOL_ETXTBSY 26 /* Text file in busy state */
36#define SOL_EFBIG 27 /* Too big of a file for operation */
37#define SOL_ENOSPC 28 /* Disk is full */
38#define SOL_ESPIPE 29 /* Seek attempted on non-seeking dev*/
39#define SOL_EROFS 30 /* Write attempted on read-only fs */
40#define SOL_EMLINK 31 /* Too many links in file search */
41#define SOL_EPIPE 32 /* Call a plumber */
42#define SOL_EDOM 33 /* Argument was out of fct domain */
43#define SOL_ERANGE 34 /* Could not represent math result */
44#define SOL_ENOMSG 35 /* Message of req type doesn't exist */
45#define SOL_EIDRM 36 /* Identifier has been removed */
46#define SOL_ECHRNG 37 /* Req channel number out of range */
47#define SOL_EL2NSYNC 38 /* Could not sync at run level 2 */
48#define SOL_EL3HLT 39 /* Halted at run level 3 */
49#define SOL_EL3RST 40 /* Reset at run level 3 */
50#define SOL_ELNRNG 41 /* Out of range link number */
51#define SOL_EUNATCH 42 /* Driver for protocol not attached */
52#define SOL_ENOCSI 43 /* CSI structure not around */
53#define SOL_EL2HLT 44 /* Halted at run level 2 */
54#define SOL_EDEADLK 45 /* Deadlock condition detected */
55#define SOL_ENOLCK 46 /* Record locks unavailable */
56#define SOL_ECANCELED 47 /* Cancellation of oper. happened */
57#define SOL_ENOTSUP 48 /* Attempt of unsupported operation */
58#define SOL_EDQUOT 49 /* Users disk quota exceeded */
59#define SOL_EBADE 50 /* Invalid exchange */
60#define SOL_EBADR 51 /* Request descriptor was invalid */
61#define SOL_EXFULL 52 /* Full exchange */
62#define SOL_ENOANO 53 /* ano does not exist */
63#define SOL_EBADRQC 54 /* Req code was invalid */
64#define SOL_EBADSLT 55 /* Bad slot number */
65#define SOL_EDEADLOCK 56 /* Deadlock in fs error */
66#define SOL_EBFONT 57 /* Font file format invalid */
67/* YOW, I LOVE SYSV STREAMS!!!! */
68#define SOL_ENOSTR 60 /* Stream-op on non-stream dev */
69#define SOL_ENODATA 61 /* No data avail at this time */
70#define SOL_ETIME 62 /* Expiration of time occurred */
71#define SOL_ENOSR 63 /* Streams resources exhausted */
72#define SOL_ENONET 64 /* No network connected */
73#define SOL_ENOPKG 65 /* Non-installed package */
74#define SOL_EREMOTE 66 /* Object was on remote machine */
75#define SOL_ENOLINK 67 /* Cut link */
76#define SOL_EADV 68 /* Error in advertise */
77#define SOL_ESRMNT 69 /* Some magic srmount problem */
78#define SOL_ECOMM 70 /* During send, comm error occurred */
79#define SOL_EPROTO 71 /* Protocol botch */
80#define SOL_EMULTIHOP 74 /* Multihop attempted */
81#define SOL_EBADMSG 77 /* Message was unreadable */
82#define SOL_ENAMETOOLONG 78 /* Too long of a path name */
83#define SOL_EOVERFLOW 79 /* Data type too small for datum */
84#define SOL_ENOTUNIQ 80 /* Logical name was not unique */
85#define SOL_EBADFD 81 /* Op cannot be performed on fd */
86#define SOL_EREMCHG 82 /* Remote address is now different */
87#define SOL_ELIBACC 83 /* Shared lib could not be accessed */
88#define SOL_ELIBBAD 84 /* ShLib is corrupted in some way */
89#define SOL_ELIBSCN 85 /* A.out ShLib problems */
90#define SOL_ELIBMAX 86 /* Exceeded ShLib linkage limit */
91#define SOL_ELIBEXEC 87 /* Execution of ShLib attempted */
92#define SOL_EILSEQ 88 /* Bad byte sequence found */
93#define SOL_ENOSYS 89 /* Invalid filesystem operation */
94#define SOL_ELOOP 90 /* Detected loop in symbolic links */
95#define SOL_ERESTART 91 /* System call is restartable */
96#define SOL_ESTRPIPE 92 /* Do not sleep in head of stream */
97#define SOL_ENOTEMPTY 93 /* Rmdir of non-empty directory */
98#define SOL_EUSERS 94 /* Over abundance of users for ufs */
99#define SOL_ENOTSOCK 95 /* Sock-op on non-sock */
100#define SOL_EDESTADDRREQ 96 /* No dest addr given, but needed */
101#define SOL_EMSGSIZE 97 /* Msg too big */
102#define SOL_EPROTOTYPE 98 /* Bad socket protocol */
103#define SOL_ENOPROTOOPT 99 /* Unavailable protocol */
104#define SOL_EPROTONOSUPPORT 120 /* Unsupported protocol */
105#define SOL_ESOCKTNOSUPPORT 121 /* Unsupported socket type */
106#define SOL_EOPNOTSUPP 122 /* Unsupported sock-op */
107#define SOL_EPFNOSUPPORT 123 /* Unsupported protocol family */
108#define SOL_EAFNOSUPPORT 124 /* Unsup addr family for protocol */
109#define SOL_EADDRINUSE 125 /* Req addr is already in use */
110#define SOL_EADDRNOTAVAIL 126 /* Req addr not available right now */
111#define SOL_ENETDOWN 127 /* Your subnet is on fire */
112#define SOL_ENETUNREACH 128 /* Someone playing with gateway and */
113 /* did not tell you he was going to */
114#define SOL_ENETRESET 129 /* Buy less-buggy ethernet cards */
115#define SOL_ECONNABORTED 130 /* Aborted connection due to sw */
116#define SOL_ECONNRESET 131 /* Your peers reset your connection */
117#define SOL_ENOBUFS 132 /* No buffer space available */
118#define SOL_EISCONN 133 /* Connect on already connected */
119 /* socket attempted */
120#define SOL_ENOTCONN 134 /* Comm on non-connected socket */
121#define SOL_ESHUTDOWN 143 /* Op attempted after sock-shutdown */
122#define SOL_ETOOMANYREFS 144 /* Reference limit exceeded */
123#define SOL_ETIMEDOUT 145 /* Timed out connection */
124#define SOL_ECONNREFUSED 146 /* Connection refused by remote host*/
125#define SOL_EHOSTDOWN 147 /* Remote host is up in flames */
126#define SOL_EHOSTUNREACH 148 /* Make a left at Easton Ave..... */
127#define SOL_EWOULDBLOCK EAGAIN /* Just an alias */
128#define SOL_EALREADY 149 /* Operation is already occurring */
129#define SOL_EINPROGRESS 150 /* Operation is happening now */
130#define SOL_ESTALE 151 /* Fungus growth on NFS file handle */
131
132#endif /* !(_SPARC64_SOLERRNO_H) */
diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h
new file mode 100644
index 000000000000..11efa474865b
--- /dev/null
+++ b/include/asm-sparc64/spinlock.h
@@ -0,0 +1,310 @@
1/* spinlock.h: 64-bit Sparc spinlock support.
2 *
3 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
4 */
5
6#ifndef __SPARC64_SPINLOCK_H
7#define __SPARC64_SPINLOCK_H
8
9#include <linux/config.h>
10#include <linux/threads.h> /* For NR_CPUS */
11
12#ifndef __ASSEMBLY__
13
14/* To get debugging spinlocks which detect and catch
15 * deadlock situations, set CONFIG_DEBUG_SPINLOCK
16 * and rebuild your kernel.
17 */
18
19/* All of these locking primitives are expected to work properly
20 * even in an RMO memory model, which currently is what the kernel
21 * runs in.
22 *
23 * There is another issue. Because we play games to save cycles
24 * in the non-contention case, we need to be extra careful about
25 * branch targets into the "spinning" code. They live in their
26 * own section, but the newer V9 branches have a shorter range
27 * than the traditional 32-bit sparc branch variants. The rule
28 * is that the branches that go into and out of the spinner sections
29 * must be pre-V9 branches.
30 */
31
32#ifndef CONFIG_DEBUG_SPINLOCK
33
34typedef unsigned char spinlock_t;
35#define SPIN_LOCK_UNLOCKED 0
36
37#define spin_lock_init(lock) (*((unsigned char *)(lock)) = 0)
38#define spin_is_locked(lock) (*((volatile unsigned char *)(lock)) != 0)
39
40#define spin_unlock_wait(lock) \
41do { membar("#LoadLoad"); \
42} while(*((volatile unsigned char *)lock))
43
44static inline void _raw_spin_lock(spinlock_t *lock)
45{
46 unsigned long tmp;
47
48 __asm__ __volatile__(
49"1: ldstub [%1], %0\n"
50" brnz,pn %0, 2f\n"
51" membar #StoreLoad | #StoreStore\n"
52" .subsection 2\n"
53"2: ldub [%1], %0\n"
54" brnz,pt %0, 2b\n"
55" membar #LoadLoad\n"
56" ba,a,pt %%xcc, 1b\n"
57" .previous"
58 : "=&r" (tmp)
59 : "r" (lock)
60 : "memory");
61}
62
63static inline int _raw_spin_trylock(spinlock_t *lock)
64{
65 unsigned long result;
66
67 __asm__ __volatile__(
68" ldstub [%1], %0\n"
69" membar #StoreLoad | #StoreStore"
70 : "=r" (result)
71 : "r" (lock)
72 : "memory");
73
74 return (result == 0UL);
75}
76
77static inline void _raw_spin_unlock(spinlock_t *lock)
78{
79 __asm__ __volatile__(
80" membar #StoreStore | #LoadStore\n"
81" stb %%g0, [%0]"
82 : /* No outputs */
83 : "r" (lock)
84 : "memory");
85}
86
87static inline void _raw_spin_lock_flags(spinlock_t *lock, unsigned long flags)
88{
89 unsigned long tmp1, tmp2;
90
91 __asm__ __volatile__(
92"1: ldstub [%2], %0\n"
93" brnz,pn %0, 2f\n"
94" membar #StoreLoad | #StoreStore\n"
95" .subsection 2\n"
96"2: rdpr %%pil, %1\n"
97" wrpr %3, %%pil\n"
98"3: ldub [%2], %0\n"
99" brnz,pt %0, 3b\n"
100" membar #LoadLoad\n"
101" ba,pt %%xcc, 1b\n"
102" wrpr %1, %%pil\n"
103" .previous"
104 : "=&r" (tmp1), "=&r" (tmp2)
105 : "r"(lock), "r"(flags)
106 : "memory");
107}
108
109#else /* !(CONFIG_DEBUG_SPINLOCK) */
110
111typedef struct {
112 unsigned char lock;
113 unsigned int owner_pc, owner_cpu;
114} spinlock_t;
115#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0xff }
116#define spin_lock_init(__lock) \
117do { (__lock)->lock = 0; \
118 (__lock)->owner_pc = 0; \
119 (__lock)->owner_cpu = 0xff; \
120} while(0)
121#define spin_is_locked(__lock) (*((volatile unsigned char *)(&((__lock)->lock))) != 0)
122#define spin_unlock_wait(__lock) \
123do { \
124 membar("#LoadLoad"); \
125} while(*((volatile unsigned char *)(&((__lock)->lock))))
126
127extern void _do_spin_lock (spinlock_t *lock, char *str);
128extern void _do_spin_unlock (spinlock_t *lock);
129extern int _do_spin_trylock (spinlock_t *lock);
130
131#define _raw_spin_trylock(lp) _do_spin_trylock(lp)
132#define _raw_spin_lock(lock) _do_spin_lock(lock, "spin_lock")
133#define _raw_spin_unlock(lock) _do_spin_unlock(lock)
134#define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock)
135
136#endif /* CONFIG_DEBUG_SPINLOCK */
137
138/* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
139
140#ifndef CONFIG_DEBUG_SPINLOCK
141
142typedef unsigned int rwlock_t;
143#define RW_LOCK_UNLOCKED 0
144#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
145
146static void inline __read_lock(rwlock_t *lock)
147{
148 unsigned long tmp1, tmp2;
149
150 __asm__ __volatile__ (
151"1: ldsw [%2], %0\n"
152" brlz,pn %0, 2f\n"
153"4: add %0, 1, %1\n"
154" cas [%2], %0, %1\n"
155" cmp %0, %1\n"
156" bne,pn %%icc, 1b\n"
157" membar #StoreLoad | #StoreStore\n"
158" .subsection 2\n"
159"2: ldsw [%2], %0\n"
160" brlz,pt %0, 2b\n"
161" membar #LoadLoad\n"
162" ba,a,pt %%xcc, 4b\n"
163" .previous"
164 : "=&r" (tmp1), "=&r" (tmp2)
165 : "r" (lock)
166 : "memory");
167}
168
169static void inline __read_unlock(rwlock_t *lock)
170{
171 unsigned long tmp1, tmp2;
172
173 __asm__ __volatile__(
174" membar #StoreLoad | #LoadLoad\n"
175"1: lduw [%2], %0\n"
176" sub %0, 1, %1\n"
177" cas [%2], %0, %1\n"
178" cmp %0, %1\n"
179" bne,pn %%xcc, 1b\n"
180" nop"
181 : "=&r" (tmp1), "=&r" (tmp2)
182 : "r" (lock)
183 : "memory");
184}
185
186static void inline __write_lock(rwlock_t *lock)
187{
188 unsigned long mask, tmp1, tmp2;
189
190 mask = 0x80000000UL;
191
192 __asm__ __volatile__(
193"1: lduw [%2], %0\n"
194" brnz,pn %0, 2f\n"
195"4: or %0, %3, %1\n"
196" cas [%2], %0, %1\n"
197" cmp %0, %1\n"
198" bne,pn %%icc, 1b\n"
199" membar #StoreLoad | #StoreStore\n"
200" .subsection 2\n"
201"2: lduw [%2], %0\n"
202" brnz,pt %0, 2b\n"
203" membar #LoadLoad\n"
204" ba,a,pt %%xcc, 4b\n"
205" .previous"
206 : "=&r" (tmp1), "=&r" (tmp2)
207 : "r" (lock), "r" (mask)
208 : "memory");
209}
210
211static void inline __write_unlock(rwlock_t *lock)
212{
213 __asm__ __volatile__(
214" membar #LoadStore | #StoreStore\n"
215" stw %%g0, [%0]"
216 : /* no outputs */
217 : "r" (lock)
218 : "memory");
219}
220
221static int inline __write_trylock(rwlock_t *lock)
222{
223 unsigned long mask, tmp1, tmp2, result;
224
225 mask = 0x80000000UL;
226
227 __asm__ __volatile__(
228" mov 0, %2\n"
229"1: lduw [%3], %0\n"
230" brnz,pn %0, 2f\n"
231" or %0, %4, %1\n"
232" cas [%3], %0, %1\n"
233" cmp %0, %1\n"
234" bne,pn %%icc, 1b\n"
235" membar #StoreLoad | #StoreStore\n"
236" mov 1, %2\n"
237"2:"
238 : "=&r" (tmp1), "=&r" (tmp2), "=&r" (result)
239 : "r" (lock), "r" (mask)
240 : "memory");
241
242 return result;
243}
244
245#define _raw_read_lock(p) __read_lock(p)
246#define _raw_read_unlock(p) __read_unlock(p)
247#define _raw_write_lock(p) __write_lock(p)
248#define _raw_write_unlock(p) __write_unlock(p)
249#define _raw_write_trylock(p) __write_trylock(p)
250
251#else /* !(CONFIG_DEBUG_SPINLOCK) */
252
253typedef struct {
254 unsigned long lock;
255 unsigned int writer_pc, writer_cpu;
256 unsigned int reader_pc[NR_CPUS];
257} rwlock_t;
258#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { } }
259#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
260
261extern void _do_read_lock(rwlock_t *rw, char *str);
262extern void _do_read_unlock(rwlock_t *rw, char *str);
263extern void _do_write_lock(rwlock_t *rw, char *str);
264extern void _do_write_unlock(rwlock_t *rw);
265extern int _do_write_trylock(rwlock_t *rw, char *str);
266
267#define _raw_read_lock(lock) \
268do { unsigned long flags; \
269 local_irq_save(flags); \
270 _do_read_lock(lock, "read_lock"); \
271 local_irq_restore(flags); \
272} while(0)
273
274#define _raw_read_unlock(lock) \
275do { unsigned long flags; \
276 local_irq_save(flags); \
277 _do_read_unlock(lock, "read_unlock"); \
278 local_irq_restore(flags); \
279} while(0)
280
281#define _raw_write_lock(lock) \
282do { unsigned long flags; \
283 local_irq_save(flags); \
284 _do_write_lock(lock, "write_lock"); \
285 local_irq_restore(flags); \
286} while(0)
287
288#define _raw_write_unlock(lock) \
289do { unsigned long flags; \
290 local_irq_save(flags); \
291 _do_write_unlock(lock); \
292 local_irq_restore(flags); \
293} while(0)
294
295#define _raw_write_trylock(lock) \
296({ unsigned long flags; \
297 int val; \
298 local_irq_save(flags); \
299 val = _do_write_trylock(lock, "write_trylock"); \
300 local_irq_restore(flags); \
301 val; \
302})
303
304#endif /* CONFIG_DEBUG_SPINLOCK */
305
306#define _raw_read_trylock(lock) generic_raw_read_trylock(lock)
307
308#endif /* !(__ASSEMBLY__) */
309
310#endif /* !(__SPARC64_SPINLOCK_H) */
diff --git a/include/asm-sparc64/spitfire.h b/include/asm-sparc64/spitfire.h
new file mode 100644
index 000000000000..ad78ce64d69e
--- /dev/null
+++ b/include/asm-sparc64/spitfire.h
@@ -0,0 +1,461 @@
1/* $Id: spitfire.h,v 1.18 2001/11/29 16:42:10 kanoj Exp $
2 * spitfire.h: SpitFire/BlackBird/Cheetah inline MMU operations.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_SPITFIRE_H
8#define _SPARC64_SPITFIRE_H
9
10#include <asm/asi.h>
11
12/* The following register addresses are accessible via ASI_DMMU
13 * and ASI_IMMU, that is there is a distinct and unique copy of
14 * each these registers for each TLB.
15 */
16#define TSB_TAG_TARGET 0x0000000000000000 /* All chips */
17#define TLB_SFSR 0x0000000000000018 /* All chips */
18#define TSB_REG 0x0000000000000028 /* All chips */
19#define TLB_TAG_ACCESS 0x0000000000000030 /* All chips */
20#define VIRT_WATCHPOINT 0x0000000000000038 /* All chips */
21#define PHYS_WATCHPOINT 0x0000000000000040 /* All chips */
22#define TSB_EXTENSION_P 0x0000000000000048 /* Ultra-III and later */
23#define TSB_EXTENSION_S 0x0000000000000050 /* Ultra-III and later, D-TLB only */
24#define TSB_EXTENSION_N 0x0000000000000058 /* Ultra-III and later */
25#define TLB_TAG_ACCESS_EXT 0x0000000000000060 /* Ultra-III+ and later */
26
27/* These registers only exist as one entity, and are accessed
28 * via ASI_DMMU only.
29 */
30#define PRIMARY_CONTEXT 0x0000000000000008
31#define SECONDARY_CONTEXT 0x0000000000000010
32#define DMMU_SFAR 0x0000000000000020
33#define VIRT_WATCHPOINT 0x0000000000000038
34#define PHYS_WATCHPOINT 0x0000000000000040
35
36#define SPITFIRE_HIGHEST_LOCKED_TLBENT (64 - 1)
37#define CHEETAH_HIGHEST_LOCKED_TLBENT (16 - 1)
38
39#define L1DCACHE_SIZE 0x4000
40
41#ifndef __ASSEMBLY__
42
43enum ultra_tlb_layout {
44 spitfire = 0,
45 cheetah = 1,
46 cheetah_plus = 2,
47};
48
49extern enum ultra_tlb_layout tlb_type;
50
51#define sparc64_highest_locked_tlbent() \
52 (tlb_type == spitfire ? \
53 SPITFIRE_HIGHEST_LOCKED_TLBENT : \
54 CHEETAH_HIGHEST_LOCKED_TLBENT)
55
56static __inline__ unsigned long spitfire_get_isfsr(void)
57{
58 unsigned long ret;
59
60 __asm__ __volatile__("ldxa [%1] %2, %0"
61 : "=r" (ret)
62 : "r" (TLB_SFSR), "i" (ASI_IMMU));
63 return ret;
64}
65
66static __inline__ unsigned long spitfire_get_dsfsr(void)
67{
68 unsigned long ret;
69
70 __asm__ __volatile__("ldxa [%1] %2, %0"
71 : "=r" (ret)
72 : "r" (TLB_SFSR), "i" (ASI_DMMU));
73 return ret;
74}
75
76static __inline__ unsigned long spitfire_get_sfar(void)
77{
78 unsigned long ret;
79
80 __asm__ __volatile__("ldxa [%1] %2, %0"
81 : "=r" (ret)
82 : "r" (DMMU_SFAR), "i" (ASI_DMMU));
83 return ret;
84}
85
86static __inline__ void spitfire_put_isfsr(unsigned long sfsr)
87{
88 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
89 "membar #Sync"
90 : /* no outputs */
91 : "r" (sfsr), "r" (TLB_SFSR), "i" (ASI_IMMU));
92}
93
94static __inline__ void spitfire_put_dsfsr(unsigned long sfsr)
95{
96 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
97 "membar #Sync"
98 : /* no outputs */
99 : "r" (sfsr), "r" (TLB_SFSR), "i" (ASI_DMMU));
100}
101
102/* The data cache is write through, so this just invalidates the
103 * specified line.
104 */
105static __inline__ void spitfire_put_dcache_tag(unsigned long addr, unsigned long tag)
106{
107 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
108 "membar #Sync"
109 : /* No outputs */
110 : "r" (tag), "r" (addr), "i" (ASI_DCACHE_TAG));
111 __asm__ __volatile__ ("membar #Sync" : : : "memory");
112}
113
114/* The instruction cache lines are flushed with this, but note that
115 * this does not flush the pipeline. It is possible for a line to
116 * get flushed but stale instructions to still be in the pipeline,
117 * a flush instruction (to any address) is sufficient to handle
118 * this issue after the line is invalidated.
119 */
120static __inline__ void spitfire_put_icache_tag(unsigned long addr, unsigned long tag)
121{
122 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
123 "membar #Sync"
124 : /* No outputs */
125 : "r" (tag), "r" (addr), "i" (ASI_IC_TAG));
126}
127
128static __inline__ unsigned long spitfire_get_dtlb_data(int entry)
129{
130 unsigned long data;
131
132 __asm__ __volatile__("ldxa [%1] %2, %0"
133 : "=r" (data)
134 : "r" (entry << 3), "i" (ASI_DTLB_DATA_ACCESS));
135
136 /* Clear TTE diag bits. */
137 data &= ~0x0003fe0000000000UL;
138
139 return data;
140}
141
142static __inline__ unsigned long spitfire_get_dtlb_tag(int entry)
143{
144 unsigned long tag;
145
146 __asm__ __volatile__("ldxa [%1] %2, %0"
147 : "=r" (tag)
148 : "r" (entry << 3), "i" (ASI_DTLB_TAG_READ));
149 return tag;
150}
151
152static __inline__ void spitfire_put_dtlb_data(int entry, unsigned long data)
153{
154 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
155 "membar #Sync"
156 : /* No outputs */
157 : "r" (data), "r" (entry << 3),
158 "i" (ASI_DTLB_DATA_ACCESS));
159}
160
161static __inline__ unsigned long spitfire_get_itlb_data(int entry)
162{
163 unsigned long data;
164
165 __asm__ __volatile__("ldxa [%1] %2, %0"
166 : "=r" (data)
167 : "r" (entry << 3), "i" (ASI_ITLB_DATA_ACCESS));
168
169 /* Clear TTE diag bits. */
170 data &= ~0x0003fe0000000000UL;
171
172 return data;
173}
174
175static __inline__ unsigned long spitfire_get_itlb_tag(int entry)
176{
177 unsigned long tag;
178
179 __asm__ __volatile__("ldxa [%1] %2, %0"
180 : "=r" (tag)
181 : "r" (entry << 3), "i" (ASI_ITLB_TAG_READ));
182 return tag;
183}
184
185static __inline__ void spitfire_put_itlb_data(int entry, unsigned long data)
186{
187 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
188 "membar #Sync"
189 : /* No outputs */
190 : "r" (data), "r" (entry << 3),
191 "i" (ASI_ITLB_DATA_ACCESS));
192}
193
194/* Spitfire hardware assisted TLB flushes. */
195
196/* Context level flushes. */
197static __inline__ void spitfire_flush_dtlb_primary_context(void)
198{
199 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
200 "membar #Sync"
201 : /* No outputs */
202 : "r" (0x40), "i" (ASI_DMMU_DEMAP));
203}
204
205static __inline__ void spitfire_flush_itlb_primary_context(void)
206{
207 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
208 "membar #Sync"
209 : /* No outputs */
210 : "r" (0x40), "i" (ASI_IMMU_DEMAP));
211}
212
213static __inline__ void spitfire_flush_dtlb_secondary_context(void)
214{
215 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
216 "membar #Sync"
217 : /* No outputs */
218 : "r" (0x50), "i" (ASI_DMMU_DEMAP));
219}
220
221static __inline__ void spitfire_flush_itlb_secondary_context(void)
222{
223 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
224 "membar #Sync"
225 : /* No outputs */
226 : "r" (0x50), "i" (ASI_IMMU_DEMAP));
227}
228
229static __inline__ void spitfire_flush_dtlb_nucleus_context(void)
230{
231 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
232 "membar #Sync"
233 : /* No outputs */
234 : "r" (0x60), "i" (ASI_DMMU_DEMAP));
235}
236
237static __inline__ void spitfire_flush_itlb_nucleus_context(void)
238{
239 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
240 "membar #Sync"
241 : /* No outputs */
242 : "r" (0x60), "i" (ASI_IMMU_DEMAP));
243}
244
245/* Page level flushes. */
246static __inline__ void spitfire_flush_dtlb_primary_page(unsigned long page)
247{
248 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
249 "membar #Sync"
250 : /* No outputs */
251 : "r" (page), "i" (ASI_DMMU_DEMAP));
252}
253
254static __inline__ void spitfire_flush_itlb_primary_page(unsigned long page)
255{
256 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
257 "membar #Sync"
258 : /* No outputs */
259 : "r" (page), "i" (ASI_IMMU_DEMAP));
260}
261
262static __inline__ void spitfire_flush_dtlb_secondary_page(unsigned long page)
263{
264 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
265 "membar #Sync"
266 : /* No outputs */
267 : "r" (page | 0x10), "i" (ASI_DMMU_DEMAP));
268}
269
270static __inline__ void spitfire_flush_itlb_secondary_page(unsigned long page)
271{
272 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
273 "membar #Sync"
274 : /* No outputs */
275 : "r" (page | 0x10), "i" (ASI_IMMU_DEMAP));
276}
277
278static __inline__ void spitfire_flush_dtlb_nucleus_page(unsigned long page)
279{
280 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
281 "membar #Sync"
282 : /* No outputs */
283 : "r" (page | 0x20), "i" (ASI_DMMU_DEMAP));
284}
285
286static __inline__ void spitfire_flush_itlb_nucleus_page(unsigned long page)
287{
288 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
289 "membar #Sync"
290 : /* No outputs */
291 : "r" (page | 0x20), "i" (ASI_IMMU_DEMAP));
292}
293
294/* Cheetah has "all non-locked" tlb flushes. */
295static __inline__ void cheetah_flush_dtlb_all(void)
296{
297 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
298 "membar #Sync"
299 : /* No outputs */
300 : "r" (0x80), "i" (ASI_DMMU_DEMAP));
301}
302
303static __inline__ void cheetah_flush_itlb_all(void)
304{
305 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
306 "membar #Sync"
307 : /* No outputs */
308 : "r" (0x80), "i" (ASI_IMMU_DEMAP));
309}
310
311/* Cheetah has a 4-tlb layout so direct access is a bit different.
312 * The first two TLBs are fully assosciative, hold 16 entries, and are
313 * used only for locked and >8K sized translations. One exists for
314 * data accesses and one for instruction accesses.
315 *
316 * The third TLB is for data accesses to 8K non-locked translations, is
317 * 2 way assosciative, and holds 512 entries. The fourth TLB is for
318 * instruction accesses to 8K non-locked translations, is 2 way
319 * assosciative, and holds 128 entries.
320 *
321 * Cheetah has some bug where bogus data can be returned from
322 * ASI_{D,I}TLB_DATA_ACCESS loads, doing the load twice fixes
323 * the problem for me. -DaveM
324 */
325static __inline__ unsigned long cheetah_get_ldtlb_data(int entry)
326{
327 unsigned long data;
328
329 __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t"
330 "ldxa [%1] %2, %0"
331 : "=r" (data)
332 : "r" ((0 << 16) | (entry << 3)),
333 "i" (ASI_DTLB_DATA_ACCESS));
334
335 return data;
336}
337
338static __inline__ unsigned long cheetah_get_litlb_data(int entry)
339{
340 unsigned long data;
341
342 __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t"
343 "ldxa [%1] %2, %0"
344 : "=r" (data)
345 : "r" ((0 << 16) | (entry << 3)),
346 "i" (ASI_ITLB_DATA_ACCESS));
347
348 return data;
349}
350
351static __inline__ unsigned long cheetah_get_ldtlb_tag(int entry)
352{
353 unsigned long tag;
354
355 __asm__ __volatile__("ldxa [%1] %2, %0"
356 : "=r" (tag)
357 : "r" ((0 << 16) | (entry << 3)),
358 "i" (ASI_DTLB_TAG_READ));
359
360 return tag;
361}
362
363static __inline__ unsigned long cheetah_get_litlb_tag(int entry)
364{
365 unsigned long tag;
366
367 __asm__ __volatile__("ldxa [%1] %2, %0"
368 : "=r" (tag)
369 : "r" ((0 << 16) | (entry << 3)),
370 "i" (ASI_ITLB_TAG_READ));
371
372 return tag;
373}
374
375static __inline__ void cheetah_put_ldtlb_data(int entry, unsigned long data)
376{
377 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
378 "membar #Sync"
379 : /* No outputs */
380 : "r" (data),
381 "r" ((0 << 16) | (entry << 3)),
382 "i" (ASI_DTLB_DATA_ACCESS));
383}
384
385static __inline__ void cheetah_put_litlb_data(int entry, unsigned long data)
386{
387 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
388 "membar #Sync"
389 : /* No outputs */
390 : "r" (data),
391 "r" ((0 << 16) | (entry << 3)),
392 "i" (ASI_ITLB_DATA_ACCESS));
393}
394
395static __inline__ unsigned long cheetah_get_dtlb_data(int entry, int tlb)
396{
397 unsigned long data;
398
399 __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t"
400 "ldxa [%1] %2, %0"
401 : "=r" (data)
402 : "r" ((tlb << 16) | (entry << 3)), "i" (ASI_DTLB_DATA_ACCESS));
403
404 return data;
405}
406
407static __inline__ unsigned long cheetah_get_dtlb_tag(int entry, int tlb)
408{
409 unsigned long tag;
410
411 __asm__ __volatile__("ldxa [%1] %2, %0"
412 : "=r" (tag)
413 : "r" ((tlb << 16) | (entry << 3)), "i" (ASI_DTLB_TAG_READ));
414 return tag;
415}
416
417static __inline__ void cheetah_put_dtlb_data(int entry, unsigned long data, int tlb)
418{
419 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
420 "membar #Sync"
421 : /* No outputs */
422 : "r" (data),
423 "r" ((tlb << 16) | (entry << 3)),
424 "i" (ASI_DTLB_DATA_ACCESS));
425}
426
427static __inline__ unsigned long cheetah_get_itlb_data(int entry)
428{
429 unsigned long data;
430
431 __asm__ __volatile__("ldxa [%1] %2, %%g0\n\t"
432 "ldxa [%1] %2, %0"
433 : "=r" (data)
434 : "r" ((2 << 16) | (entry << 3)),
435 "i" (ASI_ITLB_DATA_ACCESS));
436
437 return data;
438}
439
440static __inline__ unsigned long cheetah_get_itlb_tag(int entry)
441{
442 unsigned long tag;
443
444 __asm__ __volatile__("ldxa [%1] %2, %0"
445 : "=r" (tag)
446 : "r" ((2 << 16) | (entry << 3)), "i" (ASI_ITLB_TAG_READ));
447 return tag;
448}
449
450static __inline__ void cheetah_put_itlb_data(int entry, unsigned long data)
451{
452 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
453 "membar #Sync"
454 : /* No outputs */
455 : "r" (data), "r" ((2 << 16) | (entry << 3)),
456 "i" (ASI_ITLB_DATA_ACCESS));
457}
458
459#endif /* !(__ASSEMBLY__) */
460
461#endif /* !(_SPARC64_SPITFIRE_H) */
diff --git a/include/asm-sparc64/starfire.h b/include/asm-sparc64/starfire.h
new file mode 100644
index 000000000000..b606cb2b32a8
--- /dev/null
+++ b/include/asm-sparc64/starfire.h
@@ -0,0 +1,21 @@
1/* $Id: starfire.h,v 1.2 2001/07/04 00:18:18 davem Exp $
2 * starfire.h: Group all starfire specific code together.
3 *
4 * Copyright (C) 2000 Anton Blanchard (anton@samba.org)
5 */
6
7#ifndef _SPARC64_STARFIRE_H
8#define _SPARC64_STARFIRE_H
9
10#ifndef __ASSEMBLY__
11
12extern int this_is_starfire;
13
14extern void check_if_starfire(void);
15extern void starfire_cpu_setup(void);
16extern int starfire_hard_smp_processor_id(void);
17extern void *starfire_hookup(int);
18extern unsigned int starfire_translate(unsigned long imap, unsigned int upaid);
19
20#endif
21#endif
diff --git a/include/asm-sparc64/stat.h b/include/asm-sparc64/stat.h
new file mode 100644
index 000000000000..48e06618a5a4
--- /dev/null
+++ b/include/asm-sparc64/stat.h
@@ -0,0 +1,63 @@
1/* $Id: stat.h,v 1.7 2000/08/04 05:35:55 davem Exp $ */
2#ifndef _SPARC64_STAT_H
3#define _SPARC64_STAT_H
4
5#include <linux/types.h>
6
7struct stat {
8 unsigned st_dev;
9 ino_t st_ino;
10 mode_t st_mode;
11 short st_nlink;
12 uid_t st_uid;
13 gid_t st_gid;
14 unsigned st_rdev;
15 off_t st_size;
16 time_t st_atime;
17 time_t st_mtime;
18 time_t st_ctime;
19 off_t st_blksize;
20 off_t st_blocks;
21 unsigned long __unused4[2];
22};
23
24#ifdef __KERNEL__
25/* This is sparc32 stat64 structure. */
26
27struct stat64 {
28 unsigned long long st_dev;
29
30 unsigned long long st_ino;
31
32 unsigned int st_mode;
33 unsigned int st_nlink;
34
35 unsigned int st_uid;
36 unsigned int st_gid;
37
38 unsigned long long st_rdev;
39
40 unsigned char __pad3[8];
41
42 long long st_size;
43 unsigned int st_blksize;
44
45 unsigned char __pad4[8];
46 unsigned int st_blocks;
47
48 unsigned int st_atime;
49 unsigned int st_atime_nsec;
50
51 unsigned int st_mtime;
52 unsigned int st_mtime_nsec;
53
54 unsigned int st_ctime;
55 unsigned int st_ctime_nsec;
56
57 unsigned int __unused4;
58 unsigned int __unused5;
59};
60
61#endif
62
63#endif
diff --git a/include/asm-sparc64/statfs.h b/include/asm-sparc64/statfs.h
new file mode 100644
index 000000000000..185b6c481b24
--- /dev/null
+++ b/include/asm-sparc64/statfs.h
@@ -0,0 +1,55 @@
1/* $Id: statfs.h,v 1.2 1997/04/14 17:05:22 jj Exp $ */
2#ifndef _SPARC64_STATFS_H
3#define _SPARC64_STATFS_H
4
5#ifndef __KERNEL_STRICT_NAMES
6
7#include <linux/types.h>
8
9typedef __kernel_fsid_t fsid_t;
10
11#endif
12
13struct statfs {
14 long f_type;
15 long f_bsize;
16 long f_blocks;
17 long f_bfree;
18 long f_bavail;
19 long f_files;
20 long f_ffree;
21 __kernel_fsid_t f_fsid;
22 long f_namelen;
23 long f_frsize;
24 long f_spare[5];
25};
26
27struct statfs64 {
28 long f_type;
29 long f_bsize;
30 long f_blocks;
31 long f_bfree;
32 long f_bavail;
33 long f_files;
34 long f_ffree;
35 __kernel_fsid_t f_fsid;
36 long f_namelen;
37 long f_frsize;
38 long f_spare[5];
39};
40
41struct compat_statfs64 {
42 __u32 f_type;
43 __u32 f_bsize;
44 __u64 f_blocks;
45 __u64 f_bfree;
46 __u64 f_bavail;
47 __u64 f_files;
48 __u64 f_ffree;
49 __kernel_fsid_t f_fsid;
50 __u32 f_namelen;
51 __u32 f_frsize;
52 __u32 f_spare[5];
53};
54
55#endif
diff --git a/include/asm-sparc64/string.h b/include/asm-sparc64/string.h
new file mode 100644
index 000000000000..c7d88622cb27
--- /dev/null
+++ b/include/asm-sparc64/string.h
@@ -0,0 +1,83 @@
1/* $Id: string.h,v 1.20 2001/09/27 04:36:24 kanoj Exp $
2 * string.h: External definitions for optimized assembly string
3 * routines for the Linux Kernel.
4 *
5 * Copyright (C) 1995,1996 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996,1997,1999 Jakub Jelinek (jakub@redhat.com)
7 */
8
9#ifndef __SPARC64_STRING_H__
10#define __SPARC64_STRING_H__
11
12/* Really, userland/ksyms should not see any of this stuff. */
13
14#ifdef __KERNEL__
15
16#include <asm/asi.h>
17
18extern void *__memset(void *,int,__kernel_size_t);
19
20#ifndef EXPORT_SYMTAB_STROPS
21
22/* First the mem*() things. */
23#define __HAVE_ARCH_MEMMOVE
24extern void *memmove(void *, const void *, __kernel_size_t);
25
26#define __HAVE_ARCH_MEMCPY
27extern void *memcpy(void *, const void *, __kernel_size_t);
28
29#define __HAVE_ARCH_MEMSET
30extern void *__builtin_memset(void *,int,__kernel_size_t);
31
32static inline void *__constant_memset(void *s, int c, __kernel_size_t count)
33{
34 extern __kernel_size_t __bzero(void *, __kernel_size_t);
35
36 if (!c) {
37 __bzero(s, count);
38 return s;
39 } else
40 return __memset(s, c, count);
41}
42
43#undef memset
44#define memset(s, c, count) \
45((__builtin_constant_p(count) && (count) <= 32) ? \
46 __builtin_memset((s), (c), (count)) : \
47 (__builtin_constant_p(c) ? \
48 __constant_memset((s), (c), (count)) : \
49 __memset((s), (c), (count))))
50
51#define __HAVE_ARCH_MEMSCAN
52
53#undef memscan
54#define memscan(__arg0, __char, __arg2) \
55({ \
56 extern void *__memscan_zero(void *, size_t); \
57 extern void *__memscan_generic(void *, int, size_t); \
58 void *__retval, *__addr = (__arg0); \
59 size_t __size = (__arg2); \
60 \
61 if(__builtin_constant_p(__char) && !(__char)) \
62 __retval = __memscan_zero(__addr, __size); \
63 else \
64 __retval = __memscan_generic(__addr, (__char), __size); \
65 \
66 __retval; \
67})
68
69#define __HAVE_ARCH_MEMCMP
70extern int memcmp(const void *,const void *,__kernel_size_t);
71
72/* Now the str*() stuff... */
73#define __HAVE_ARCH_STRLEN
74extern __kernel_size_t strlen(const char *);
75
76#define __HAVE_ARCH_STRNCMP
77extern int strncmp(const char *, const char *, __kernel_size_t);
78
79#endif /* !EXPORT_SYMTAB_STROPS */
80
81#endif /* __KERNEL__ */
82
83#endif /* !(__SPARC64_STRING_H__) */
diff --git a/include/asm-sparc64/sunbpp.h b/include/asm-sparc64/sunbpp.h
new file mode 100644
index 000000000000..b441cc9c426c
--- /dev/null
+++ b/include/asm-sparc64/sunbpp.h
@@ -0,0 +1,80 @@
1/* $Id: sunbpp.h,v 1.1 1999/08/13 06:21:44 shadow Exp $
2 * include/asm-sparc64/sunbpp.h
3 */
4
5#ifndef _ASM_SPARC64_SUNBPP_H
6#define _ASM_SPARC64_SUNBPP_H
7
8struct bpp_regs {
9 /* DMA registers */
10 __volatile__ __u32 p_csr; /* DMA Control/Status Register */
11 __volatile__ __u32 p_addr; /* Address Register */
12 __volatile__ __u32 p_bcnt; /* Byte Count Register */
13 __volatile__ __u32 p_tst_csr; /* Test Control/Status (DMA2 only) */
14 /* Parallel Port registers */
15 __volatile__ __u16 p_hcr; /* Hardware Configuration Register */
16 __volatile__ __u16 p_ocr; /* Operation Configuration Register */
17 __volatile__ __u8 p_dr; /* Parallel Data Register */
18 __volatile__ __u8 p_tcr; /* Transfer Control Register */
19 __volatile__ __u8 p_or; /* Output Register */
20 __volatile__ __u8 p_ir; /* Input Register */
21 __volatile__ __u16 p_icr; /* Interrupt Control Register */
22};
23
24/* P_HCR. Time is in increments of SBus clock. */
25#define P_HCR_TEST 0x8000 /* Allows buried counters to be read */
26#define P_HCR_DSW 0x7f00 /* Data strobe width (in ticks) */
27#define P_HCR_DDS 0x007f /* Data setup before strobe (in ticks) */
28
29/* P_OCR. */
30#define P_OCR_MEM_CLR 0x8000
31#define P_OCR_DATA_SRC 0x4000 /* ) */
32#define P_OCR_DS_DSEL 0x2000 /* ) Bidirectional */
33#define P_OCR_BUSY_DSEL 0x1000 /* ) selects */
34#define P_OCR_ACK_DSEL 0x0800 /* ) */
35#define P_OCR_EN_DIAG 0x0400
36#define P_OCR_BUSY_OP 0x0200 /* Busy operation */
37#define P_OCR_ACK_OP 0x0100 /* Ack operation */
38#define P_OCR_SRST 0x0080 /* Reset state machines. Not selfcleaning. */
39#define P_OCR_IDLE 0x0008 /* PP data transfer state machine is idle */
40#define P_OCR_V_ILCK 0x0002 /* Versatec faded. Zebra only. */
41#define P_OCR_EN_VER 0x0001 /* Enable Versatec (0 - enable). Zebra only. */
42
43/* P_TCR */
44#define P_TCR_DIR 0x08
45#define P_TCR_BUSY 0x04
46#define P_TCR_ACK 0x02
47#define P_TCR_DS 0x01 /* Strobe */
48
49/* P_OR */
50#define P_OR_V3 0x20 /* ) */
51#define P_OR_V2 0x10 /* ) on Zebra only */
52#define P_OR_V1 0x08 /* ) */
53#define P_OR_INIT 0x04
54#define P_OR_AFXN 0x02 /* Auto Feed */
55#define P_OR_SLCT_IN 0x01
56
57/* P_IR */
58#define P_IR_PE 0x04
59#define P_IR_SLCT 0x02
60#define P_IR_ERR 0x01
61
62/* P_ICR */
63#define P_DS_IRQ 0x8000 /* RW1 */
64#define P_ACK_IRQ 0x4000 /* RW1 */
65#define P_BUSY_IRQ 0x2000 /* RW1 */
66#define P_PE_IRQ 0x1000 /* RW1 */
67#define P_SLCT_IRQ 0x0800 /* RW1 */
68#define P_ERR_IRQ 0x0400 /* RW1 */
69#define P_DS_IRQ_EN 0x0200 /* RW Always on rising edge */
70#define P_ACK_IRQ_EN 0x0100 /* RW Always on rising edge */
71#define P_BUSY_IRP 0x0080 /* RW 1= rising edge */
72#define P_BUSY_IRQ_EN 0x0040 /* RW */
73#define P_PE_IRP 0x0020 /* RW 1= rising edge */
74#define P_PE_IRQ_EN 0x0010 /* RW */
75#define P_SLCT_IRP 0x0008 /* RW 1= rising edge */
76#define P_SLCT_IRQ_EN 0x0004 /* RW */
77#define P_ERR_IRP 0x0002 /* RW1 1= rising edge */
78#define P_ERR_IRQ_EN 0x0001 /* RW */
79
80#endif /* !(_ASM_SPARC64_SUNBPP_H) */
diff --git a/include/asm-sparc64/svr4.h b/include/asm-sparc64/svr4.h
new file mode 100644
index 000000000000..c96d5f116e1c
--- /dev/null
+++ b/include/asm-sparc64/svr4.h
@@ -0,0 +1,120 @@
1/* Solaris/SPARC constants and definitions --
2 * (C) 1996 Miguel de Icaza
3 *
4 * This file is not meant to be included by user level applications
5 * but the solaris syscall emulator
6 */
7
8#ifndef _SPARC64_SVR4_H
9#define _SPARC64_SVR4_H
10
11/* Signals as used by svr4 */
12typedef struct { /* signal set type */
13 uint sigbits[4];
14} svr4_sigset_t;
15
16/* Values for siginfo.code */
17#define SVR4_SINOINFO 32767
18/* Siginfo, sucker expects bunch of information on those parameters */
19typedef union {
20 char total_size [128];
21 struct {
22 int signo;
23 int code;
24 int error;
25 union {
26 } data;
27 } siginfo;
28} svr4_siginfo_t;
29
30/* Context definition */
31
32/* Location of the user stored registers into a greg_t */
33enum {
34 SVR4_PSR, SVR4_PC, SVR4_NPC, SVR4_Y,
35 SVR4_G1, SVR4_G2, SVR4_G3, SVR4_G4,
36 SVR4_G5, SVR4_G6, SVR4_G7, SVR4_O0,
37 SVR4_O1, SVR4_O2, SVR4_O3, SVR4_O4,
38 SVR4_O5, SVR4_O6, SVR4_O7
39};
40
41/* sizeof (regs) / sizeof (greg_t), defined in the ABI */
42#define SVR4_NREGS 19
43#define SVR4_MAXWIN 31
44
45typedef struct {
46 u32 rwin_lo[8];
47 u32 rwin_in[8];
48} svr4_rwindow_t;
49
50typedef struct {
51 int count;
52 u32 winptr [SVR4_MAXWIN]; /* pointer to the windows */
53
54 svr4_rwindow_t win[SVR4_MAXWIN]; /* the windows */
55} svr4_gwindows_t;
56
57typedef int svr4_gregset_t[SVR4_NREGS];
58
59typedef struct {
60 u64 fpu_regs[32];
61 u32 fp_q;
62 u32 fp_fsr;
63 u_char fp_nqel;
64 u_char fp_nqsize;
65 u_char inuse; /* if fpu is in use */
66} svr4_fregset_t;
67
68typedef struct {
69 u32 id; /* if this holds "xrs" string => ptr is valid */
70 u32 ptr;
71} svr4_xrs_t;
72
73/* Machine dependent context */
74typedef struct {
75 svr4_gregset_t greg; /* registers 0..19 (see top) */
76 u32 gwin; /* may point to register windows */
77 svr4_fregset_t freg; /* floating point registers */
78 svr4_xrs_t xrs; /* mhm? */
79 int pad[19];
80} svr4_mcontext_t;
81
82/* flags for stack_t.flags */
83enum svr4_stack_flags {
84 SVR4_SS_ONSTACK,
85 SVR4_SS_DISABLE,
86};
87
88/* signal stack execution place, unsupported */
89typedef struct svr4_stack_t {
90 u32 sp;
91 int size;
92 int flags;
93} svr4_stack_t;
94
95/* Context used by getcontext and setcontext */
96typedef struct svr4_ucontext_t {
97 u32 flags; /* context flags, indicate what is loaded */
98 u32 link;
99 svr4_sigset_t sigmask;
100 svr4_stack_t stack;
101 svr4_mcontext_t mcontext;
102 int pad[23];
103} svr4_ucontext_t;
104
105/* windows hold the windows as they were at signal time,
106 * ucontext->mcontext holds a pointer to them.
107 * addresses for uc and si are passed as parameters to svr4 signal
108 * handler
109 */
110
111/* This is the signal frame that is passed to the signal handler */
112typedef struct {
113 svr4_gwindows_t gw; /* windows */
114 svr4_ucontext_t uc; /* machine context */
115 svr4_siginfo_t si; /* siginfo */
116} svr4_signal_frame_t;
117
118#define SVR4_SF_ALIGNED (((sizeof (svr4_signal_frame_t) + 7) & (~7)))
119
120#endif /* include control */
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h
new file mode 100644
index 000000000000..fd12ca386f48
--- /dev/null
+++ b/include/asm-sparc64/system.h
@@ -0,0 +1,350 @@
1/* $Id: system.h,v 1.69 2002/02/09 19:49:31 davem Exp $ */
2#ifndef __SPARC64_SYSTEM_H
3#define __SPARC64_SYSTEM_H
4
5#include <linux/config.h>
6#include <asm/ptrace.h>
7#include <asm/processor.h>
8#include <asm/visasm.h>
9
10#ifndef __ASSEMBLY__
11/*
12 * Sparc (general) CPU types
13 */
14enum sparc_cpu {
15 sun4 = 0x00,
16 sun4c = 0x01,
17 sun4m = 0x02,
18 sun4d = 0x03,
19 sun4e = 0x04,
20 sun4u = 0x05, /* V8 ploos ploos */
21 sun_unknown = 0x06,
22 ap1000 = 0x07, /* almost a sun4m */
23};
24
25#define sparc_cpu_model sun4u
26
27/* This cannot ever be a sun4c nor sun4 :) That's just history. */
28#define ARCH_SUN4C_SUN4 0
29#define ARCH_SUN4 0
30
31#endif
32
33#define setipl(__new_ipl) \
34 __asm__ __volatile__("wrpr %0, %%pil" : : "r" (__new_ipl) : "memory")
35
36#define local_irq_disable() \
37 __asm__ __volatile__("wrpr 15, %%pil" : : : "memory")
38
39#define local_irq_enable() \
40 __asm__ __volatile__("wrpr 0, %%pil" : : : "memory")
41
42#define getipl() \
43({ unsigned long retval; __asm__ __volatile__("rdpr %%pil, %0" : "=r" (retval)); retval; })
44
45#define swap_pil(__new_pil) \
46({ unsigned long retval; \
47 __asm__ __volatile__("rdpr %%pil, %0\n\t" \
48 "wrpr %1, %%pil" \
49 : "=&r" (retval) \
50 : "r" (__new_pil) \
51 : "memory"); \
52 retval; \
53})
54
55#define read_pil_and_cli() \
56({ unsigned long retval; \
57 __asm__ __volatile__("rdpr %%pil, %0\n\t" \
58 "wrpr 15, %%pil" \
59 : "=r" (retval) \
60 : : "memory"); \
61 retval; \
62})
63
64#define local_save_flags(flags) ((flags) = getipl())
65#define local_irq_save(flags) ((flags) = read_pil_and_cli())
66#define local_irq_restore(flags) setipl((flags))
67
68/* On sparc64 IRQ flags are the PIL register. A value of zero
69 * means all interrupt levels are enabled, any other value means
70 * only IRQ levels greater than that value will be received.
71 * Consequently this means that the lowest IRQ level is one.
72 */
73#define irqs_disabled() \
74({ unsigned long flags; \
75 local_save_flags(flags);\
76 (flags > 0); \
77})
78
79#define nop() __asm__ __volatile__ ("nop")
80
81#define membar(type) __asm__ __volatile__ ("membar " type : : : "memory")
82#define mb() \
83 membar("#LoadLoad | #LoadStore | #StoreStore | #StoreLoad")
84#define rmb() membar("#LoadLoad")
85#define wmb() membar("#StoreStore")
86#define read_barrier_depends() do { } while(0)
87#define set_mb(__var, __value) \
88 do { __var = __value; membar("#StoreLoad | #StoreStore"); } while(0)
89#define set_wmb(__var, __value) \
90 do { __var = __value; membar("#StoreStore"); } while(0)
91
92#ifdef CONFIG_SMP
93#define smp_mb() mb()
94#define smp_rmb() rmb()
95#define smp_wmb() wmb()
96#define smp_read_barrier_depends() read_barrier_depends()
97#else
98#define smp_mb() __asm__ __volatile__("":::"memory")
99#define smp_rmb() __asm__ __volatile__("":::"memory")
100#define smp_wmb() __asm__ __volatile__("":::"memory")
101#define smp_read_barrier_depends() do { } while(0)
102#endif
103
104#define flushi(addr) __asm__ __volatile__ ("flush %0" : : "r" (addr) : "memory")
105
106#define flushw_all() __asm__ __volatile__("flushw")
107
108/* Performance counter register access. */
109#define read_pcr(__p) __asm__ __volatile__("rd %%pcr, %0" : "=r" (__p))
110#define write_pcr(__p) __asm__ __volatile__("wr %0, 0x0, %%pcr" : : "r" (__p))
111#define read_pic(__p) __asm__ __volatile__("rd %%pic, %0" : "=r" (__p))
112
113/* Blackbird errata workaround. See commentary in
114 * arch/sparc64/kernel/smp.c:smp_percpu_timer_interrupt()
115 * for more information.
116 */
117#define reset_pic() \
118 __asm__ __volatile__("ba,pt %xcc, 99f\n\t" \
119 ".align 64\n" \
120 "99:wr %g0, 0x0, %pic\n\t" \
121 "rd %pic, %g0")
122
123#ifndef __ASSEMBLY__
124
125extern void sun_do_break(void);
126extern int serial_console;
127extern int stop_a_enabled;
128
129static __inline__ int con_is_present(void)
130{
131 return serial_console ? 0 : 1;
132}
133
134extern void synchronize_user_stack(void);
135
136extern void __flushw_user(void);
137#define flushw_user() __flushw_user()
138
139#define flush_user_windows flushw_user
140#define flush_register_windows flushw_all
141
142#define prepare_arch_switch(rq, next) \
143do { spin_lock(&(next)->switch_lock); \
144 spin_unlock(&(rq)->lock); \
145 flushw_all(); \
146} while (0)
147
148#define finish_arch_switch(rq, prev) \
149do { spin_unlock_irq(&(prev)->switch_lock); \
150} while (0)
151
152#define task_running(rq, p) \
153 ((rq)->curr == (p) || spin_is_locked(&(p)->switch_lock))
154
155 /* See what happens when you design the chip correctly?
156 *
157 * We tell gcc we clobber all non-fixed-usage registers except
158 * for l0/l1. It will use one for 'next' and the other to hold
159 * the output value of 'last'. 'next' is not referenced again
160 * past the invocation of switch_to in the scheduler, so we need
161 * not preserve it's value. Hairy, but it lets us remove 2 loads
162 * and 2 stores in this critical code path. -DaveM
163 */
164#if __GNUC__ >= 3
165#define EXTRA_CLOBBER ,"%l1"
166#else
167#define EXTRA_CLOBBER
168#endif
169#define switch_to(prev, next, last) \
170do { if (test_thread_flag(TIF_PERFCTR)) { \
171 unsigned long __tmp; \
172 read_pcr(__tmp); \
173 current_thread_info()->pcr_reg = __tmp; \
174 read_pic(__tmp); \
175 current_thread_info()->kernel_cntd0 += (unsigned int)(__tmp);\
176 current_thread_info()->kernel_cntd1 += ((__tmp) >> 32); \
177 } \
178 flush_tlb_pending(); \
179 save_and_clear_fpu(); \
180 /* If you are tempted to conditionalize the following */ \
181 /* so that ASI is only written if it changes, think again. */ \
182 __asm__ __volatile__("wr %%g0, %0, %%asi" \
183 : : "r" (__thread_flag_byte_ptr(next->thread_info)[TI_FLAG_BYTE_CURRENT_DS]));\
184 __asm__ __volatile__( \
185 "mov %%g4, %%g7\n\t" \
186 "wrpr %%g0, 0x95, %%pstate\n\t" \
187 "stx %%i6, [%%sp + 2047 + 0x70]\n\t" \
188 "stx %%i7, [%%sp + 2047 + 0x78]\n\t" \
189 "rdpr %%wstate, %%o5\n\t" \
190 "stx %%o6, [%%g6 + %3]\n\t" \
191 "stb %%o5, [%%g6 + %2]\n\t" \
192 "rdpr %%cwp, %%o5\n\t" \
193 "stb %%o5, [%%g6 + %5]\n\t" \
194 "mov %1, %%g6\n\t" \
195 "ldub [%1 + %5], %%g1\n\t" \
196 "wrpr %%g1, %%cwp\n\t" \
197 "ldx [%%g6 + %3], %%o6\n\t" \
198 "ldub [%%g6 + %2], %%o5\n\t" \
199 "ldx [%%g6 + %4], %%o7\n\t" \
200 "mov %%g6, %%l2\n\t" \
201 "wrpr %%o5, 0x0, %%wstate\n\t" \
202 "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \
203 "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \
204 "wrpr %%g0, 0x94, %%pstate\n\t" \
205 "mov %%l2, %%g6\n\t" \
206 "ldx [%%g6 + %7], %%g4\n\t" \
207 "wrpr %%g0, 0x96, %%pstate\n\t" \
208 "andcc %%o7, %6, %%g0\n\t" \
209 "beq,pt %%icc, 1f\n\t" \
210 " mov %%g7, %0\n\t" \
211 "b,a ret_from_syscall\n\t" \
212 "1:\n\t" \
213 : "=&r" (last) \
214 : "0" (next->thread_info), \
215 "i" (TI_WSTATE), "i" (TI_KSP), "i" (TI_FLAGS), "i" (TI_CWP), \
216 "i" (_TIF_NEWCHILD), "i" (TI_TASK) \
217 : "cc", \
218 "g1", "g2", "g3", "g7", \
219 "l2", "l3", "l4", "l5", "l6", "l7", \
220 "i0", "i1", "i2", "i3", "i4", "i5", \
221 "o0", "o1", "o2", "o3", "o4", "o5", "o7" EXTRA_CLOBBER);\
222 /* If you fuck with this, update ret_from_syscall code too. */ \
223 if (test_thread_flag(TIF_PERFCTR)) { \
224 write_pcr(current_thread_info()->pcr_reg); \
225 reset_pic(); \
226 } \
227} while(0)
228
229static inline unsigned long xchg32(__volatile__ unsigned int *m, unsigned int val)
230{
231 unsigned long tmp1, tmp2;
232
233 __asm__ __volatile__(
234" membar #StoreLoad | #LoadLoad\n"
235" mov %0, %1\n"
236"1: lduw [%4], %2\n"
237" cas [%4], %2, %0\n"
238" cmp %2, %0\n"
239" bne,a,pn %%icc, 1b\n"
240" mov %1, %0\n"
241" membar #StoreLoad | #StoreStore\n"
242 : "=&r" (val), "=&r" (tmp1), "=&r" (tmp2)
243 : "0" (val), "r" (m)
244 : "cc", "memory");
245 return val;
246}
247
248static inline unsigned long xchg64(__volatile__ unsigned long *m, unsigned long val)
249{
250 unsigned long tmp1, tmp2;
251
252 __asm__ __volatile__(
253" membar #StoreLoad | #LoadLoad\n"
254" mov %0, %1\n"
255"1: ldx [%4], %2\n"
256" casx [%4], %2, %0\n"
257" cmp %2, %0\n"
258" bne,a,pn %%xcc, 1b\n"
259" mov %1, %0\n"
260" membar #StoreLoad | #StoreStore\n"
261 : "=&r" (val), "=&r" (tmp1), "=&r" (tmp2)
262 : "0" (val), "r" (m)
263 : "cc", "memory");
264 return val;
265}
266
267#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
268#define tas(ptr) (xchg((ptr),1))
269
270extern void __xchg_called_with_bad_pointer(void);
271
272static __inline__ unsigned long __xchg(unsigned long x, __volatile__ void * ptr,
273 int size)
274{
275 switch (size) {
276 case 4:
277 return xchg32(ptr, x);
278 case 8:
279 return xchg64(ptr, x);
280 };
281 __xchg_called_with_bad_pointer();
282 return x;
283}
284
285extern void die_if_kernel(char *str, struct pt_regs *regs) __attribute__ ((noreturn));
286
287/*
288 * Atomic compare and exchange. Compare OLD with MEM, if identical,
289 * store NEW in MEM. Return the initial value in MEM. Success is
290 * indicated by comparing RETURN with OLD.
291 */
292
293#define __HAVE_ARCH_CMPXCHG 1
294
295static __inline__ unsigned long
296__cmpxchg_u32(volatile int *m, int old, int new)
297{
298 __asm__ __volatile__("membar #StoreLoad | #LoadLoad\n"
299 "cas [%2], %3, %0\n\t"
300 "membar #StoreLoad | #StoreStore"
301 : "=&r" (new)
302 : "0" (new), "r" (m), "r" (old)
303 : "memory");
304
305 return new;
306}
307
308static __inline__ unsigned long
309__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
310{
311 __asm__ __volatile__("membar #StoreLoad | #LoadLoad\n"
312 "casx [%2], %3, %0\n\t"
313 "membar #StoreLoad | #StoreStore"
314 : "=&r" (new)
315 : "0" (new), "r" (m), "r" (old)
316 : "memory");
317
318 return new;
319}
320
321/* This function doesn't exist, so you'll get a linker error
322 if something tries to do an invalid cmpxchg(). */
323extern void __cmpxchg_called_with_bad_pointer(void);
324
325static __inline__ unsigned long
326__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
327{
328 switch (size) {
329 case 4:
330 return __cmpxchg_u32(ptr, old, new);
331 case 8:
332 return __cmpxchg_u64(ptr, old, new);
333 }
334 __cmpxchg_called_with_bad_pointer();
335 return old;
336}
337
338#define cmpxchg(ptr,o,n) \
339 ({ \
340 __typeof__(*(ptr)) _o_ = (o); \
341 __typeof__(*(ptr)) _n_ = (n); \
342 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
343 (unsigned long)_n_, sizeof(*(ptr))); \
344 })
345
346#endif /* !(__ASSEMBLY__) */
347
348#define arch_align_stack(x) (x)
349
350#endif /* !(__SPARC64_SYSTEM_H) */
diff --git a/include/asm-sparc64/termbits.h b/include/asm-sparc64/termbits.h
new file mode 100644
index 000000000000..b07715273ed4
--- /dev/null
+++ b/include/asm-sparc64/termbits.h
@@ -0,0 +1,235 @@
1#ifndef _SPARC64_TERMBITS_H
2#define _SPARC64_TERMBITS_H
3
4#include <linux/posix_types.h>
5
6typedef unsigned char cc_t;
7typedef unsigned int speed_t;
8
9/* XXX is this right for sparc64? it was an unsigned long... XXX */
10typedef unsigned int tcflag_t;
11
12#define NCC 8
13struct termio {
14 unsigned short c_iflag; /* input mode flags */
15 unsigned short c_oflag; /* output mode flags */
16 unsigned short c_cflag; /* control mode flags */
17 unsigned short c_lflag; /* local mode flags */
18 unsigned char c_line; /* line discipline */
19 unsigned char c_cc[NCC]; /* control characters */
20};
21
22#define NCCS 17
23struct termios {
24 tcflag_t c_iflag; /* input mode flags */
25 tcflag_t c_oflag; /* output mode flags */
26 tcflag_t c_cflag; /* control mode flags */
27 tcflag_t c_lflag; /* local mode flags */
28 cc_t c_line; /* line discipline */
29 cc_t c_cc[NCCS]; /* control characters */
30#ifdef __KERNEL__
31#define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t))
32 cc_t _x_cc[2]; /* We need them to hold vmin/vtime */
33#endif
34};
35
36/* c_cc characters */
37#define VINTR 0
38#define VQUIT 1
39#define VERASE 2
40#define VKILL 3
41#define VEOF 4
42#define VEOL 5
43#define VEOL2 6
44#define VSWTC 7
45#define VSTART 8
46#define VSTOP 9
47
48
49
50#define VSUSP 10
51#define VDSUSP 11 /* SunOS POSIX nicety I do believe... */
52#define VREPRINT 12
53#define VDISCARD 13
54#define VWERASE 14
55#define VLNEXT 15
56
57/* Kernel keeps vmin/vtime separated, user apps assume vmin/vtime is
58 * shared with eof/eol
59 */
60#ifdef __KERNEL__
61#define VMIN 16
62#define VTIME 17
63#else
64#define VMIN VEOF
65#define VTIME VEOL
66#endif
67
68/* c_iflag bits */
69#define IGNBRK 0x00000001
70#define BRKINT 0x00000002
71#define IGNPAR 0x00000004
72#define PARMRK 0x00000008
73#define INPCK 0x00000010
74#define ISTRIP 0x00000020
75#define INLCR 0x00000040
76#define IGNCR 0x00000080
77#define ICRNL 0x00000100
78#define IUCLC 0x00000200
79#define IXON 0x00000400
80#define IXANY 0x00000800
81#define IXOFF 0x00001000
82#define IMAXBEL 0x00002000
83#define IUTF8 0x00004000
84
85/* c_oflag bits */
86#define OPOST 0x00000001
87#define OLCUC 0x00000002
88#define ONLCR 0x00000004
89#define OCRNL 0x00000008
90#define ONOCR 0x00000010
91#define ONLRET 0x00000020
92#define OFILL 0x00000040
93#define OFDEL 0x00000080
94#define NLDLY 0x00000100
95#define NL0 0x00000000
96#define NL1 0x00000100
97#define CRDLY 0x00000600
98#define CR0 0x00000000
99#define CR1 0x00000200
100#define CR2 0x00000400
101#define CR3 0x00000600
102#define TABDLY 0x00001800
103#define TAB0 0x00000000
104#define TAB1 0x00000800
105#define TAB2 0x00001000
106#define TAB3 0x00001800
107#define XTABS 0x00001800
108#define BSDLY 0x00002000
109#define BS0 0x00000000
110#define BS1 0x00002000
111#define VTDLY 0x00004000
112#define VT0 0x00000000
113#define VT1 0x00004000
114#define FFDLY 0x00008000
115#define FF0 0x00000000
116#define FF1 0x00008000
117#define PAGEOUT 0x00010000 /* SUNOS specific */
118#define WRAP 0x00020000 /* SUNOS specific */
119
120/* c_cflag bit meaning */
121#define CBAUD 0x0000100f
122#define B0 0x00000000 /* hang up */
123#define B50 0x00000001
124#define B75 0x00000002
125#define B110 0x00000003
126#define B134 0x00000004
127#define B150 0x00000005
128#define B200 0x00000006
129#define B300 0x00000007
130#define B600 0x00000008
131#define B1200 0x00000009
132#define B1800 0x0000000a
133#define B2400 0x0000000b
134#define B4800 0x0000000c
135#define B9600 0x0000000d
136#define B19200 0x0000000e
137#define B38400 0x0000000f
138#define EXTA B19200
139#define EXTB B38400
140#define CSIZE 0x00000030
141#define CS5 0x00000000
142#define CS6 0x00000010
143#define CS7 0x00000020
144#define CS8 0x00000030
145#define CSTOPB 0x00000040
146#define CREAD 0x00000080
147#define PARENB 0x00000100
148#define PARODD 0x00000200
149#define HUPCL 0x00000400
150#define CLOCAL 0x00000800
151#define CBAUDEX 0x00001000
152#define B57600 0x00001001
153#define B115200 0x00001002
154#define B230400 0x00001003
155#define B460800 0x00001004
156/* This is what we can do with the Zilogs. */
157#define B76800 0x00001005
158/* This is what we can do with the SAB82532. */
159#define B153600 0x00001006
160#define B307200 0x00001007
161#define B614400 0x00001008
162#define B921600 0x00001009
163/* And these are the rest... */
164#define B500000 0x0000100a
165#define B576000 0x0000100b
166#define B1000000 0x0000100c
167#define B1152000 0x0000100d
168#define B1500000 0x0000100e
169#define B2000000 0x0000100f
170/* These have totally bogus values and nobody uses them
171 so far. Later on we'd have to use say 0x10000x and
172 adjust CBAUD constant and drivers accordingly.
173#define B2500000 0x00001010
174#define B3000000 0x00001011
175#define B3500000 0x00001012
176#define B4000000 0x00001013 */
177#define CIBAUD 0x100f0000 /* input baud rate (not used) */
178#define CMSPAR 0x40000000 /* mark or space (stick) parity */
179#define CRTSCTS 0x80000000 /* flow control */
180
181/* c_lflag bits */
182#define ISIG 0x00000001
183#define ICANON 0x00000002
184#define XCASE 0x00000004
185#define ECHO 0x00000008
186#define ECHOE 0x00000010
187#define ECHOK 0x00000020
188#define ECHONL 0x00000040
189#define NOFLSH 0x00000080
190#define TOSTOP 0x00000100
191#define ECHOCTL 0x00000200
192#define ECHOPRT 0x00000400
193#define ECHOKE 0x00000800
194#define DEFECHO 0x00001000 /* SUNOS thing, what is it? */
195#define FLUSHO 0x00002000
196#define PENDIN 0x00004000
197#define IEXTEN 0x00008000
198
199/* modem lines */
200#define TIOCM_LE 0x001
201#define TIOCM_DTR 0x002
202#define TIOCM_RTS 0x004
203#define TIOCM_ST 0x008
204#define TIOCM_SR 0x010
205#define TIOCM_CTS 0x020
206#define TIOCM_CAR 0x040
207#define TIOCM_RNG 0x080
208#define TIOCM_DSR 0x100
209#define TIOCM_CD TIOCM_CAR
210#define TIOCM_RI TIOCM_RNG
211#define TIOCM_OUT1 0x2000
212#define TIOCM_OUT2 0x4000
213#define TIOCM_LOOP 0x8000
214
215/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
216#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
217
218
219/* tcflow() and TCXONC use these */
220#define TCOOFF 0
221#define TCOON 1
222#define TCIOFF 2
223#define TCION 3
224
225/* tcflush() and TCFLSH use these */
226#define TCIFLUSH 0
227#define TCOFLUSH 1
228#define TCIOFLUSH 2
229
230/* tcsetattr uses these */
231#define TCSANOW 0
232#define TCSADRAIN 1
233#define TCSAFLUSH 2
234
235#endif /* !(_SPARC64_TERMBITS_H) */
diff --git a/include/asm-sparc64/termios.h b/include/asm-sparc64/termios.h
new file mode 100644
index 000000000000..8effce0da087
--- /dev/null
+++ b/include/asm-sparc64/termios.h
@@ -0,0 +1,173 @@
1/* $Id: termios.h,v 1.11 2001/06/01 08:12:11 davem Exp $ */
2#ifndef _SPARC64_TERMIOS_H
3#define _SPARC64_TERMIOS_H
4
5#include <asm/ioctls.h>
6#include <asm/termbits.h>
7
8#if defined(__KERNEL__) || defined(__DEFINE_BSD_TERMIOS)
9struct sgttyb {
10 char sg_ispeed;
11 char sg_ospeed;
12 char sg_erase;
13 char sg_kill;
14 short sg_flags;
15};
16
17struct tchars {
18 char t_intrc;
19 char t_quitc;
20 char t_startc;
21 char t_stopc;
22 char t_eofc;
23 char t_brkc;
24};
25
26struct ltchars {
27 char t_suspc;
28 char t_dsuspc;
29 char t_rprntc;
30 char t_flushc;
31 char t_werasc;
32 char t_lnextc;
33};
34#endif /* __KERNEL__ */
35
36struct sunos_ttysize {
37 int st_lines; /* Lines on the terminal */
38 int st_columns; /* Columns on the terminal */
39};
40
41/* Used for packet mode */
42#define TIOCPKT_DATA 0
43#define TIOCPKT_FLUSHREAD 1
44#define TIOCPKT_FLUSHWRITE 2
45#define TIOCPKT_STOP 4
46#define TIOCPKT_START 8
47#define TIOCPKT_NOSTOP 16
48#define TIOCPKT_DOSTOP 32
49
50struct winsize {
51 unsigned short ws_row;
52 unsigned short ws_col;
53 unsigned short ws_xpixel;
54 unsigned short ws_ypixel;
55};
56
57/* line disciplines */
58#define N_TTY 0
59#define N_SLIP 1
60#define N_MOUSE 2
61#define N_PPP 3
62#define N_STRIP 4
63#define N_AX25 5
64#define N_X25 6
65#define N_6PACK 7
66#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
67#define N_R3964 9 /* Reserved for Simatic R3964 module */
68#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
69#define N_IRDA 11 /* Linux IrDa - http://irda.sourceforge.net/ */
70#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards about SMS messages */
71#define N_HDLC 13 /* synchronous HDLC */
72#define N_SYNC_PPP 14 /* synchronous PPP */
73#define N_HCI 15 /* Bluetooth HCI UART */
74
75#ifdef __KERNEL__
76#include <linux/module.h>
77
78/*
79 * c_cc characters in the termio structure. Oh, how I love being
80 * backwardly compatible. Notice that character 4 and 5 are
81 * interpreted differently depending on whether ICANON is set in
82 * c_lflag. If it's set, they are used as _VEOF and _VEOL, otherwise
83 * as _VMIN and V_TIME. This is for compatibility with OSF/1 (which
84 * is compatible with sysV)...
85 */
86#define _VMIN 4
87#define _VTIME 5
88
89/* intr=^C quit=^\ erase=del kill=^U
90 eof=^D eol=\0 eol2=\0 sxtc=\0
91 start=^Q stop=^S susp=^Z dsusp=^Y
92 reprint=^R discard=^U werase=^W lnext=^V
93 vmin=\1 vtime=\0
94*/
95#define INIT_C_CC "\003\034\177\025\004\000\000\000\021\023\032\031\022\025\027\026\001"
96
97/*
98 * Translate a "termio" structure into a "termios". Ugh.
99 */
100#define user_termio_to_kernel_termios(termios, termio) \
101({ \
102 unsigned short tmp; \
103 get_user(tmp, &(termio)->c_iflag); \
104 (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
105 get_user(tmp, &(termio)->c_oflag); \
106 (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
107 get_user(tmp, &(termio)->c_cflag); \
108 (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
109 get_user(tmp, &(termio)->c_lflag); \
110 (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
111 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
112 0; \
113})
114
115/*
116 * Translate a "termios" structure into a "termio". Ugh.
117 *
118 * Note the "fun" _VMIN overloading.
119 */
120#define kernel_termios_to_user_termio(termio, termios) \
121({ \
122 put_user((termios)->c_iflag, &(termio)->c_iflag); \
123 put_user((termios)->c_oflag, &(termio)->c_oflag); \
124 put_user((termios)->c_cflag, &(termio)->c_cflag); \
125 put_user((termios)->c_lflag, &(termio)->c_lflag); \
126 put_user((termios)->c_line, &(termio)->c_line); \
127 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
128 if (!((termios)->c_lflag & ICANON)) { \
129 put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \
130 put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \
131 } \
132 0; \
133})
134
135#define user_termios_to_kernel_termios(k, u) \
136({ \
137 get_user((k)->c_iflag, &(u)->c_iflag); \
138 get_user((k)->c_oflag, &(u)->c_oflag); \
139 get_user((k)->c_cflag, &(u)->c_cflag); \
140 get_user((k)->c_lflag, &(u)->c_lflag); \
141 get_user((k)->c_line, &(u)->c_line); \
142 copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \
143 if((k)->c_lflag & ICANON) { \
144 get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
145 get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
146 } else { \
147 get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
148 get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
149 } \
150 0; \
151})
152
153#define kernel_termios_to_user_termios(u, k) \
154({ \
155 put_user((k)->c_iflag, &(u)->c_iflag); \
156 put_user((k)->c_oflag, &(u)->c_oflag); \
157 put_user((k)->c_cflag, &(u)->c_cflag); \
158 put_user((k)->c_lflag, &(u)->c_lflag); \
159 put_user((k)->c_line, &(u)->c_line); \
160 copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \
161 if(!((k)->c_lflag & ICANON)) { \
162 put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \
163 put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \
164 } else { \
165 put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \
166 put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \
167 } \
168 0; \
169})
170
171#endif /* __KERNEL__ */
172
173#endif /* _SPARC64_TERMIOS_H */
diff --git a/include/asm-sparc64/thread_info.h b/include/asm-sparc64/thread_info.h
new file mode 100644
index 000000000000..517caaba1c87
--- /dev/null
+++ b/include/asm-sparc64/thread_info.h
@@ -0,0 +1,252 @@
1/* $Id: thread_info.h,v 1.1 2002/02/10 00:00:58 davem Exp $
2 * thread_info.h: sparc64 low-level thread information
3 *
4 * Copyright (C) 2002 David S. Miller (davem@redhat.com)
5 */
6
7#ifndef _ASM_THREAD_INFO_H
8#define _ASM_THREAD_INFO_H
9
10#ifdef __KERNEL__
11
12#define NSWINS 7
13
14#define TI_FLAG_BYTE_FAULT_CODE 0
15#define TI_FLAG_FAULT_CODE_SHIFT 56
16#define TI_FLAG_BYTE_WSTATE 1
17#define TI_FLAG_WSTATE_SHIFT 48
18#define TI_FLAG_BYTE_CWP 2
19#define TI_FLAG_CWP_SHIFT 40
20#define TI_FLAG_BYTE_CURRENT_DS 3
21#define TI_FLAG_CURRENT_DS_SHIFT 32
22#define TI_FLAG_BYTE_FPDEPTH 4
23#define TI_FLAG_FPDEPTH_SHIFT 24
24#define TI_FLAG_BYTE_WSAVED 5
25#define TI_FLAG_WSAVED_SHIFT 16
26
27#include <asm/page.h>
28
29#ifndef __ASSEMBLY__
30
31#include <asm/ptrace.h>
32#include <asm/types.h>
33
34struct task_struct;
35struct exec_domain;
36
37struct thread_info {
38 /* D$ line 1 */
39 struct task_struct *task;
40 unsigned long flags;
41 __u8 cpu;
42 __u8 fpsaved[7];
43 unsigned long ksp;
44
45 /* D$ line 2 */
46 unsigned long fault_address;
47 struct pt_regs *kregs;
48 struct exec_domain *exec_domain;
49 int preempt_count;
50 int __pad;
51
52 unsigned long *utraps;
53
54 struct reg_window reg_window[NSWINS];
55 unsigned long rwbuf_stkptrs[NSWINS];
56
57 unsigned long gsr[7];
58 unsigned long xfsr[7];
59
60 __u64 __user *user_cntd0;
61 __u64 __user *user_cntd1;
62 __u64 kernel_cntd0, kernel_cntd1;
63 __u64 pcr_reg;
64
65 __u64 cee_stuff;
66
67 struct restart_block restart_block;
68
69 unsigned long fpregs[0] __attribute__ ((aligned(64)));
70};
71
72#endif /* !(__ASSEMBLY__) */
73
74/* offsets into the thread_info struct for assembly code access */
75#define TI_TASK 0x00000000
76#define TI_FLAGS 0x00000008
77#define TI_FAULT_CODE (TI_FLAGS + TI_FLAG_BYTE_FAULT_CODE)
78#define TI_WSTATE (TI_FLAGS + TI_FLAG_BYTE_WSTATE)
79#define TI_CWP (TI_FLAGS + TI_FLAG_BYTE_CWP)
80#define TI_CURRENT_DS (TI_FLAGS + TI_FLAG_BYTE_CURRENT_DS)
81#define TI_FPDEPTH (TI_FLAGS + TI_FLAG_BYTE_FPDEPTH)
82#define TI_WSAVED (TI_FLAGS + TI_FLAG_BYTE_WSAVED)
83#define TI_CPU 0x00000010
84#define TI_FPSAVED 0x00000011
85#define TI_KSP 0x00000018
86#define TI_FAULT_ADDR 0x00000020
87#define TI_KREGS 0x00000028
88#define TI_EXEC_DOMAIN 0x00000030
89#define TI_PRE_COUNT 0x00000038
90#define TI_UTRAPS 0x00000040
91#define TI_REG_WINDOW 0x00000048
92#define TI_RWIN_SPTRS 0x000003c8
93#define TI_GSR 0x00000400
94#define TI_XFSR 0x00000438
95#define TI_USER_CNTD0 0x00000470
96#define TI_USER_CNTD1 0x00000478
97#define TI_KERN_CNTD0 0x00000480
98#define TI_KERN_CNTD1 0x00000488
99#define TI_PCR 0x00000490
100#define TI_CEE_STUFF 0x00000498
101#define TI_RESTART_BLOCK 0x000004a0
102#define TI_FPREGS 0x00000500
103
104/* We embed this in the uppermost byte of thread_info->flags */
105#define FAULT_CODE_WRITE 0x01 /* Write access, implies D-TLB */
106#define FAULT_CODE_DTLB 0x02 /* Miss happened in D-TLB */
107#define FAULT_CODE_ITLB 0x04 /* Miss happened in I-TLB */
108#define FAULT_CODE_WINFIXUP 0x08 /* Miss happened during spill/fill */
109#define FAULT_CODE_BLKCOMMIT 0x10 /* Use blk-commit ASI in copy_page */
110
111#if PAGE_SHIFT == 13
112#define THREAD_SIZE (2*PAGE_SIZE)
113#define THREAD_SHIFT (PAGE_SHIFT + 1)
114#else /* PAGE_SHIFT == 13 */
115#define THREAD_SIZE PAGE_SIZE
116#define THREAD_SHIFT PAGE_SHIFT
117#endif /* PAGE_SHIFT == 13 */
118
119#define PREEMPT_ACTIVE 0x4000000
120
121/*
122 * macros/functions for gaining access to the thread information structure
123 *
124 * preempt_count needs to be 1 initially, until the scheduler is functional.
125 */
126#ifndef __ASSEMBLY__
127
128#define INIT_THREAD_INFO(tsk) \
129{ \
130 .task = &tsk, \
131 .flags = ((unsigned long)ASI_P) << TI_FLAG_CURRENT_DS_SHIFT, \
132 .exec_domain = &default_exec_domain, \
133 .preempt_count = 1, \
134 .restart_block = { \
135 .fn = do_no_restart_syscall, \
136 }, \
137}
138
139#define init_thread_info (init_thread_union.thread_info)
140#define init_stack (init_thread_union.stack)
141
142/* how to get the thread information struct from C */
143register struct thread_info *current_thread_info_reg asm("g6");
144#define current_thread_info() (current_thread_info_reg)
145
146/* thread information allocation */
147#if PAGE_SHIFT == 13
148#define __THREAD_INFO_ORDER 1
149#else /* PAGE_SHIFT == 13 */
150#define __THREAD_INFO_ORDER 0
151#endif /* PAGE_SHIFT == 13 */
152
153#ifdef CONFIG_DEBUG_STACK_USAGE
154#define alloc_thread_info(tsk) \
155({ \
156 struct thread_info *ret; \
157 \
158 ret = (struct thread_info *) \
159 __get_free_pages(GFP_KERNEL, __THREAD_INFO_ORDER); \
160 if (ret) \
161 memset(ret, 0, PAGE_SIZE<<__THREAD_INFO_ORDER); \
162 ret; \
163})
164#else
165#define alloc_thread_info(tsk) \
166 ((struct thread_info *)__get_free_pages(GFP_KERNEL, __THREAD_INFO_ORDER))
167#endif
168
169#define free_thread_info(ti) \
170 free_pages((unsigned long)(ti),__THREAD_INFO_ORDER)
171
172#define __thread_flag_byte_ptr(ti) \
173 ((unsigned char *)(&((ti)->flags)))
174#define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
175
176#define get_thread_fault_code() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FAULT_CODE])
177#define set_thread_fault_code(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FAULT_CODE] = (val))
178#define get_thread_wstate() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE])
179#define set_thread_wstate(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE] = (val))
180#define get_thread_cwp() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP])
181#define set_thread_cwp(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP] = (val))
182#define get_thread_current_ds() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CURRENT_DS])
183#define set_thread_current_ds(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CURRENT_DS] = (val))
184#define get_thread_fpdepth() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH])
185#define set_thread_fpdepth(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH] = (val))
186#define get_thread_wsaved() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED])
187#define set_thread_wsaved(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED] = (val))
188
189#endif /* !(__ASSEMBLY__) */
190
191/*
192 * Thread information flags, only 16 bits are available as we encode
193 * other values into the upper 6 bytes.
194 *
195 * On trap return we need to test several values:
196 *
197 * user: need_resched, notify_resume, sigpending, wsaved, perfctr
198 * kernel: fpdepth
199 *
200 * So to check for work in the kernel case we simply load the fpdepth
201 * byte out of the flags and test it. For the user case we encode the
202 * lower 3 bytes of flags as follows:
203 * ----------------------------------------
204 * | wsaved | flags byte 1 | flags byte 2 |
205 * ----------------------------------------
206 * This optimizes the user test into:
207 * ldx [%g6 + TI_FLAGS], REG1
208 * sethi %hi(_TIF_USER_WORK_MASK), REG2
209 * or REG2, %lo(_TIF_USER_WORK_MASK), REG2
210 * andcc REG1, REG2, %g0
211 * be,pt no_work_to_do
212 * nop
213 */
214#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
215#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
216#define TIF_SIGPENDING 2 /* signal pending */
217#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
218#define TIF_PERFCTR 4 /* performance counters active */
219#define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
220#define TIF_NEWSIGNALS 6 /* wants new-style signals */
221#define TIF_32BIT 7 /* 32-bit binary */
222#define TIF_NEWCHILD 8 /* just-spawned child process */
223/* TIF_* value 9 is available */
224#define TIF_POLLING_NRFLAG 10
225#define TIF_SYSCALL_SUCCESS 11
226/* NOTE: Thread flags >= 12 should be ones we have no interest
227 * in using in assembly, else we can't use the mask as
228 * an immediate value in instructions such as andcc.
229 */
230#define TIF_ABI_PENDING 12
231#define TIF_MEMDIE 13
232
233#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
234#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
235#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
236#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
237#define _TIF_PERFCTR (1<<TIF_PERFCTR)
238#define _TIF_UNALIGNED (1<<TIF_UNALIGNED)
239#define _TIF_NEWSIGNALS (1<<TIF_NEWSIGNALS)
240#define _TIF_32BIT (1<<TIF_32BIT)
241#define _TIF_NEWCHILD (1<<TIF_NEWCHILD)
242#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
243#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
244#define _TIF_SYSCALL_SUCCESS (1<<TIF_SYSCALL_SUCCESS)
245
246#define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
247 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
248 _TIF_NEED_RESCHED | _TIF_PERFCTR))
249
250#endif /* __KERNEL__ */
251
252#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/asm-sparc64/timer.h b/include/asm-sparc64/timer.h
new file mode 100644
index 000000000000..ba33a2b6b7bd
--- /dev/null
+++ b/include/asm-sparc64/timer.h
@@ -0,0 +1,74 @@
1/* $Id: timer.h,v 1.3 2000/05/09 17:40:15 davem Exp $
2 * timer.h: System timer definitions for sun5.
3 *
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_TIMER_H
8#define _SPARC64_TIMER_H
9
10#include <linux/types.h>
11
12/* How timers work:
13 *
14 * On uniprocessors we just use counter zero for the system wide
15 * ticker, this performs thread scheduling, clock book keeping,
16 * and runs timer based events. Previously we used the Ultra
17 * %tick interrupt for this purpose.
18 *
19 * On multiprocessors we pick one cpu as the master level 10 tick
20 * processor. Here this counter zero tick handles clock book
21 * keeping and timer events only. Each Ultra has it's level
22 * 14 %tick interrupt set to fire off as well, even the master
23 * tick cpu runs this locally. This ticker performs thread
24 * scheduling, system/user tick counting for the current thread,
25 * and also profiling if enabled.
26 */
27
28#include <linux/config.h>
29
30/* Two timers, traditionally steered to PIL's 10 and 14 respectively.
31 * But since INO packets are used on sun5, we could use any PIL level
32 * we like, however for now we use the normal ones.
33 *
34 * The 'reg' and 'interrupts' properties for these live in nodes named
35 * 'counter-timer'. The first of three 'reg' properties describe where
36 * the sun5_timer registers are. The other two I have no idea. (XXX)
37 */
38struct sun5_timer {
39 u64 count0;
40 u64 limit0;
41 u64 count1;
42 u64 limit1;
43};
44
45#define SUN5_LIMIT_ENABLE 0x80000000
46#define SUN5_LIMIT_TOZERO 0x40000000
47#define SUN5_LIMIT_ZRESTART 0x20000000
48#define SUN5_LIMIT_CMASK 0x1fffffff
49
50/* Given a HZ value, set the limit register to so that the timer IRQ
51 * gets delivered that often.
52 */
53#define SUN5_HZ_TO_LIMIT(__hz) (1000000/(__hz))
54
55struct sparc64_tick_ops {
56 void (*init_tick)(unsigned long);
57 unsigned long (*get_tick)(void);
58 unsigned long (*get_compare)(void);
59 unsigned long (*add_tick)(unsigned long, unsigned long);
60 unsigned long (*add_compare)(unsigned long);
61 unsigned long softint_mask;
62};
63
64extern struct sparc64_tick_ops *tick_ops;
65
66#ifdef CONFIG_SMP
67extern unsigned long timer_tick_offset;
68struct pt_regs;
69extern void timer_tick_interrupt(struct pt_regs *);
70#endif
71
72extern unsigned long sparc64_get_clock_tick(unsigned int cpu);
73
74#endif /* _SPARC64_TIMER_H */
diff --git a/include/asm-sparc64/timex.h b/include/asm-sparc64/timex.h
new file mode 100644
index 000000000000..9e8d4175bcb2
--- /dev/null
+++ b/include/asm-sparc64/timex.h
@@ -0,0 +1,17 @@
1/*
2 * linux/include/asm-sparc64/timex.h
3 *
4 * sparc64 architecture timex specifications
5 */
6#ifndef _ASMsparc64_TIMEX_H
7#define _ASMsparc64_TIMEX_H
8
9#include <asm/timer.h>
10
11#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
12
13/* Getting on the cycle counter on sparc64. */
14typedef unsigned long cycles_t;
15#define get_cycles() tick_ops->get_tick()
16
17#endif
diff --git a/include/asm-sparc64/tlb.h b/include/asm-sparc64/tlb.h
new file mode 100644
index 000000000000..9baf57db01d2
--- /dev/null
+++ b/include/asm-sparc64/tlb.h
@@ -0,0 +1,128 @@
1#ifndef _SPARC64_TLB_H
2#define _SPARC64_TLB_H
3
4#include <linux/config.h>
5#include <linux/swap.h>
6#include <asm/pgalloc.h>
7#include <asm/tlbflush.h>
8#include <asm/mmu_context.h>
9
10#define TLB_BATCH_NR 192
11
12/*
13 * For UP we don't need to worry about TLB flush
14 * and page free order so much..
15 */
16#ifdef CONFIG_SMP
17 #define FREE_PTE_NR 506
18 #define tlb_fast_mode(bp) ((bp)->pages_nr == ~0U)
19#else
20 #define FREE_PTE_NR 1
21 #define tlb_fast_mode(bp) 1
22#endif
23
24struct mmu_gather {
25 struct mm_struct *mm;
26 unsigned int pages_nr;
27 unsigned int need_flush;
28 unsigned int tlb_frozen;
29 unsigned int tlb_nr;
30 unsigned long freed;
31 unsigned long vaddrs[TLB_BATCH_NR];
32 struct page *pages[FREE_PTE_NR];
33};
34
35DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
36
37#ifdef CONFIG_SMP
38extern void smp_flush_tlb_pending(struct mm_struct *,
39 unsigned long, unsigned long *);
40#endif
41
42extern void __flush_tlb_pending(unsigned long, unsigned long, unsigned long *);
43extern void flush_tlb_pending(void);
44
45static inline struct mmu_gather *tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
46{
47 struct mmu_gather *mp = &__get_cpu_var(mmu_gathers);
48
49 BUG_ON(mp->tlb_nr);
50
51 mp->mm = mm;
52 mp->pages_nr = num_online_cpus() > 1 ? 0U : ~0U;
53 mp->tlb_frozen = full_mm_flush;
54 mp->freed = 0;
55
56 return mp;
57}
58
59
60static inline void tlb_flush_mmu(struct mmu_gather *mp)
61{
62 if (mp->need_flush) {
63 mp->need_flush = 0;
64 if (!tlb_fast_mode(mp)) {
65 free_pages_and_swap_cache(mp->pages, mp->pages_nr);
66 mp->pages_nr = 0;
67 }
68 }
69
70}
71
72#ifdef CONFIG_SMP
73extern void smp_flush_tlb_mm(struct mm_struct *mm);
74#define do_flush_tlb_mm(mm) smp_flush_tlb_mm(mm)
75#else
76#define do_flush_tlb_mm(mm) __flush_tlb_mm(CTX_HWBITS(mm->context), SECONDARY_CONTEXT)
77#endif
78
79static inline void tlb_finish_mmu(struct mmu_gather *mp, unsigned long start, unsigned long end)
80{
81 unsigned long freed = mp->freed;
82 struct mm_struct *mm = mp->mm;
83 unsigned long rss = get_mm_counter(mm, rss);
84
85 if (rss < freed)
86 freed = rss;
87 add_mm_counter(mm, rss, -freed);
88
89 tlb_flush_mmu(mp);
90
91 if (mp->tlb_frozen) {
92 if (CTX_VALID(mm->context))
93 do_flush_tlb_mm(mm);
94 mp->tlb_frozen = 0;
95 } else
96 flush_tlb_pending();
97
98 /* keep the page table cache within bounds */
99 check_pgt_cache();
100}
101
102static inline unsigned int tlb_is_full_mm(struct mmu_gather *mp)
103{
104 return mp->tlb_frozen;
105}
106
107static inline void tlb_remove_page(struct mmu_gather *mp, struct page *page)
108{
109 mp->need_flush = 1;
110 if (tlb_fast_mode(mp)) {
111 free_page_and_swap_cache(page);
112 return;
113 }
114 mp->pages[mp->pages_nr++] = page;
115 if (mp->pages_nr >= FREE_PTE_NR)
116 tlb_flush_mmu(mp);
117}
118
119#define tlb_remove_tlb_entry(mp,ptep,addr) do { } while (0)
120#define pte_free_tlb(mp,ptepage) pte_free(ptepage)
121#define pmd_free_tlb(mp,pmdp) pmd_free(pmdp)
122#define pud_free_tlb(tlb,pudp) __pud_free_tlb(tlb,pudp)
123
124#define tlb_migrate_finish(mm) do { } while (0)
125#define tlb_start_vma(tlb, vma) do { } while (0)
126#define tlb_end_vma(tlb, vma) do { } while (0)
127
128#endif /* _SPARC64_TLB_H */
diff --git a/include/asm-sparc64/tlbflush.h b/include/asm-sparc64/tlbflush.h
new file mode 100644
index 000000000000..3ef9909ac3ac
--- /dev/null
+++ b/include/asm-sparc64/tlbflush.h
@@ -0,0 +1,41 @@
1#ifndef _SPARC64_TLBFLUSH_H
2#define _SPARC64_TLBFLUSH_H
3
4#include <linux/config.h>
5#include <linux/mm.h>
6#include <asm/mmu_context.h>
7
8/* TLB flush operations. */
9
10extern void flush_tlb_pending(void);
11
12#define flush_tlb_range(vma,start,end) \
13 do { (void)(start); flush_tlb_pending(); } while (0)
14#define flush_tlb_page(vma,addr) flush_tlb_pending()
15#define flush_tlb_mm(mm) flush_tlb_pending()
16
17extern void __flush_tlb_all(void);
18extern void __flush_tlb_page(unsigned long context, unsigned long page, unsigned long r);
19
20extern void __flush_tlb_kernel_range(unsigned long start, unsigned long end);
21
22#ifndef CONFIG_SMP
23
24#define flush_tlb_all() __flush_tlb_all()
25#define flush_tlb_kernel_range(start,end) \
26 __flush_tlb_kernel_range(start,end)
27
28#else /* CONFIG_SMP */
29
30extern void smp_flush_tlb_all(void);
31extern void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end);
32
33#define flush_tlb_all() smp_flush_tlb_all()
34#define flush_tlb_kernel_range(start, end) \
35 smp_flush_tlb_kernel_range(start, end)
36
37#endif /* ! CONFIG_SMP */
38
39extern void flush_tlb_pgtables(struct mm_struct *, unsigned long, unsigned long);
40
41#endif /* _SPARC64_TLBFLUSH_H */
diff --git a/include/asm-sparc64/topology.h b/include/asm-sparc64/topology.h
new file mode 100644
index 000000000000..0e234e201bd6
--- /dev/null
+++ b/include/asm-sparc64/topology.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_SPARC64_TOPOLOGY_H
2#define _ASM_SPARC64_TOPOLOGY_H
3
4#include <asm-generic/topology.h>
5
6#endif /* _ASM_SPARC64_TOPOLOGY_H */
diff --git a/include/asm-sparc64/ttable.h b/include/asm-sparc64/ttable.h
new file mode 100644
index 000000000000..2784f80094c3
--- /dev/null
+++ b/include/asm-sparc64/ttable.h
@@ -0,0 +1,407 @@
1/* $Id: ttable.h,v 1.18 2002/02/09 19:49:32 davem Exp $ */
2#ifndef _SPARC64_TTABLE_H
3#define _SPARC64_TTABLE_H
4
5#include <linux/config.h>
6#include <asm/utrap.h>
7
8#ifdef __ASSEMBLY__
9#include <asm/thread_info.h>
10#endif
11
12#define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop;
13
14/* We need a "cleaned" instruction... */
15#define CLEAN_WINDOW \
16 rdpr %cleanwin, %l0; add %l0, 1, %l0; \
17 wrpr %l0, 0x0, %cleanwin; \
18 clr %o0; clr %o1; clr %o2; clr %o3; \
19 clr %o4; clr %o5; clr %o6; clr %o7; \
20 clr %l0; clr %l1; clr %l2; clr %l3; \
21 clr %l4; clr %l5; clr %l6; clr %l7; \
22 retry; \
23 nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
24
25#define TRAP(routine) \
26 sethi %hi(109f), %g7; \
27 ba,pt %xcc, etrap; \
28109: or %g7, %lo(109b), %g7; \
29 call routine; \
30 add %sp, PTREGS_OFF, %o0; \
31 ba,pt %xcc, rtrap; \
32 clr %l6; \
33 nop;
34
35#define TRAP_7INSNS(routine) \
36 sethi %hi(109f), %g7; \
37 ba,pt %xcc, etrap; \
38109: or %g7, %lo(109b), %g7; \
39 call routine; \
40 add %sp, PTREGS_OFF, %o0; \
41 ba,pt %xcc, rtrap; \
42 clr %l6;
43
44#define TRAP_SAVEFPU(routine) \
45 sethi %hi(109f), %g7; \
46 ba,pt %xcc, do_fptrap; \
47109: or %g7, %lo(109b), %g7; \
48 call routine; \
49 add %sp, PTREGS_OFF, %o0; \
50 ba,pt %xcc, rtrap; \
51 clr %l6; \
52 nop;
53
54#define TRAP_NOSAVE(routine) \
55 ba,pt %xcc, routine; \
56 nop; \
57 nop; nop; nop; nop; nop; nop;
58
59#define TRAP_NOSAVE_7INSNS(routine) \
60 ba,pt %xcc, routine; \
61 nop; \
62 nop; nop; nop; nop; nop;
63
64#define TRAPTL1(routine) \
65 sethi %hi(109f), %g7; \
66 ba,pt %xcc, etraptl1; \
67109: or %g7, %lo(109b), %g7; \
68 call routine; \
69 add %sp, PTREGS_OFF, %o0; \
70 ba,pt %xcc, rtrap; \
71 clr %l6; \
72 nop;
73
74#define TRAP_ARG(routine, arg) \
75 sethi %hi(109f), %g7; \
76 ba,pt %xcc, etrap; \
77109: or %g7, %lo(109b), %g7; \
78 add %sp, PTREGS_OFF, %o0; \
79 call routine; \
80 mov arg, %o1; \
81 ba,pt %xcc, rtrap; \
82 clr %l6;
83
84#define TRAPTL1_ARG(routine, arg) \
85 sethi %hi(109f), %g7; \
86 ba,pt %xcc, etraptl1; \
87109: or %g7, %lo(109b), %g7; \
88 add %sp, PTREGS_OFF, %o0; \
89 call routine; \
90 mov arg, %o1; \
91 ba,pt %xcc, rtrap; \
92 clr %l6;
93
94#define SYSCALL_TRAP(routine, systbl) \
95 sethi %hi(109f), %g7; \
96 ba,pt %xcc, scetrap; \
97109: or %g7, %lo(109b), %g7; \
98 sethi %hi(systbl), %l7; \
99 ba,pt %xcc, routine; \
100 or %l7, %lo(systbl), %l7; \
101 nop; nop;
102
103#define INDIRECT_SOLARIS_SYSCALL(num) \
104 sethi %hi(109f), %g7; \
105 ba,pt %xcc, etrap; \
106109: or %g7, %lo(109b), %g7; \
107 ba,pt %xcc, tl0_solaris + 0xc; \
108 mov num, %g1; \
109 nop;nop;nop;
110
111#define TRAP_UTRAP(handler,lvl) \
112 ldx [%g6 + TI_UTRAPS], %g1; \
113 sethi %hi(109f), %g7; \
114 brz,pn %g1, utrap; \
115 or %g7, %lo(109f), %g7; \
116 ba,pt %xcc, utrap; \
117109: ldx [%g1 + handler*8], %g1; \
118 ba,pt %xcc, utrap_ill; \
119 mov lvl, %o1;
120
121#ifdef CONFIG_SUNOS_EMUL
122#define SUNOS_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sunos_sys_table)
123#else
124#define SUNOS_SYSCALL_TRAP TRAP(sunos_syscall)
125#endif
126#ifdef CONFIG_COMPAT
127#define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
128#else
129#define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110)
130#endif
131#define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
132#define GETCC_TRAP TRAP(getcc)
133#define SETCC_TRAP TRAP(setcc)
134#ifdef CONFIG_SOLARIS_EMUL
135#define SOLARIS_SYSCALL_TRAP TRAP(solaris_sparc_syscall)
136#else
137#define SOLARIS_SYSCALL_TRAP TRAP(solaris_syscall)
138#endif
139/* FIXME: Write these actually */
140#define NETBSD_SYSCALL_TRAP TRAP(netbsd_syscall)
141#define BREAKPOINT_TRAP TRAP(breakpoint_trap)
142
143#define TRAP_IRQ(routine, level) \
144 rdpr %pil, %g2; \
145 wrpr %g0, 15, %pil; \
146 b,pt %xcc, etrap_irq; \
147 rd %pc, %g7; \
148 mov level, %o0; \
149 call routine; \
150 add %sp, PTREGS_OFF, %o1; \
151 ba,a,pt %xcc, rtrap_irq;
152
153#define TICK_SMP_IRQ \
154 rdpr %pil, %g2; \
155 wrpr %g0, 15, %pil; \
156 sethi %hi(109f), %g7; \
157 b,pt %xcc, etrap_irq; \
158109: or %g7, %lo(109b), %g7; \
159 call smp_percpu_timer_interrupt; \
160 add %sp, PTREGS_OFF, %o0; \
161 ba,a,pt %xcc, rtrap_irq;
162
163#define TRAP_IVEC TRAP_NOSAVE(do_ivec)
164
165#define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
166
167#define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
168
169#define FLUSH_WINDOW_TRAP \
170 ba,pt %xcc, etrap; \
171 rd %pc, %g7; \
172 flushw; \
173 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \
174 add %l1, 4, %l2; \
175 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \
176 ba,pt %xcc, rtrap_clr_l6; \
177 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
178
179#ifdef CONFIG_KPROBES
180#define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl)
181#else
182#define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
183#endif
184
185/* Before touching these macros, you owe it to yourself to go and
186 * see how arch/sparc64/kernel/winfixup.S works... -DaveM
187 *
188 * For the user cases we used to use the %asi register, but
189 * it turns out that the "wr xxx, %asi" costs ~5 cycles, so
190 * now we use immediate ASI loads and stores instead. Kudos
191 * to Greg Onufer for pointing out this performance anomaly.
192 *
193 * Further note that we cannot use the g2, g4, g5, and g7 alternate
194 * globals in the spill routines, check out the save instruction in
195 * arch/sparc64/kernel/etrap.S to see what I mean about g2, and
196 * g4/g5 are the globals which are preserved by etrap processing
197 * for the caller of it. The g7 register is the return pc for
198 * etrap. Finally, g6 is the current thread register so we cannot
199 * us it in the spill handlers either. Most of these rules do not
200 * apply to fill processing, only g6 is not usable.
201 */
202
203/* Normal kernel spill */
204#define SPILL_0_NORMAL \
205 stx %l0, [%sp + STACK_BIAS + 0x00]; \
206 stx %l1, [%sp + STACK_BIAS + 0x08]; \
207 stx %l2, [%sp + STACK_BIAS + 0x10]; \
208 stx %l3, [%sp + STACK_BIAS + 0x18]; \
209 stx %l4, [%sp + STACK_BIAS + 0x20]; \
210 stx %l5, [%sp + STACK_BIAS + 0x28]; \
211 stx %l6, [%sp + STACK_BIAS + 0x30]; \
212 stx %l7, [%sp + STACK_BIAS + 0x38]; \
213 stx %i0, [%sp + STACK_BIAS + 0x40]; \
214 stx %i1, [%sp + STACK_BIAS + 0x48]; \
215 stx %i2, [%sp + STACK_BIAS + 0x50]; \
216 stx %i3, [%sp + STACK_BIAS + 0x58]; \
217 stx %i4, [%sp + STACK_BIAS + 0x60]; \
218 stx %i5, [%sp + STACK_BIAS + 0x68]; \
219 stx %i6, [%sp + STACK_BIAS + 0x70]; \
220 stx %i7, [%sp + STACK_BIAS + 0x78]; \
221 saved; retry; nop; nop; nop; nop; nop; nop; \
222 nop; nop; nop; nop; nop; nop; nop; nop;
223
224/* Normal 64bit spill */
225#define SPILL_1_GENERIC(ASI) \
226 add %sp, STACK_BIAS + 0x00, %g1; \
227 stxa %l0, [%g1 + %g0] ASI; \
228 mov 0x08, %g3; \
229 stxa %l1, [%g1 + %g3] ASI; \
230 add %g1, 0x10, %g1; \
231 stxa %l2, [%g1 + %g0] ASI; \
232 stxa %l3, [%g1 + %g3] ASI; \
233 add %g1, 0x10, %g1; \
234 stxa %l4, [%g1 + %g0] ASI; \
235 stxa %l5, [%g1 + %g3] ASI; \
236 add %g1, 0x10, %g1; \
237 stxa %l6, [%g1 + %g0] ASI; \
238 stxa %l7, [%g1 + %g3] ASI; \
239 add %g1, 0x10, %g1; \
240 stxa %i0, [%g1 + %g0] ASI; \
241 stxa %i1, [%g1 + %g3] ASI; \
242 add %g1, 0x10, %g1; \
243 stxa %i2, [%g1 + %g0] ASI; \
244 stxa %i3, [%g1 + %g3] ASI; \
245 add %g1, 0x10, %g1; \
246 stxa %i4, [%g1 + %g0] ASI; \
247 stxa %i5, [%g1 + %g3] ASI; \
248 add %g1, 0x10, %g1; \
249 stxa %i6, [%g1 + %g0] ASI; \
250 stxa %i7, [%g1 + %g3] ASI; \
251 saved; \
252 retry; nop; nop; \
253 b,a,pt %xcc, spill_fixup_dax; \
254 b,a,pt %xcc, spill_fixup_mna; \
255 b,a,pt %xcc, spill_fixup;
256
257/* Normal 32bit spill */
258#define SPILL_2_GENERIC(ASI) \
259 srl %sp, 0, %sp; \
260 stwa %l0, [%sp + %g0] ASI; \
261 mov 0x04, %g3; \
262 stwa %l1, [%sp + %g3] ASI; \
263 add %sp, 0x08, %g1; \
264 stwa %l2, [%g1 + %g0] ASI; \
265 stwa %l3, [%g1 + %g3] ASI; \
266 add %g1, 0x08, %g1; \
267 stwa %l4, [%g1 + %g0] ASI; \
268 stwa %l5, [%g1 + %g3] ASI; \
269 add %g1, 0x08, %g1; \
270 stwa %l6, [%g1 + %g0] ASI; \
271 stwa %l7, [%g1 + %g3] ASI; \
272 add %g1, 0x08, %g1; \
273 stwa %i0, [%g1 + %g0] ASI; \
274 stwa %i1, [%g1 + %g3] ASI; \
275 add %g1, 0x08, %g1; \
276 stwa %i2, [%g1 + %g0] ASI; \
277 stwa %i3, [%g1 + %g3] ASI; \
278 add %g1, 0x08, %g1; \
279 stwa %i4, [%g1 + %g0] ASI; \
280 stwa %i5, [%g1 + %g3] ASI; \
281 add %g1, 0x08, %g1; \
282 stwa %i6, [%g1 + %g0] ASI; \
283 stwa %i7, [%g1 + %g3] ASI; \
284 saved; \
285 retry; nop; nop; \
286 b,a,pt %xcc, spill_fixup_dax; \
287 b,a,pt %xcc, spill_fixup_mna; \
288 b,a,pt %xcc, spill_fixup;
289
290#define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
291#define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
292#define SPILL_3_NORMAL SPILL_0_NORMAL
293#define SPILL_4_NORMAL SPILL_0_NORMAL
294#define SPILL_5_NORMAL SPILL_0_NORMAL
295#define SPILL_6_NORMAL SPILL_0_NORMAL
296#define SPILL_7_NORMAL SPILL_0_NORMAL
297
298#define SPILL_0_OTHER SPILL_0_NORMAL
299#define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
300#define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
301#define SPILL_3_OTHER SPILL_3_NORMAL
302#define SPILL_4_OTHER SPILL_4_NORMAL
303#define SPILL_5_OTHER SPILL_5_NORMAL
304#define SPILL_6_OTHER SPILL_6_NORMAL
305#define SPILL_7_OTHER SPILL_7_NORMAL
306
307/* Normal kernel fill */
308#define FILL_0_NORMAL \
309 ldx [%sp + STACK_BIAS + 0x00], %l0; \
310 ldx [%sp + STACK_BIAS + 0x08], %l1; \
311 ldx [%sp + STACK_BIAS + 0x10], %l2; \
312 ldx [%sp + STACK_BIAS + 0x18], %l3; \
313 ldx [%sp + STACK_BIAS + 0x20], %l4; \
314 ldx [%sp + STACK_BIAS + 0x28], %l5; \
315 ldx [%sp + STACK_BIAS + 0x30], %l6; \
316 ldx [%sp + STACK_BIAS + 0x38], %l7; \
317 ldx [%sp + STACK_BIAS + 0x40], %i0; \
318 ldx [%sp + STACK_BIAS + 0x48], %i1; \
319 ldx [%sp + STACK_BIAS + 0x50], %i2; \
320 ldx [%sp + STACK_BIAS + 0x58], %i3; \
321 ldx [%sp + STACK_BIAS + 0x60], %i4; \
322 ldx [%sp + STACK_BIAS + 0x68], %i5; \
323 ldx [%sp + STACK_BIAS + 0x70], %i6; \
324 ldx [%sp + STACK_BIAS + 0x78], %i7; \
325 restored; retry; nop; nop; nop; nop; nop; nop; \
326 nop; nop; nop; nop; nop; nop; nop; nop;
327
328/* Normal 64bit fill */
329#define FILL_1_GENERIC(ASI) \
330 add %sp, STACK_BIAS + 0x00, %g1; \
331 ldxa [%g1 + %g0] ASI, %l0; \
332 mov 0x08, %g2; \
333 mov 0x10, %g3; \
334 ldxa [%g1 + %g2] ASI, %l1; \
335 mov 0x18, %g5; \
336 ldxa [%g1 + %g3] ASI, %l2; \
337 ldxa [%g1 + %g5] ASI, %l3; \
338 add %g1, 0x20, %g1; \
339 ldxa [%g1 + %g0] ASI, %l4; \
340 ldxa [%g1 + %g2] ASI, %l5; \
341 ldxa [%g1 + %g3] ASI, %l6; \
342 ldxa [%g1 + %g5] ASI, %l7; \
343 add %g1, 0x20, %g1; \
344 ldxa [%g1 + %g0] ASI, %i0; \
345 ldxa [%g1 + %g2] ASI, %i1; \
346 ldxa [%g1 + %g3] ASI, %i2; \
347 ldxa [%g1 + %g5] ASI, %i3; \
348 add %g1, 0x20, %g1; \
349 ldxa [%g1 + %g0] ASI, %i4; \
350 ldxa [%g1 + %g2] ASI, %i5; \
351 ldxa [%g1 + %g3] ASI, %i6; \
352 ldxa [%g1 + %g5] ASI, %i7; \
353 restored; \
354 retry; nop; nop; nop; nop; \
355 b,a,pt %xcc, fill_fixup_dax; \
356 b,a,pt %xcc, fill_fixup_mna; \
357 b,a,pt %xcc, fill_fixup;
358
359/* Normal 32bit fill */
360#define FILL_2_GENERIC(ASI) \
361 srl %sp, 0, %sp; \
362 lduwa [%sp + %g0] ASI, %l0; \
363 mov 0x04, %g2; \
364 mov 0x08, %g3; \
365 lduwa [%sp + %g2] ASI, %l1; \
366 mov 0x0c, %g5; \
367 lduwa [%sp + %g3] ASI, %l2; \
368 lduwa [%sp + %g5] ASI, %l3; \
369 add %sp, 0x10, %g1; \
370 lduwa [%g1 + %g0] ASI, %l4; \
371 lduwa [%g1 + %g2] ASI, %l5; \
372 lduwa [%g1 + %g3] ASI, %l6; \
373 lduwa [%g1 + %g5] ASI, %l7; \
374 add %g1, 0x10, %g1; \
375 lduwa [%g1 + %g0] ASI, %i0; \
376 lduwa [%g1 + %g2] ASI, %i1; \
377 lduwa [%g1 + %g3] ASI, %i2; \
378 lduwa [%g1 + %g5] ASI, %i3; \
379 add %g1, 0x10, %g1; \
380 lduwa [%g1 + %g0] ASI, %i4; \
381 lduwa [%g1 + %g2] ASI, %i5; \
382 lduwa [%g1 + %g3] ASI, %i6; \
383 lduwa [%g1 + %g5] ASI, %i7; \
384 restored; \
385 retry; nop; nop; nop; nop; \
386 b,a,pt %xcc, fill_fixup_dax; \
387 b,a,pt %xcc, fill_fixup_mna; \
388 b,a,pt %xcc, fill_fixup;
389
390#define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
391#define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
392#define FILL_3_NORMAL FILL_0_NORMAL
393#define FILL_4_NORMAL FILL_0_NORMAL
394#define FILL_5_NORMAL FILL_0_NORMAL
395#define FILL_6_NORMAL FILL_0_NORMAL
396#define FILL_7_NORMAL FILL_0_NORMAL
397
398#define FILL_0_OTHER FILL_0_NORMAL
399#define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
400#define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
401#define FILL_3_OTHER FILL_3_NORMAL
402#define FILL_4_OTHER FILL_4_NORMAL
403#define FILL_5_OTHER FILL_5_NORMAL
404#define FILL_6_OTHER FILL_6_NORMAL
405#define FILL_7_OTHER FILL_7_NORMAL
406
407#endif /* !(_SPARC64_TTABLE_H) */
diff --git a/include/asm-sparc64/types.h b/include/asm-sparc64/types.h
new file mode 100644
index 000000000000..6248ed1a9a7a
--- /dev/null
+++ b/include/asm-sparc64/types.h
@@ -0,0 +1,65 @@
1/* $Id: types.h,v 1.4 2001/10/09 02:24:35 davem Exp $ */
2#ifndef _SPARC64_TYPES_H
3#define _SPARC64_TYPES_H
4
5/*
6 * This file is never included by application software unless
7 * explicitly requested (e.g., via linux/types.h) in which case the
8 * application is Linux specific so (user-) name space pollution is
9 * not a major issue. However, for interoperability, libraries still
10 * need to be careful to avoid a name clashes.
11 */
12
13#ifndef __ASSEMBLY__
14
15typedef unsigned short umode_t;
16
17/*
18 * _xx is ok: it doesn't pollute the POSIX namespace. Use these in the
19 * header files exported to user space.
20 */
21
22typedef __signed__ char __s8;
23typedef unsigned char __u8;
24
25typedef __signed__ short __s16;
26typedef unsigned short __u16;
27
28typedef __signed__ int __s32;
29typedef unsigned int __u32;
30
31typedef __signed__ long __s64;
32typedef unsigned long __u64;
33
34#endif /* __ASSEMBLY__ */
35
36#ifdef __KERNEL__
37
38#define BITS_PER_LONG 64
39
40#ifndef __ASSEMBLY__
41
42typedef __signed__ char s8;
43typedef unsigned char u8;
44
45typedef __signed__ short s16;
46typedef unsigned short u16;
47
48typedef __signed__ int s32;
49typedef unsigned int u32;
50
51typedef __signed__ long s64;
52typedef unsigned long u64;
53
54/* Dma addresses come in generic and 64-bit flavours. */
55
56typedef u32 dma_addr_t;
57typedef u64 dma64_addr_t;
58
59typedef unsigned short kmem_bufctl_t;
60
61#endif /* __ASSEMBLY__ */
62
63#endif /* __KERNEL__ */
64
65#endif /* defined(_SPARC64_TYPES_H) */
diff --git a/include/asm-sparc64/uaccess.h b/include/asm-sparc64/uaccess.h
new file mode 100644
index 000000000000..5690142f82de
--- /dev/null
+++ b/include/asm-sparc64/uaccess.h
@@ -0,0 +1,335 @@
1/* $Id: uaccess.h,v 1.35 2002/02/09 19:49:31 davem Exp $ */
2#ifndef _ASM_UACCESS_H
3#define _ASM_UACCESS_H
4
5/*
6 * User space memory access functions
7 */
8
9#ifdef __KERNEL__
10#include <linux/compiler.h>
11#include <linux/sched.h>
12#include <linux/string.h>
13#include <asm/a.out.h>
14#include <asm/asi.h>
15#include <asm/system.h>
16#include <asm/spitfire.h>
17#include <asm-generic/uaccess.h>
18#endif
19
20#ifndef __ASSEMBLY__
21
22/*
23 * Sparc64 is segmented, though more like the M68K than the I386.
24 * We use the secondary ASI to address user memory, which references a
25 * completely different VM map, thus there is zero chance of the user
26 * doing something queer and tricking us into poking kernel memory.
27 *
28 * What is left here is basically what is needed for the other parts of
29 * the kernel that expect to be able to manipulate, erum, "segments".
30 * Or perhaps more properly, permissions.
31 *
32 * "For historical reasons, these macros are grossly misnamed." -Linus
33 */
34
35#define KERNEL_DS ((mm_segment_t) { ASI_P })
36#define USER_DS ((mm_segment_t) { ASI_AIUS }) /* har har har */
37
38#define VERIFY_READ 0
39#define VERIFY_WRITE 1
40
41#define get_fs() ((mm_segment_t) { get_thread_current_ds() })
42#define get_ds() (KERNEL_DS)
43
44#define segment_eq(a,b) ((a).seg == (b).seg)
45
46#define set_fs(val) \
47do { \
48 set_thread_current_ds((val).seg); \
49 __asm__ __volatile__ ("wr %%g0, %0, %%asi" : : "r" ((val).seg)); \
50} while(0)
51
52static inline int __access_ok(const void __user * addr, unsigned long size)
53{
54 return 1;
55}
56
57static inline int access_ok(int type, const void __user * addr, unsigned long size)
58{
59 return 1;
60}
61
62/* this function will go away soon - use access_ok() instead */
63static inline int __deprecated verify_area(int type, const void __user * addr, unsigned long size)
64{
65 return 0;
66}
67
68/*
69 * The exception table consists of pairs of addresses: the first is the
70 * address of an instruction that is allowed to fault, and the second is
71 * the address at which the program should continue. No registers are
72 * modified, so it is entirely up to the continuation code to figure out
73 * what to do.
74 *
75 * All the routines below use bits of fixup code that are out of line
76 * with the main instruction path. This means when everything is well,
77 * we don't even have to jump over them. Further, they do not intrude
78 * on our cache or tlb entries.
79 *
80 * There is a special way how to put a range of potentially faulting
81 * insns (like twenty ldd/std's with now intervening other instructions)
82 * You specify address of first in insn and 0 in fixup and in the next
83 * exception_table_entry you specify last potentially faulting insn + 1
84 * and in fixup the routine which should handle the fault.
85 * That fixup code will get
86 * (faulting_insn_address - first_insn_in_the_range_address)/4
87 * in %g2 (ie. index of the faulting instruction in the range).
88 */
89
90struct exception_table_entry
91{
92 unsigned insn, fixup;
93};
94
95/* Special exable search, which handles ranges. Returns fixup */
96unsigned long search_extables_range(unsigned long addr, unsigned long *g2);
97
98extern void __ret_efault(void);
99
100/* Uh, these should become the main single-value transfer routines..
101 * They automatically use the right size if we just have the right
102 * pointer type..
103 *
104 * This gets kind of ugly. We want to return _two_ values in "get_user()"
105 * and yet we don't want to do any pointers, because that is too much
106 * of a performance impact. Thus we have a few rather ugly macros here,
107 * and hide all the ugliness from the user.
108 */
109#define put_user(x,ptr) ({ \
110unsigned long __pu_addr = (unsigned long)(ptr); \
111__chk_user_ptr(ptr); \
112__put_user_nocheck((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); })
113
114#define get_user(x,ptr) ({ \
115unsigned long __gu_addr = (unsigned long)(ptr); \
116__chk_user_ptr(ptr); \
117__get_user_nocheck((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); })
118
119#define __put_user(x,ptr) put_user(x,ptr)
120#define __get_user(x,ptr) get_user(x,ptr)
121
122struct __large_struct { unsigned long buf[100]; };
123#define __m(x) ((struct __large_struct *)(x))
124
125#define __put_user_nocheck(data,addr,size) ({ \
126register int __pu_ret; \
127switch (size) { \
128case 1: __put_user_asm(data,b,addr,__pu_ret); break; \
129case 2: __put_user_asm(data,h,addr,__pu_ret); break; \
130case 4: __put_user_asm(data,w,addr,__pu_ret); break; \
131case 8: __put_user_asm(data,x,addr,__pu_ret); break; \
132default: __pu_ret = __put_user_bad(); break; \
133} __pu_ret; })
134
135#define __put_user_nocheck_ret(data,addr,size,retval) ({ \
136register int __foo __asm__ ("l1"); \
137switch (size) { \
138case 1: __put_user_asm_ret(data,b,addr,retval,__foo); break; \
139case 2: __put_user_asm_ret(data,h,addr,retval,__foo); break; \
140case 4: __put_user_asm_ret(data,w,addr,retval,__foo); break; \
141case 8: __put_user_asm_ret(data,x,addr,retval,__foo); break; \
142default: if (__put_user_bad()) return retval; break; \
143} })
144
145#define __put_user_asm(x,size,addr,ret) \
146__asm__ __volatile__( \
147 "/* Put user asm, inline. */\n" \
148"1:\t" "st"#size "a %1, [%2] %%asi\n\t" \
149 "clr %0\n" \
150"2:\n\n\t" \
151 ".section .fixup,#alloc,#execinstr\n\t" \
152 ".align 4\n" \
153"3:\n\t" \
154 "b 2b\n\t" \
155 " mov %3, %0\n\n\t" \
156 ".previous\n\t" \
157 ".section __ex_table,#alloc\n\t" \
158 ".align 4\n\t" \
159 ".word 1b, 3b\n\t" \
160 ".previous\n\n\t" \
161 : "=r" (ret) : "r" (x), "r" (__m(addr)), \
162 "i" (-EFAULT))
163
164#define __put_user_asm_ret(x,size,addr,ret,foo) \
165if (__builtin_constant_p(ret) && ret == -EFAULT) \
166__asm__ __volatile__( \
167 "/* Put user asm ret, inline. */\n" \
168"1:\t" "st"#size "a %1, [%2] %%asi\n\n\t" \
169 ".section __ex_table,#alloc\n\t" \
170 ".align 4\n\t" \
171 ".word 1b, __ret_efault\n\n\t" \
172 ".previous\n\n\t" \
173 : "=r" (foo) : "r" (x), "r" (__m(addr))); \
174else \
175__asm__ __volatile__( \
176 "/* Put user asm ret, inline. */\n" \
177"1:\t" "st"#size "a %1, [%2] %%asi\n\n\t" \
178 ".section .fixup,#alloc,#execinstr\n\t" \
179 ".align 4\n" \
180"3:\n\t" \
181 "ret\n\t" \
182 " restore %%g0, %3, %%o0\n\n\t" \
183 ".previous\n\t" \
184 ".section __ex_table,#alloc\n\t" \
185 ".align 4\n\t" \
186 ".word 1b, 3b\n\n\t" \
187 ".previous\n\n\t" \
188 : "=r" (foo) : "r" (x), "r" (__m(addr)), \
189 "i" (ret))
190
191extern int __put_user_bad(void);
192
193#define __get_user_nocheck(data,addr,size,type) ({ \
194register int __gu_ret; \
195register unsigned long __gu_val; \
196switch (size) { \
197case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \
198case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \
199case 4: __get_user_asm(__gu_val,uw,addr,__gu_ret); break; \
200case 8: __get_user_asm(__gu_val,x,addr,__gu_ret); break; \
201default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \
202} data = (type) __gu_val; __gu_ret; })
203
204#define __get_user_nocheck_ret(data,addr,size,type,retval) ({ \
205register unsigned long __gu_val __asm__ ("l1"); \
206switch (size) { \
207case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \
208case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \
209case 4: __get_user_asm_ret(__gu_val,uw,addr,retval); break; \
210case 8: __get_user_asm_ret(__gu_val,x,addr,retval); break; \
211default: if (__get_user_bad()) return retval; \
212} data = (type) __gu_val; })
213
214#define __get_user_asm(x,size,addr,ret) \
215__asm__ __volatile__( \
216 "/* Get user asm, inline. */\n" \
217"1:\t" "ld"#size "a [%2] %%asi, %1\n\t" \
218 "clr %0\n" \
219"2:\n\n\t" \
220 ".section .fixup,#alloc,#execinstr\n\t" \
221 ".align 4\n" \
222"3:\n\t" \
223 "clr %1\n\t" \
224 "b 2b\n\t" \
225 " mov %3, %0\n\n\t" \
226 ".previous\n\t" \
227 ".section __ex_table,#alloc\n\t" \
228 ".align 4\n\t" \
229 ".word 1b, 3b\n\n\t" \
230 ".previous\n\t" \
231 : "=r" (ret), "=r" (x) : "r" (__m(addr)), \
232 "i" (-EFAULT))
233
234#define __get_user_asm_ret(x,size,addr,retval) \
235if (__builtin_constant_p(retval) && retval == -EFAULT) \
236__asm__ __volatile__( \
237 "/* Get user asm ret, inline. */\n" \
238"1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \
239 ".section __ex_table,#alloc\n\t" \
240 ".align 4\n\t" \
241 ".word 1b,__ret_efault\n\n\t" \
242 ".previous\n\t" \
243 : "=r" (x) : "r" (__m(addr))); \
244else \
245__asm__ __volatile__( \
246 "/* Get user asm ret, inline. */\n" \
247"1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \
248 ".section .fixup,#alloc,#execinstr\n\t" \
249 ".align 4\n" \
250"3:\n\t" \
251 "ret\n\t" \
252 " restore %%g0, %2, %%o0\n\n\t" \
253 ".previous\n\t" \
254 ".section __ex_table,#alloc\n\t" \
255 ".align 4\n\t" \
256 ".word 1b, 3b\n\n\t" \
257 ".previous\n\t" \
258 : "=r" (x) : "r" (__m(addr)), "i" (retval))
259
260extern int __get_user_bad(void);
261
262extern unsigned long __must_check ___copy_from_user(void *to,
263 const void __user *from,
264 unsigned long size);
265extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
266 unsigned long size);
267static inline unsigned long __must_check
268copy_from_user(void *to, const void __user *from, unsigned long size)
269{
270 unsigned long ret = ___copy_from_user(to, from, size);
271
272 if (ret)
273 ret = copy_from_user_fixup(to, from, size);
274 return ret;
275}
276#define __copy_from_user copy_from_user
277
278extern unsigned long __must_check ___copy_to_user(void __user *to,
279 const void *from,
280 unsigned long size);
281extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
282 unsigned long size);
283static inline unsigned long __must_check
284copy_to_user(void __user *to, const void *from, unsigned long size)
285{
286 unsigned long ret = ___copy_to_user(to, from, size);
287
288 if (ret)
289 ret = copy_to_user_fixup(to, from, size);
290 return ret;
291}
292#define __copy_to_user copy_to_user
293
294extern unsigned long __must_check ___copy_in_user(void __user *to,
295 const void __user *from,
296 unsigned long size);
297extern unsigned long copy_in_user_fixup(void __user *to, void __user *from,
298 unsigned long size);
299static inline unsigned long __must_check
300copy_in_user(void __user *to, void __user *from, unsigned long size)
301{
302 unsigned long ret = ___copy_in_user(to, from, size);
303
304 if (ret)
305 ret = copy_in_user_fixup(to, from, size);
306 return ret;
307}
308#define __copy_in_user copy_in_user
309
310extern unsigned long __must_check __bzero_noasi(void __user *, unsigned long);
311
312static inline unsigned long __must_check
313__clear_user(void __user *addr, unsigned long size)
314{
315
316 return __bzero_noasi(addr, size);
317}
318
319#define clear_user __clear_user
320
321extern long __must_check __strncpy_from_user(char *dest, const char __user *src, long count);
322
323#define strncpy_from_user __strncpy_from_user
324
325extern long __strlen_user(const char __user *);
326extern long __strnlen_user(const char __user *, long len);
327
328#define strlen_user __strlen_user
329#define strnlen_user __strnlen_user
330#define __copy_to_user_inatomic __copy_to_user
331#define __copy_from_user_inatomic __copy_from_user
332
333#endif /* __ASSEMBLY__ */
334
335#endif /* _ASM_UACCESS_H */
diff --git a/include/asm-sparc64/uctx.h b/include/asm-sparc64/uctx.h
new file mode 100644
index 000000000000..6eaf16ef23f6
--- /dev/null
+++ b/include/asm-sparc64/uctx.h
@@ -0,0 +1,71 @@
1/* $Id: uctx.h,v 1.1 1997/06/18 16:51:58 davem Exp $
2 * uctx.h: Sparc64 {set,get}context() register state layouts.
3 *
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef __SPARC64_UCTX_H
8#define __SPARC64_UCTX_H
9
10#define MC_TSTATE 0
11#define MC_PC 1
12#define MC_NPC 2
13#define MC_Y 3
14#define MC_G1 4
15#define MC_G2 5
16#define MC_G3 6
17#define MC_G4 7
18#define MC_G5 8
19#define MC_G6 9
20#define MC_G7 10
21#define MC_O0 11
22#define MC_O1 12
23#define MC_O2 13
24#define MC_O3 14
25#define MC_O4 15
26#define MC_O5 16
27#define MC_O6 17
28#define MC_O7 18
29#define MC_NGREG 19
30
31typedef unsigned long mc_greg_t;
32typedef mc_greg_t mc_gregset_t[MC_NGREG];
33
34#define MC_MAXFPQ 16
35struct mc_fq {
36 unsigned long *mcfq_addr;
37 unsigned int mcfq_insn;
38};
39
40struct mc_fpu {
41 union {
42 unsigned int sregs[32];
43 unsigned long dregs[32];
44 long double qregs[16];
45 } mcfpu_fregs;
46 unsigned long mcfpu_fsr;
47 unsigned long mcfpu_fprs;
48 unsigned long mcfpu_gsr;
49 struct mc_fq *mcfpu_fq;
50 unsigned char mcfpu_qcnt;
51 unsigned char mcfpu_qentsz;
52 unsigned char mcfpu_enab;
53};
54typedef struct mc_fpu mc_fpu_t;
55
56typedef struct {
57 mc_gregset_t mc_gregs;
58 mc_greg_t mc_fp;
59 mc_greg_t mc_i7;
60 mc_fpu_t mc_fpregs;
61} mcontext_t;
62
63struct ucontext {
64 struct ucontext *uc_link;
65 unsigned long uc_flags;
66 sigset_t uc_sigmask;
67 mcontext_t uc_mcontext;
68};
69typedef struct ucontext ucontext_t;
70
71#endif /* __SPARC64_UCTX_H */
diff --git a/include/asm-sparc64/unaligned.h b/include/asm-sparc64/unaligned.h
new file mode 100644
index 000000000000..1ed3ba537772
--- /dev/null
+++ b/include/asm-sparc64/unaligned.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_SPARC64_UNALIGNED_H_
2#define _ASM_SPARC64_UNALIGNED_H_
3
4#include <asm-generic/unaligned.h>
5
6#endif /* _ASM_SPARC64_UNALIGNED_H */
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
new file mode 100644
index 000000000000..3c00065eea80
--- /dev/null
+++ b/include/asm-sparc64/unistd.h
@@ -0,0 +1,514 @@
1/* $Id: unistd.h,v 1.50 2002/02/08 03:57:18 davem Exp $ */
2#ifndef _SPARC64_UNISTD_H
3#define _SPARC64_UNISTD_H
4
5/*
6 * System calls under the Sparc.
7 *
8 * Don't be scared by the ugly clobbers, it is the only way I can
9 * think of right now to force the arguments into fixed registers
10 * before the trap into the system call with gcc 'asm' statements.
11 *
12 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
13 *
14 * SunOS compatibility based upon preliminary work which is:
15 *
16 * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu)
17 */
18
19#define __NR_restart_syscall 0 /* Linux Specific */
20#define __NR_exit 1 /* Common */
21#define __NR_fork 2 /* Common */
22#define __NR_read 3 /* Common */
23#define __NR_write 4 /* Common */
24#define __NR_open 5 /* Common */
25#define __NR_close 6 /* Common */
26#define __NR_wait4 7 /* Common */
27#define __NR_creat 8 /* Common */
28#define __NR_link 9 /* Common */
29#define __NR_unlink 10 /* Common */
30#define __NR_execv 11 /* SunOS Specific */
31#define __NR_chdir 12 /* Common */
32#define __NR_chown 13 /* Common */
33#define __NR_mknod 14 /* Common */
34#define __NR_chmod 15 /* Common */
35#define __NR_lchown 16 /* Common */
36#define __NR_brk 17 /* Common */
37#define __NR_perfctr 18 /* Performance counter operations */
38#define __NR_lseek 19 /* Common */
39#define __NR_getpid 20 /* Common */
40#define __NR_capget 21 /* Linux Specific */
41#define __NR_capset 22 /* Linux Specific */
42#define __NR_setuid 23 /* Implemented via setreuid in SunOS */
43#define __NR_getuid 24 /* Common */
44/* #define __NR_time alias 25 ENOSYS under SunOS */
45#define __NR_ptrace 26 /* Common */
46#define __NR_alarm 27 /* Implemented via setitimer in SunOS */
47#define __NR_sigaltstack 28 /* Common */
48#define __NR_pause 29 /* Is sigblock(0)->sigpause() in SunOS */
49#define __NR_utime 30 /* Implemented via utimes() under SunOS */
50/* #define __NR_lchown32 31 Linux sparc32 specific */
51/* #define __NR_fchown32 32 Linux sparc32 specific */
52#define __NR_access 33 /* Common */
53#define __NR_nice 34 /* Implemented via get/setpriority() in SunOS */
54/* #define __NR_chown32 35 Linux sparc32 specific */
55#define __NR_sync 36 /* Common */
56#define __NR_kill 37 /* Common */
57#define __NR_stat 38 /* Common */
58#define __NR_sendfile 39 /* Linux Specific */
59#define __NR_lstat 40 /* Common */
60#define __NR_dup 41 /* Common */
61#define __NR_pipe 42 /* Common */
62#define __NR_times 43 /* Implemented via getrusage() in SunOS */
63/* #define __NR_getuid32 44 Linux sparc32 specific */
64#define __NR_umount2 45 /* Linux Specific */
65#define __NR_setgid 46 /* Implemented via setregid() in SunOS */
66#define __NR_getgid 47 /* Common */
67#define __NR_signal 48 /* Implemented via sigvec() in SunOS */
68#define __NR_geteuid 49 /* SunOS calls getuid() */
69#define __NR_getegid 50 /* SunOS calls getgid() */
70#define __NR_acct 51 /* Common */
71#define __NR_memory_ordering 52 /* Linux Specific */
72/* #define __NR_getgid32 53 Linux sparc32 specific */
73#define __NR_ioctl 54 /* Common */
74#define __NR_reboot 55 /* Common */
75/* #define __NR_mmap2 56 Linux sparc32 Specific */
76#define __NR_symlink 57 /* Common */
77#define __NR_readlink 58 /* Common */
78#define __NR_execve 59 /* Common */
79#define __NR_umask 60 /* Common */
80#define __NR_chroot 61 /* Common */
81#define __NR_fstat 62 /* Common */
82/* #define __NR_fstat64 63 Linux sparc32 Specific */
83#define __NR_getpagesize 64 /* Common */
84#define __NR_msync 65 /* Common in newer 1.3.x revs... */
85#define __NR_vfork 66 /* Common */
86#define __NR_pread64 67 /* Linux Specific */
87#define __NR_pwrite64 68 /* Linux Specific */
88/* #define __NR_geteuid32 69 Linux sparc32, sbrk under SunOS */
89/* #define __NR_getegid32 70 Linux sparc32, sstk under SunOS */
90#define __NR_mmap 71 /* Common */
91/* #define __NR_setreuid32 72 Linux sparc32, vadvise under SunOS */
92#define __NR_munmap 73 /* Common */
93#define __NR_mprotect 74 /* Common */
94#define __NR_madvise 75 /* Common */
95#define __NR_vhangup 76 /* Common */
96/* #define __NR_truncate64 77 Linux sparc32 Specific */
97#define __NR_mincore 78 /* Common */
98#define __NR_getgroups 79 /* Common */
99#define __NR_setgroups 80 /* Common */
100#define __NR_getpgrp 81 /* Common */
101/* #define __NR_setgroups32 82 Linux sparc32, setpgrp under SunOS */
102#define __NR_setitimer 83 /* Common */
103/* #define __NR_ftruncate64 84 Linux sparc32 Specific */
104#define __NR_swapon 85 /* Common */
105#define __NR_getitimer 86 /* Common */
106/* #define __NR_setuid32 87 Linux sparc32, gethostname under SunOS */
107#define __NR_sethostname 88 /* Common */
108/* #define __NR_setgid32 89 Linux sparc32, getdtablesize under SunOS */
109#define __NR_dup2 90 /* Common */
110/* #define __NR_setfsuid32 91 Linux sparc32, getdopt under SunOS */
111#define __NR_fcntl 92 /* Common */
112#define __NR_select 93 /* Common */
113/* #define __NR_setfsgid32 94 Linux sparc32, setdopt under SunOS */
114#define __NR_fsync 95 /* Common */
115#define __NR_setpriority 96 /* Common */
116#define __NR_socket 97 /* Common */
117#define __NR_connect 98 /* Common */
118#define __NR_accept 99 /* Common */
119#define __NR_getpriority 100 /* Common */
120#define __NR_rt_sigreturn 101 /* Linux Specific */
121#define __NR_rt_sigaction 102 /* Linux Specific */
122#define __NR_rt_sigprocmask 103 /* Linux Specific */
123#define __NR_rt_sigpending 104 /* Linux Specific */
124#define __NR_rt_sigtimedwait 105 /* Linux Specific */
125#define __NR_rt_sigqueueinfo 106 /* Linux Specific */
126#define __NR_rt_sigsuspend 107 /* Linux Specific */
127#define __NR_setresuid 108 /* Linux Specific, sigvec under SunOS */
128#define __NR_getresuid 109 /* Linux Specific, sigblock under SunOS */
129#define __NR_setresgid 110 /* Linux Specific, sigsetmask under SunOS */
130#define __NR_getresgid 111 /* Linux Specific, sigpause under SunOS */
131/* #define __NR_setregid32 75 Linux sparc32, sigstack under SunOS */
132#define __NR_recvmsg 113 /* Common */
133#define __NR_sendmsg 114 /* Common */
134/* #define __NR_getgroups32 115 Linux sparc32, vtrace under SunOS */
135#define __NR_gettimeofday 116 /* Common */
136#define __NR_getrusage 117 /* Common */
137#define __NR_getsockopt 118 /* Common */
138#define __NR_getcwd 119 /* Linux Specific */
139#define __NR_readv 120 /* Common */
140#define __NR_writev 121 /* Common */
141#define __NR_settimeofday 122 /* Common */
142#define __NR_fchown 123 /* Common */
143#define __NR_fchmod 124 /* Common */
144#define __NR_recvfrom 125 /* Common */
145#define __NR_setreuid 126 /* Common */
146#define __NR_setregid 127 /* Common */
147#define __NR_rename 128 /* Common */
148#define __NR_truncate 129 /* Common */
149#define __NR_ftruncate 130 /* Common */
150#define __NR_flock 131 /* Common */
151/* #define __NR_lstat64 132 Linux sparc32 Specific */
152#define __NR_sendto 133 /* Common */
153#define __NR_shutdown 134 /* Common */
154#define __NR_socketpair 135 /* Common */
155#define __NR_mkdir 136 /* Common */
156#define __NR_rmdir 137 /* Common */
157#define __NR_utimes 138 /* SunOS Specific */
158/* #define __NR_stat64 139 Linux sparc32 Specific */
159#define __NR_sendfile64 140 /* adjtime under SunOS */
160#define __NR_getpeername 141 /* Common */
161#define __NR_futex 142 /* gethostid under SunOS */
162#define __NR_gettid 143 /* ENOSYS under SunOS */
163#define __NR_getrlimit 144 /* Common */
164#define __NR_setrlimit 145 /* Common */
165#define __NR_pivot_root 146 /* Linux Specific, killpg under SunOS */
166#define __NR_prctl 147 /* ENOSYS under SunOS */
167#define __NR_pciconfig_read 148 /* ENOSYS under SunOS */
168#define __NR_pciconfig_write 149 /* ENOSYS under SunOS */
169#define __NR_getsockname 150 /* Common */
170/* #define __NR_getmsg 151 SunOS Specific */
171/* #define __NR_putmsg 152 SunOS Specific */
172#define __NR_poll 153 /* Common */
173#define __NR_getdents64 154 /* Linux specific */
174/* #define __NR_fcntl64 155 Linux sparc32 Specific */
175/* #define __NR_getdirentries 156 SunOS Specific */
176#define __NR_statfs 157 /* Common */
177#define __NR_fstatfs 158 /* Common */
178#define __NR_umount 159 /* Common */
179#define __NR_sched_set_affinity 160 /* Linux specific, async_daemon under SunOS */
180#define __NR_sched_get_affinity 161 /* Linux specific, getfh under SunOS */
181#define __NR_getdomainname 162 /* SunOS Specific */
182#define __NR_setdomainname 163 /* Common */
183#define __NR_utrap_install 164 /* SYSV ABI/v9 required */
184#define __NR_quotactl 165 /* Common */
185#define __NR_set_tid_address 166 /* Linux specific, exportfs under SunOS */
186#define __NR_mount 167 /* Common */
187#define __NR_ustat 168 /* Common */
188#define __NR_setxattr 169 /* SunOS: semsys */
189#define __NR_lsetxattr 170 /* SunOS: msgsys */
190#define __NR_fsetxattr 171 /* SunOS: shmsys */
191#define __NR_getxattr 172 /* SunOS: auditsys */
192#define __NR_lgetxattr 173 /* SunOS: rfssys */
193#define __NR_getdents 174 /* Common */
194#define __NR_setsid 175 /* Common */
195#define __NR_fchdir 176 /* Common */
196#define __NR_fgetxattr 177 /* SunOS: fchroot */
197#define __NR_listxattr 178 /* SunOS: vpixsys */
198#define __NR_llistxattr 179 /* SunOS: aioread */
199#define __NR_flistxattr 180 /* SunOS: aiowrite */
200#define __NR_removexattr 181 /* SunOS: aiowait */
201#define __NR_lremovexattr 182 /* SunOS: aiocancel */
202#define __NR_sigpending 183 /* Common */
203#define __NR_query_module 184 /* Linux Specific */
204#define __NR_setpgid 185 /* Common */
205#define __NR_fremovexattr 186 /* SunOS: pathconf */
206#define __NR_tkill 187 /* SunOS: fpathconf */
207#define __NR_exit_group 188 /* Linux specific, sysconf undef SunOS */
208#define __NR_uname 189 /* Linux Specific */
209#define __NR_init_module 190 /* Linux Specific */
210#define __NR_personality 191 /* Linux Specific */
211#define __NR_remap_file_pages 192 /* Linux Specific */
212#define __NR_epoll_create 193 /* Linux Specific */
213#define __NR_epoll_ctl 194 /* Linux Specific */
214#define __NR_epoll_wait 195 /* Linux Specific */
215/* #define __NR_ulimit 196 Linux Specific */
216#define __NR_getppid 197 /* Linux Specific */
217#define __NR_sigaction 198 /* Linux Specific */
218#define __NR_sgetmask 199 /* Linux Specific */
219#define __NR_ssetmask 200 /* Linux Specific */
220#define __NR_sigsuspend 201 /* Linux Specific */
221#define __NR_oldlstat 202 /* Linux Specific */
222#define __NR_uselib 203 /* Linux Specific */
223#define __NR_readdir 204 /* Linux Specific */
224#define __NR_readahead 205 /* Linux Specific */
225#define __NR_socketcall 206 /* Linux Specific */
226#define __NR_syslog 207 /* Linux Specific */
227#define __NR_lookup_dcookie 208 /* Linux Specific */
228#define __NR_fadvise64 209 /* Linux Specific */
229#define __NR_fadvise64_64 210 /* Linux Specific */
230#define __NR_tgkill 211 /* Linux Specific */
231#define __NR_waitpid 212 /* Linux Specific */
232#define __NR_swapoff 213 /* Linux Specific */
233#define __NR_sysinfo 214 /* Linux Specific */
234#define __NR_ipc 215 /* Linux Specific */
235#define __NR_sigreturn 216 /* Linux Specific */
236#define __NR_clone 217 /* Linux Specific */
237/* #define __NR_modify_ldt 218 Linux Specific - i386 specific, unused */
238#define __NR_adjtimex 219 /* Linux Specific */
239#define __NR_sigprocmask 220 /* Linux Specific */
240#define __NR_create_module 221 /* Linux Specific */
241#define __NR_delete_module 222 /* Linux Specific */
242#define __NR_get_kernel_syms 223 /* Linux Specific */
243#define __NR_getpgid 224 /* Linux Specific */
244#define __NR_bdflush 225 /* Linux Specific */
245#define __NR_sysfs 226 /* Linux Specific */
246#define __NR_afs_syscall 227 /* Linux Specific */
247#define __NR_setfsuid 228 /* Linux Specific */
248#define __NR_setfsgid 229 /* Linux Specific */
249#define __NR__newselect 230 /* Linux Specific */
250#ifdef __KERNEL__
251#define __NR_time 231 /* Linux sparc32 */
252#endif
253/* #define __NR_oldstat 232 Linux Specific */
254#define __NR_stime 233 /* Linux Specific */
255#define __NR_statfs64 234 /* Linux Specific */
256#define __NR_fstatfs64 235 /* Linux Specific */
257#define __NR__llseek 236 /* Linux Specific */
258#define __NR_mlock 237
259#define __NR_munlock 238
260#define __NR_mlockall 239
261#define __NR_munlockall 240
262#define __NR_sched_setparam 241
263#define __NR_sched_getparam 242
264#define __NR_sched_setscheduler 243
265#define __NR_sched_getscheduler 244
266#define __NR_sched_yield 245
267#define __NR_sched_get_priority_max 246
268#define __NR_sched_get_priority_min 247
269#define __NR_sched_rr_get_interval 248
270#define __NR_nanosleep 249
271#define __NR_mremap 250
272#define __NR__sysctl 251
273#define __NR_getsid 252
274#define __NR_fdatasync 253
275#define __NR_nfsservctl 254
276#define __NR_aplib 255
277#define __NR_clock_settime 256
278#define __NR_clock_gettime 257
279#define __NR_clock_getres 258
280#define __NR_clock_nanosleep 259
281#define __NR_sched_getaffinity 260
282#define __NR_sched_setaffinity 261
283#define __NR_timer_settime 262
284#define __NR_timer_gettime 263
285#define __NR_timer_getoverrun 264
286#define __NR_timer_delete 265
287#define __NR_timer_create 266
288/* #define __NR_vserver 267 Reserved for VSERVER */
289#define __NR_io_setup 268
290#define __NR_io_destroy 269
291#define __NR_io_submit 270
292#define __NR_io_cancel 271
293#define __NR_io_getevents 272
294#define __NR_mq_open 273
295#define __NR_mq_unlink 274
296#define __NR_mq_timedsend 275
297#define __NR_mq_timedreceive 276
298#define __NR_mq_notify 277
299#define __NR_mq_getsetattr 278
300#define __NR_waitid 279
301/*#define __NR_sys_setaltroot 280 available (was setaltroot) */
302#define __NR_add_key 281
303#define __NR_request_key 282
304#define __NR_keyctl 283
305
306/* WARNING: You MAY NOT add syscall numbers larger than 283, since
307 * all of the syscall tables in the Sparc kernel are
308 * sized to have 283 entries (starting at zero). Therefore
309 * find a free slot in the 0-282 range.
310 */
311
312#define _syscall0(type,name) \
313type name(void) \
314{ \
315long __res; \
316register long __g1 __asm__ ("g1") = __NR_##name; \
317__asm__ __volatile__ ("t 0x6d\n\t" \
318 "sub %%g0, %%o0, %0\n\t" \
319 "movcc %%xcc, %%o0, %0\n\t" \
320 : "=r" (__res)\
321 : "r" (__g1) \
322 : "o0", "cc"); \
323if (__res >= 0) \
324 return (type) __res; \
325errno = -__res; \
326return -1; \
327}
328
329#define _syscall1(type,name,type1,arg1) \
330type name(type1 arg1) \
331{ \
332long __res; \
333register long __g1 __asm__ ("g1") = __NR_##name; \
334register long __o0 __asm__ ("o0") = (long)(arg1); \
335__asm__ __volatile__ ("t 0x6d\n\t" \
336 "sub %%g0, %%o0, %0\n\t" \
337 "movcc %%xcc, %%o0, %0\n\t" \
338 : "=r" (__res), "=&r" (__o0) \
339 : "1" (__o0), "r" (__g1) \
340 : "cc"); \
341if (__res >= 0) \
342 return (type) __res; \
343errno = -__res; \
344return -1; \
345}
346
347#define _syscall2(type,name,type1,arg1,type2,arg2) \
348type name(type1 arg1,type2 arg2) \
349{ \
350long __res; \
351register long __g1 __asm__ ("g1") = __NR_##name; \
352register long __o0 __asm__ ("o0") = (long)(arg1); \
353register long __o1 __asm__ ("o1") = (long)(arg2); \
354__asm__ __volatile__ ("t 0x6d\n\t" \
355 "sub %%g0, %%o0, %0\n\t" \
356 "movcc %%xcc, %%o0, %0\n\t" \
357 : "=r" (__res), "=&r" (__o0) \
358 : "1" (__o0), "r" (__o1), "r" (__g1) \
359 : "cc"); \
360if (__res >= 0) \
361 return (type) __res; \
362errno = -__res; \
363return -1; \
364}
365
366#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
367type name(type1 arg1,type2 arg2,type3 arg3) \
368{ \
369long __res; \
370register long __g1 __asm__ ("g1") = __NR_##name; \
371register long __o0 __asm__ ("o0") = (long)(arg1); \
372register long __o1 __asm__ ("o1") = (long)(arg2); \
373register long __o2 __asm__ ("o2") = (long)(arg3); \
374__asm__ __volatile__ ("t 0x6d\n\t" \
375 "sub %%g0, %%o0, %0\n\t" \
376 "movcc %%xcc, %%o0, %0\n\t" \
377 : "=r" (__res), "=&r" (__o0) \
378 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
379 : "cc"); \
380if (__res>=0) \
381 return (type) __res; \
382errno = -__res; \
383return -1; \
384}
385
386#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
387type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
388{ \
389long __res; \
390register long __g1 __asm__ ("g1") = __NR_##name; \
391register long __o0 __asm__ ("o0") = (long)(arg1); \
392register long __o1 __asm__ ("o1") = (long)(arg2); \
393register long __o2 __asm__ ("o2") = (long)(arg3); \
394register long __o3 __asm__ ("o3") = (long)(arg4); \
395__asm__ __volatile__ ("t 0x6d\n\t" \
396 "sub %%g0, %%o0, %0\n\t" \
397 "movcc %%xcc, %%o0, %0\n\t" \
398 : "=r" (__res), "=&r" (__o0) \
399 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
400 : "cc"); \
401if (__res>=0) \
402 return (type) __res; \
403errno = -__res; \
404return -1; \
405}
406
407#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
408 type5,arg5) \
409type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
410{ \
411long __res; \
412register long __g1 __asm__ ("g1") = __NR_##name; \
413register long __o0 __asm__ ("o0") = (long)(arg1); \
414register long __o1 __asm__ ("o1") = (long)(arg2); \
415register long __o2 __asm__ ("o2") = (long)(arg3); \
416register long __o3 __asm__ ("o3") = (long)(arg4); \
417register long __o4 __asm__ ("o4") = (long)(arg5); \
418__asm__ __volatile__ ("t 0x6d\n\t" \
419 "sub %%g0, %%o0, %0\n\t" \
420 "movcc %%xcc, %%o0, %0\n\t" \
421 : "=r" (__res), "=&r" (__o0) \
422 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
423 : "cc"); \
424if (__res>=0) \
425 return (type) __res; \
426errno = -__res; \
427return -1; \
428}
429#ifdef __KERNEL_SYSCALLS__
430
431#include <linux/compiler.h>
432#include <linux/types.h>
433
434/*
435 * we need this inline - forking from kernel space will result
436 * in NO COPY ON WRITE (!!!), until an execve is executed. This
437 * is no problem, but for the stack. This is handled by not letting
438 * main() use the stack at all after fork(). Thus, no function
439 * calls - which means inline code for fork too, as otherwise we
440 * would use the stack upon exit from 'fork()'.
441 *
442 * Actually only pause and fork are needed inline, so that there
443 * won't be any messing with the stack from main(), but we define
444 * some others too.
445 */
446#define __NR__exit __NR_exit
447static __inline__ _syscall0(pid_t,setsid)
448static __inline__ _syscall3(int,write,int,fd,__const__ char *,buf,off_t,count)
449static __inline__ _syscall3(int,read,int,fd,char *,buf,off_t,count)
450static __inline__ _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
451static __inline__ _syscall1(int,dup,int,fd)
452static __inline__ _syscall3(int,execve,__const__ char *,file,char **,argv,char **,envp)
453static __inline__ _syscall3(int,open,__const__ char *,file,int,flag,int,mode)
454static __inline__ _syscall1(int,close,int,fd)
455static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
456
457#include <linux/linkage.h>
458
459asmlinkage unsigned long sys_mmap(
460 unsigned long addr, unsigned long len,
461 unsigned long prot, unsigned long flags,
462 unsigned long fd, unsigned long off);
463struct sigaction;
464asmlinkage long sys_rt_sigaction(int sig,
465 const struct sigaction __user *act,
466 struct sigaction __user *oact,
467 void __user *restorer,
468 size_t sigsetsize);
469
470#endif /* __KERNEL_SYSCALLS__ */
471
472#ifdef __KERNEL__
473/* sysconf options, for SunOS compatibility */
474#define _SC_ARG_MAX 1
475#define _SC_CHILD_MAX 2
476#define _SC_CLK_TCK 3
477#define _SC_NGROUPS_MAX 4
478#define _SC_OPEN_MAX 5
479#define _SC_JOB_CONTROL 6
480#define _SC_SAVED_IDS 7
481#define _SC_VERSION 8
482
483#define __ARCH_WANT_IPC_PARSE_VERSION
484#define __ARCH_WANT_OLD_READDIR
485#define __ARCH_WANT_STAT64
486#define __ARCH_WANT_SYS_ALARM
487#define __ARCH_WANT_SYS_GETHOSTNAME
488#define __ARCH_WANT_SYS_PAUSE
489#define __ARCH_WANT_SYS_SGETMASK
490#define __ARCH_WANT_SYS_SIGNAL
491#define __ARCH_WANT_SYS_TIME
492#define __ARCH_WANT_COMPAT_SYS_TIME
493#define __ARCH_WANT_SYS_UTIME
494#define __ARCH_WANT_SYS_WAITPID
495#define __ARCH_WANT_SYS_SOCKETCALL
496#define __ARCH_WANT_SYS_FADVISE64
497#define __ARCH_WANT_SYS_GETPGRP
498#define __ARCH_WANT_SYS_LLSEEK
499#define __ARCH_WANT_SYS_NICE
500#define __ARCH_WANT_SYS_OLD_GETRLIMIT
501#define __ARCH_WANT_SYS_OLDUMOUNT
502#define __ARCH_WANT_SYS_SIGPENDING
503#define __ARCH_WANT_SYS_SIGPROCMASK
504#endif
505
506/*
507 * "Conditional" syscalls
508 *
509 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
510 * but it doesn't work on all toolchains, so we just do it by hand
511 */
512#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
513
514#endif /* _SPARC64_UNISTD_H */
diff --git a/include/asm-sparc64/upa.h b/include/asm-sparc64/upa.h
new file mode 100644
index 000000000000..7ae09a22e408
--- /dev/null
+++ b/include/asm-sparc64/upa.h
@@ -0,0 +1,110 @@
1/* $Id: upa.h,v 1.3 1999/09/21 14:39:47 davem Exp $ */
2#ifndef _SPARC64_UPA_H
3#define _SPARC64_UPA_H
4
5#include <asm/asi.h>
6
7/* UPA level registers and defines. */
8
9/* UPA Config Register */
10#define UPA_CONFIG_RESV 0xffffffffc0000000 /* Reserved. */
11#define UPA_CONFIG_PCON 0x000000003fc00000 /* Depth of various sys queues. */
12#define UPA_CONFIG_MID 0x00000000003e0000 /* Module ID. */
13#define UPA_CONFIG_PCAP 0x000000000001ffff /* Port Capabilities. */
14
15/* UPA Port ID Register */
16#define UPA_PORTID_FNP 0xff00000000000000 /* Hardcoded to 0xfc on ultra. */
17#define UPA_PORTID_RESV 0x00fffff800000000 /* Reserved. */
18#define UPA_PORTID_ECCVALID 0x0000000400000000 /* Zero if mod can generate ECC */
19#define UPA_PORTID_ONEREAD 0x0000000200000000 /* Set if mod generates P_RASB */
20#define UPA_PORTID_PINTRDQ 0x0000000180000000 /* # outstanding P_INT_REQ's */
21#define UPA_PORTID_PREQDQ 0x000000007e000000 /* slave-wr's to mod supported */
22#define UPA_PORTID_PREQRD 0x0000000001e00000 /* # incoming P_REQ's supported */
23#define UPA_PORTID_UPACAP 0x00000000001f0000 /* UPA capabilities of mod */
24#define UPA_PORTID_ID 0x000000000000ffff /* Module Identification bits */
25
26/* UPA I/O space accessors */
27#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
28static __inline__ unsigned char _upa_readb(unsigned long addr)
29{
30 unsigned char ret;
31
32 __asm__ __volatile__("lduba\t[%1] %2, %0\t/* upa_readb */"
33 : "=r" (ret)
34 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
35
36 return ret;
37}
38
39static __inline__ unsigned short _upa_readw(unsigned long addr)
40{
41 unsigned short ret;
42
43 __asm__ __volatile__("lduha\t[%1] %2, %0\t/* upa_readw */"
44 : "=r" (ret)
45 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
46
47 return ret;
48}
49
50static __inline__ unsigned int _upa_readl(unsigned long addr)
51{
52 unsigned int ret;
53
54 __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* upa_readl */"
55 : "=r" (ret)
56 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
57
58 return ret;
59}
60
61static __inline__ unsigned long _upa_readq(unsigned long addr)
62{
63 unsigned long ret;
64
65 __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* upa_readq */"
66 : "=r" (ret)
67 : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
68
69 return ret;
70}
71
72static __inline__ void _upa_writeb(unsigned char b, unsigned long addr)
73{
74 __asm__ __volatile__("stba\t%0, [%1] %2\t/* upa_writeb */"
75 : /* no outputs */
76 : "r" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
77}
78
79static __inline__ void _upa_writew(unsigned short w, unsigned long addr)
80{
81 __asm__ __volatile__("stha\t%0, [%1] %2\t/* upa_writew */"
82 : /* no outputs */
83 : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
84}
85
86static __inline__ void _upa_writel(unsigned int l, unsigned long addr)
87{
88 __asm__ __volatile__("stwa\t%0, [%1] %2\t/* upa_writel */"
89 : /* no outputs */
90 : "r" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
91}
92
93static __inline__ void _upa_writeq(unsigned long q, unsigned long addr)
94{
95 __asm__ __volatile__("stxa\t%0, [%1] %2\t/* upa_writeq */"
96 : /* no outputs */
97 : "r" (q), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
98}
99
100#define upa_readb(__addr) (_upa_readb((unsigned long)(__addr)))
101#define upa_readw(__addr) (_upa_readw((unsigned long)(__addr)))
102#define upa_readl(__addr) (_upa_readl((unsigned long)(__addr)))
103#define upa_readq(__addr) (_upa_readq((unsigned long)(__addr)))
104#define upa_writeb(__b, __addr) (_upa_writeb((__b), (unsigned long)(__addr)))
105#define upa_writew(__w, __addr) (_upa_writew((__w), (unsigned long)(__addr)))
106#define upa_writel(__l, __addr) (_upa_writel((__l), (unsigned long)(__addr)))
107#define upa_writeq(__q, __addr) (_upa_writeq((__q), (unsigned long)(__addr)))
108#endif /* __KERNEL__ && !__ASSEMBLY__ */
109
110#endif /* !(_SPARC64_UPA_H) */
diff --git a/include/asm-sparc64/user.h b/include/asm-sparc64/user.h
new file mode 100644
index 000000000000..fce4e857dfc3
--- /dev/null
+++ b/include/asm-sparc64/user.h
@@ -0,0 +1,60 @@
1/* $Id: user.h,v 1.1 1996/12/26 14:22:44 davem Exp $
2 * asm-sparc64/user.h: Core file definitions for the Sparc.
3 *
4 * Keep in sync with reg.h. Actually, we could get rid of this
5 * one, since we won't a.out core dump that much anyways - miguel.
6 * Copyright (C) 1995 (davem@caip.rutgers.edu)
7 */
8#ifndef _SPARC64_USER_H
9#define _SPARC64_USER_H
10
11#include <asm/a.out.h>
12struct sunos_regs {
13 unsigned int psr, pc, npc, y;
14 unsigned int regs[15];
15};
16
17struct sunos_fpqueue {
18 unsigned int *addr;
19 unsigned int inst;
20};
21
22struct sunos_fp {
23 union {
24 unsigned int regs[32];
25 double reg_dbls[16];
26 } fregs;
27 unsigned int fsr;
28 unsigned int flags;
29 unsigned int extra;
30 unsigned int fpq_count;
31 struct sunos_fpqueue fpq[16];
32};
33
34struct sunos_fpu {
35 struct sunos_fp fpstatus;
36};
37
38/* The SunOS core file header layout. */
39struct user {
40 unsigned int magic;
41 unsigned int len;
42 struct sunos_regs regs;
43 struct exec uexec;
44 int signal;
45 size_t u_tsize; /* all of these in bytes! */
46 size_t u_dsize;
47 size_t u_ssize;
48 char u_comm[17];
49 struct sunos_fpu fpu;
50 unsigned int sigcode; /* Special sigcontext subcode, if any */
51};
52
53#define NBPG PAGE_SIZE /* XXX 4096 maybe? */
54#define UPAGES 1
55#define HOST_TEXT_START_ADDR (u.start_code)
56#define HOST_DATA_START_ADDR (u.start_data)
57#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
58#define SUNOS_CORE_MAGIC 0x080456
59
60#endif /* !(_SPARC64_USER_H) */
diff --git a/include/asm-sparc64/utrap.h b/include/asm-sparc64/utrap.h
new file mode 100644
index 000000000000..81b0ebf3736c
--- /dev/null
+++ b/include/asm-sparc64/utrap.h
@@ -0,0 +1,51 @@
1/* $Id: utrap.h,v 1.1 1997/10/14 16:21:31 jj Exp $
2 * include/asm-sparc64/utrap.h
3 *
4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 */
6
7#ifndef __ASM_SPARC64_UTRAP_H
8#define __ASM_SPARC64_UTRAP_H
9
10#define UT_INSTRUCTION_EXCEPTION 1
11#define UT_INSTRUCTION_ERROR 2
12#define UT_INSTRUCTION_PROTECTION 3
13#define UT_ILLTRAP_INSTRUCTION 4
14#define UT_ILLEGAL_INSTRUCTION 5
15#define UT_PRIVILEGED_OPCODE 6
16#define UT_FP_DISABLED 7
17#define UT_FP_EXCEPTION_IEEE_754 8
18#define UT_FP_EXCEPTION_OTHER 9
19#define UT_TAG_OVERVIEW 10
20#define UT_DIVISION_BY_ZERO 11
21#define UT_DATA_EXCEPTION 12
22#define UT_DATA_ERROR 13
23#define UT_DATA_PROTECTION 14
24#define UT_MEM_ADDRESS_NOT_ALIGNED 15
25#define UT_PRIVILEGED_ACTION 16
26#define UT_ASYNC_DATA_ERROR 17
27#define UT_TRAP_INSTRUCTION_16 18
28#define UT_TRAP_INSTRUCTION_17 19
29#define UT_TRAP_INSTRUCTION_18 20
30#define UT_TRAP_INSTRUCTION_19 21
31#define UT_TRAP_INSTRUCTION_20 22
32#define UT_TRAP_INSTRUCTION_21 23
33#define UT_TRAP_INSTRUCTION_22 24
34#define UT_TRAP_INSTRUCTION_23 25
35#define UT_TRAP_INSTRUCTION_24 26
36#define UT_TRAP_INSTRUCTION_25 27
37#define UT_TRAP_INSTRUCTION_26 28
38#define UT_TRAP_INSTRUCTION_27 29
39#define UT_TRAP_INSTRUCTION_28 30
40#define UT_TRAP_INSTRUCTION_29 31
41#define UT_TRAP_INSTRUCTION_30 32
42#define UT_TRAP_INSTRUCTION_31 33
43
44#define UTH_NOCHANGE (-1)
45
46#ifndef __ASSEMBLY__
47typedef int utrap_entry_t;
48typedef void *utrap_handler_t;
49#endif /* __ASSEMBLY__ */
50
51#endif /* !(__ASM_SPARC64_PROCESSOR_H) */
diff --git a/include/asm-sparc64/vga.h b/include/asm-sparc64/vga.h
new file mode 100644
index 000000000000..9c57eb363b40
--- /dev/null
+++ b/include/asm-sparc64/vga.h
@@ -0,0 +1,33 @@
1/*
2 * Access to VGA videoram
3 *
4 * (c) 1998 Martin Mares <mj@ucw.cz>
5 */
6
7#ifndef _LINUX_ASM_VGA_H_
8#define _LINUX_ASM_VGA_H_
9
10#include <asm/types.h>
11
12#define VT_BUF_HAVE_RW
13
14#undef scr_writew
15#undef scr_readw
16
17static inline void scr_writew(u16 val, u16 *addr)
18{
19 BUG_ON((long) addr >= 0);
20
21 *addr = val;
22}
23
24static inline u16 scr_readw(const u16 *addr)
25{
26 BUG_ON((long) addr >= 0);
27
28 return *addr;
29}
30
31#define VGA_MAP_MEM(x) (x)
32
33#endif
diff --git a/include/asm-sparc64/visasm.h b/include/asm-sparc64/visasm.h
new file mode 100644
index 000000000000..a74078551e0f
--- /dev/null
+++ b/include/asm-sparc64/visasm.h
@@ -0,0 +1,63 @@
1/* $Id: visasm.h,v 1.5 2001/04/24 01:09:12 davem Exp $ */
2#ifndef _SPARC64_VISASM_H
3#define _SPARC64_VISASM_H
4
5/* visasm.h: FPU saving macros for VIS routines
6 *
7 * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
8 */
9
10#include <asm/pstate.h>
11#include <asm/ptrace.h>
12
13/* Clobbers %o5, %g1, %g2, %g3, %g7, %icc, %xcc */
14
15#define VISEntry \
16 rd %fprs, %o5; \
17 andcc %o5, (FPRS_FEF|FPRS_DU), %g0; \
18 be,pt %icc, 297f; \
19 sethi %hi(297f), %g7; \
20 sethi %hi(VISenter), %g1; \
21 jmpl %g1 + %lo(VISenter), %g0; \
22 or %g7, %lo(297f), %g7; \
23297: wr %g0, FPRS_FEF, %fprs; \
24
25#define VISExit \
26 wr %g0, 0, %fprs;
27
28/* Clobbers %o5, %g1, %g2, %g3, %g7, %icc, %xcc.
29 * Must preserve %o5 between VISEntryHalf and VISExitHalf */
30
31#define VISEntryHalf \
32 rd %fprs, %o5; \
33 andcc %o5, FPRS_FEF, %g0; \
34 be,pt %icc, 297f; \
35 sethi %hi(298f), %g7; \
36 sethi %hi(VISenterhalf), %g1; \
37 jmpl %g1 + %lo(VISenterhalf), %g0; \
38 or %g7, %lo(298f), %g7; \
39 clr %o5; \
40297: wr %o5, FPRS_FEF, %fprs; \
41298:
42
43#define VISExitHalf \
44 wr %o5, 0, %fprs;
45
46#ifndef __ASSEMBLY__
47static __inline__ void save_and_clear_fpu(void) {
48 __asm__ __volatile__ (
49" rd %%fprs, %%o5\n"
50" andcc %%o5, %0, %%g0\n"
51" be,pt %%icc, 299f\n"
52" sethi %%hi(298f), %%g7\n"
53" sethi %%hi(VISenter), %%g1\n"
54" jmpl %%g1 + %%lo(VISenter), %%g0\n"
55" or %%g7, %%lo(298f), %%g7\n"
56" 298: wr %%g0, 0, %%fprs\n"
57" 299:\n"
58" " : : "i" (FPRS_FEF|FPRS_DU) :
59 "o5", "g1", "g2", "g3", "g7", "cc");
60}
61#endif
62
63#endif /* _SPARC64_ASI_H */
diff --git a/include/asm-sparc64/vuid_event.h b/include/asm-sparc64/vuid_event.h
new file mode 100644
index 000000000000..9ef4d17ad08f
--- /dev/null
+++ b/include/asm-sparc64/vuid_event.h
@@ -0,0 +1,40 @@
1/* SunOS Virtual User Input Device (VUID) compatibility */
2
3typedef struct firm_event {
4 unsigned short id; /* tag for this event */
5 unsigned char pair_type; /* unused by X11 */
6 unsigned char pair; /* unused by X11 */
7 int value; /* VKEY_UP, VKEY_DOWN or delta */
8 struct timeval time;
9} Firm_event;
10
11enum {
12 FE_PAIR_NONE,
13 FE_PAIR_SET,
14 FE_PAIR_DELTA,
15 FE_PAIR_ABSOLUTE
16};
17
18/* VUID stream formats */
19#define VUID_NATIVE 0 /* Native byte stream format */
20#define VUID_FIRM_EVENT 1 /* send firm_event structures */
21
22/* ioctls */
23 /* Set input device byte stream format (any of VUID_{NATIVE,FIRM_EVENT}) */
24#define VUIDSFORMAT _IOW('v', 1, int)
25 /* Retrieve input device byte stream format */
26#define VUIDGFORMAT _IOR('v', 2, int)
27
28/* Possible tag values */
29/* mouse buttons: */
30#define MS_LEFT 0x7f20
31#define MS_MIDDLE 0x7f21
32#define MS_RIGHT 0x7f22
33/* motion: */
34#define LOC_X_DELTA 0x7f80
35#define LOC_Y_DELTA 0x7f81
36#define LOC_X_ABSOLUTE 0x7f82 /* X compat, unsupported */
37#define LOC_Y_ABSOLUTE 0x7f83 /* X compat, unsupported */
38
39#define VKEY_UP 0
40#define VKEY_DOWN 1
diff --git a/include/asm-sparc64/watchdog.h b/include/asm-sparc64/watchdog.h
new file mode 100644
index 000000000000..4d5b03b60e4d
--- /dev/null
+++ b/include/asm-sparc64/watchdog.h
@@ -0,0 +1,31 @@
1/* $Id: watchdog.h,v 1.1 2001/01/18 04:47:44 davem Exp $
2 *
3 * watchdog - Driver interface for the hardware watchdog timers
4 * present on Sun Microsystems boardsets
5 *
6 * Copyright (c) 2000 Eric Brower <ebrower@usa.net>
7 *
8 */
9
10#ifndef _SPARC64_WATCHDOG_H
11#define _SPARC64_WATCHDOG_H
12
13#include <linux/watchdog.h>
14
15/* Solaris compatibility ioctls--
16 * Ref. <linux/watchdog.h> for standard linux watchdog ioctls
17 */
18#define WIOCSTART _IO (WATCHDOG_IOCTL_BASE, 10) /* Start Timer */
19#define WIOCSTOP _IO (WATCHDOG_IOCTL_BASE, 11) /* Stop Timer */
20#define WIOCGSTAT _IOR(WATCHDOG_IOCTL_BASE, 12, int)/* Get Timer Status */
21
22/* Status flags from WIOCGSTAT ioctl
23 */
24#define WD_FREERUN 0x01 /* timer is running, interrupts disabled */
25#define WD_EXPIRED 0x02 /* timer has expired */
26#define WD_RUNNING 0x04 /* timer is running, interrupts enabled */
27#define WD_STOPPED 0x08 /* timer has not been started */
28#define WD_SERVICED 0x10 /* timer interrupt was serviced */
29
30#endif /* ifndef _SPARC64_WATCHDOG_H */
31
diff --git a/include/asm-sparc64/xor.h b/include/asm-sparc64/xor.h
new file mode 100644
index 000000000000..8b3a7e4b6062
--- /dev/null
+++ b/include/asm-sparc64/xor.h
@@ -0,0 +1,40 @@
1/*
2 * include/asm-sparc64/xor.h
3 *
4 * High speed xor_block operation for RAID4/5 utilizing the
5 * UltraSparc Visual Instruction Set.
6 *
7 * Copyright (C) 1997, 1999 Jakub Jelinek (jj@ultra.linux.cz)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * You should have received a copy of the GNU General Public License
15 * (for example /usr/src/linux/COPYING); if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#include <asm/pstate.h>
20#include <asm/asi.h>
21
22extern void xor_vis_2(unsigned long, unsigned long *, unsigned long *);
23extern void xor_vis_3(unsigned long, unsigned long *, unsigned long *,
24 unsigned long *);
25extern void xor_vis_4(unsigned long, unsigned long *, unsigned long *,
26 unsigned long *, unsigned long *);
27extern void xor_vis_5(unsigned long, unsigned long *, unsigned long *,
28 unsigned long *, unsigned long *, unsigned long *);
29
30/* XXX Ugh, write cheetah versions... -DaveM */
31
32static struct xor_block_template xor_block_VIS = {
33 .name = "VIS",
34 .do_2 = xor_vis_2,
35 .do_3 = xor_vis_3,
36 .do_4 = xor_vis_4,
37 .do_5 = xor_vis_5,
38};
39
40#define XOR_TRY_TEMPLATES xor_speed(&xor_block_VIS)