/[dynamips]/upstream/dynamips-0.2.6-RC2/insn_lookup.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /upstream/dynamips-0.2.6-RC2/insn_lookup.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Sat Oct 6 16:05:34 2007 UTC (14 years, 9 months ago) by dpavlin
File MIME type: text/plain
File size: 2773 byte(s)
dynamips-0.2.6-RC2

1 dpavlin 1 /*
2     * Cisco 7200 (Predator) simulation platform.
3     * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4     *
5     * MIPS Instruction Lookup Tables.
6     */
7    
8     #ifndef __INSN_LOOKUP_H__
9     #define __INSN_LOOKUP_H__
10    
11     #include "utils.h"
12     #include "hash.h"
13     #include "mips64.h"
14     #include "dynamips.h"
15    
16     /* Forward declaration for instruction lookup table */
17     typedef struct insn_lookup insn_lookup_t;
18    
19     /* CBM (Class BitMap) array */
20     #define CBM_SHIFT 5 /* log2(32) */
21     #define CBM_SIZE (1 << CBM_SHIFT) /* Arrays of 32-bits Integers */
22     #define CBM_HASH_SIZE 256 /* Size for Hash Tables */
23    
24     typedef struct cbm_array cbm_array_t;
25     struct cbm_array {
26     int nr_entries; /* Number of entries */
27     int tab[0]; /* Values... */
28     };
29    
30     #define CBM_ARRAY(array,i) ((array)->tab[(i)])
31     #define CBM_CSIZE(count) (((count)*sizeof(int))+sizeof(cbm_array_t))
32    
33     /* callback function prototype for instruction checking */
34     typedef int (*ilt_check_cbk_t)(void *,int value);
35     typedef void *(*ilt_get_insn_cbk_t)(int index);
36    
37     /* RFC (Recursive Flow Classification) arrays */
38     #define RFC_ARRAY_MAXSIZE 65536
39     #define RFC_ARRAY_MAXBITS 16
40     #define RFC_ARRAY_NUMBER 3
41    
42     typedef struct rfc_array rfc_array_t;
43     struct rfc_array {
44     rfc_array_t *parent0,*parent1;
45     int nr_elements;
46    
47     /* Number of Equivalent ID */
48     int nr_eqid;
49    
50     /* Hash Table for Class Bitmaps */
51     hash_table_t *cbm_hash;
52    
53     /* Array to get Class Bitmaps from IDs */
54     cbm_array_t **id2cbm;
55    
56     /* Equivalent ID (eqID) array */
57     int eqID[0];
58     };
59    
60     /* Equivalent Classes */
61     typedef struct rfc_eqclass rfc_eqclass_t;
62     struct rfc_eqclass {
63     cbm_array_t *cbm; /* Class Bitmap */
64     int eqID; /* Index associated to this class */
65     };
66    
67     /* Instruction lookup table */
68     struct insn_lookup {
69     int nr_insn; /* Number of instructions */
70     int cbm_size; /* Size of Class Bitmaps */
71    
72     ilt_get_insn_cbk_t get_insn;
73     ilt_check_cbk_t chk_lo,chk_hi;
74    
75     /* RFC tables */
76     rfc_array_t *rfct[RFC_ARRAY_NUMBER];
77     };
78    
79     /* Instruction lookup */
80     static forced_inline int ilt_get_index(rfc_array_t *a1,rfc_array_t *a2,
81     int i1,int i2)
82     {
83     return((a1->eqID[i1]*a2->nr_eqid) + a2->eqID[i2]);
84     }
85    
86     static forced_inline int ilt_get_idx(insn_lookup_t *ilt,int a1,int a2,
87     int i1,int i2)
88     {
89     return(ilt_get_index(ilt->rfct[a1],ilt->rfct[a2],i1,i2));
90     }
91    
92     static forced_inline int ilt_lookup(insn_lookup_t *ilt,mips_insn_t insn)
93     {
94     int id_i;
95    
96     id_i = ilt_get_idx(ilt,0,1,insn >> 16,insn & 0xFFFF);
97     return(ilt->rfct[2]->eqID[id_i]);
98     }
99    
100     /* Create an instruction lookup table */
101     insn_lookup_t *ilt_create(int nr_insn,ilt_get_insn_cbk_t get_insn,
102     ilt_check_cbk_t chk_lo,ilt_check_cbk_t chk_hi);
103    
104     #endif

  ViewVC Help
Powered by ViewVC 1.1.26