blob: 33d6b375ff12095471171911e0d46dbb626191d5 [file] [log] [blame]
David S. Miller2809a20872012-04-15 20:06:27 -07001#ifndef _BPF_JIT_H
2#define _BPF_JIT_H
3
4/* Conventions:
5 * %g1 : temporary
6 * %g2 : Secondary temporary used by SKB data helper stubs.
David S. Miller7b56f762012-04-17 16:08:29 -04007 * %g3 : packet offset passed into SKB data helper stubs.
David S. Miller2809a20872012-04-15 20:06:27 -07008 * %o0 : pointer to skb (first argument given to JIT function)
9 * %o1 : BPF A accumulator
10 * %o2 : BPF X accumulator
11 * %o3 : Holds saved %o7 so we can call helper functions without needing
12 * to allocate a register window.
David S. Miller7b56f762012-04-17 16:08:29 -040013 * %o4 : skb->len - skb->data_len
14 * %o5 : skb->data
David S. Miller2809a20872012-04-15 20:06:27 -070015 */
16
17#ifndef __ASSEMBLER__
18#define G0 0x00
19#define G1 0x01
20#define G3 0x03
21#define G6 0x06
22#define O0 0x08
23#define O1 0x09
24#define O2 0x0a
25#define O3 0x0b
26#define O4 0x0c
27#define O5 0x0d
28#define SP 0x0e
29#define O7 0x0f
30#define FP 0x1e
31
32#define r_SKB O0
33#define r_A O1
34#define r_X O2
35#define r_saved_O7 O3
36#define r_HEADLEN O4
37#define r_SKB_DATA O5
38#define r_TMP G1
39#define r_TMP2 G2
40#define r_OFF G3
David S. Miller584c5e22012-04-17 16:38:16 -040041
42/* assembly code in arch/sparc/net/bpf_jit_asm.S */
43extern u32 bpf_jit_load_word[];
44extern u32 bpf_jit_load_half[];
45extern u32 bpf_jit_load_byte[];
46extern u32 bpf_jit_load_byte_msh[];
47extern u32 bpf_jit_load_word_positive_offset[];
48extern u32 bpf_jit_load_half_positive_offset[];
49extern u32 bpf_jit_load_byte_positive_offset[];
50extern u32 bpf_jit_load_byte_msh_positive_offset[];
51extern u32 bpf_jit_load_word_negative_offset[];
52extern u32 bpf_jit_load_half_negative_offset[];
53extern u32 bpf_jit_load_byte_negative_offset[];
54extern u32 bpf_jit_load_byte_msh_negative_offset[];
55
David S. Miller2809a20872012-04-15 20:06:27 -070056#else
57#define r_SKB %o0
58#define r_A %o1
59#define r_X %o2
60#define r_saved_O7 %o3
61#define r_HEADLEN %o4
62#define r_SKB_DATA %o5
63#define r_TMP %g1
64#define r_TMP2 %g2
65#define r_OFF %g3
66#endif
67
68#endif /* _BPF_JIT_H */