Migrate UI cleanup phase 4 from MIPS into ARM
[tomato.git] / release / src-rt-6.x.4708 / include / hndtcam.h
bloba661850ade4076171e6b04cb54f76658da244f3b
1 /*
2 * HND SOCRAM TCAM software interface.
4 * Copyright (C) 2013, Broadcom Corporation. All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * $Id: hndtcam.h 419467 2013-08-21 09:19:48Z $
20 #ifndef _hndtcam_h_
21 #define _hndtcam_h_
24 * 0 - 1
25 * 1 - 2 Consecutive locations are patched
26 * 2 - 4 Consecutive locations are patched
27 * 3 - 8 Consecutive locations are patched
28 * 4 - 16 Consecutive locations are patched
29 * Define default to patch 2 locations
32 #ifdef PATCHCOUNT
33 #define SRPC_PATCHCOUNT PATCHCOUNT
34 #else
35 #define PATCHCOUNT 0
36 #define SRPC_PATCHCOUNT PATCHCOUNT
37 #endif
39 #if defined(__ARM_ARCH_7R__)
40 #if !defined(PATCHCOUNT) || (PATCHCOUNT == 0)
41 #undef PATCHCOUNT
42 #define PATCHCOUNT 1
43 #endif
44 #define ARMCR4_TCAMPATCHCOUNT PATCHCOUNT
45 #define ARMCR4_TCAMADDR_MASK (~((1 << (ARMCR4_TCAMPATCHCOUNT + 2))-1))
46 #define ARMCR4_PATCHNLOC (1 << ARMCR4_TCAMPATCHCOUNT)
47 #endif /* defined(__ARM_ARCH_7R__) */
49 /* N Consecutive location to patch */
50 #define SRPC_PATCHNLOC (1 << (SRPC_PATCHCOUNT))
52 #define PATCHHDR(_p) __attribute__ ((__section__ (".patchhdr."#_p))) _p
53 #define PATCHENTRY(_p) __attribute__ ((__section__ (".patchentry."#_p))) _p
55 #if defined(__ARM_ARCH_7R__)
56 typedef struct {
57 uint32 data[ARMCR4_PATCHNLOC];
58 } patch_entry_t;
59 #else
60 typedef struct {
61 uint32 data[SRPC_PATCHNLOC];
62 } patch_entry_t;
63 #endif
65 typedef struct {
66 void *addr; /* patch address */
67 uint32 len; /* bytes to patch in entry */
68 patch_entry_t *entry; /* patch entry data */
69 } patch_hdr_t;
71 /* patch values and address structure */
72 typedef struct patchaddrvalue {
73 uint32 addr;
74 uint32 value;
75 } patchaddrvalue_t;
77 extern void *socram_regs;
78 extern uint32 socram_rev;
80 extern void *arm_regs;
82 extern void hnd_patch_init(void *srp);
83 extern void hnd_tcam_write(void *srp, uint16 idx, uint32 data);
84 extern void hnd_tcam_read(void *srp, uint16 idx, uint32 *content);
85 void * hnd_tcam_init(void *srp, int no_addrs);
86 extern void hnd_tcam_disablepatch(void *srp);
87 extern void hnd_tcam_patchdisable(void);
88 extern void hnd_tcam_enablepatch(void *srp);
89 #ifdef CONFIG_XIP
90 extern void hnd_tcam_bootloader_load(void *srp, char *pvars);
91 #else
92 extern void hnd_tcam_load(void *srp, const patchaddrvalue_t *patchtbl);
93 #endif /* CONFIG_XIP */
94 extern void BCMATTACHFN(hnd_tcam_load_default)(void);
95 extern void hnd_tcam_reclaim(void);
97 #endif /* _hndtcam_h_ */