/[gxemul]/trunk/src/include/cpu_arm.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

Diff of /trunk/src/include/cpu_arm.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 14 by dpavlin, Mon Oct 8 16:18:51 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 2  Line 2 
2  #define CPU_ARM_H  #define CPU_ARM_H
3    
4  /*  /*
5   *  Copyright (C) 2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2007  Anders Gavare.  All rights reserved.
6   *   *
7   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
8   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 28  Line 28 
28   *  SUCH DAMAGE.   *  SUCH DAMAGE.
29   *   *
30   *   *
31   *  $Id: cpu_arm.h,v 1.43 2005/10/07 22:10:53 debug Exp $   *  $Id: cpu_arm.h,v 1.74 2007/06/14 04:53:14 debug Exp $
32   */   */
33    
34  #include "misc.h"  #include "misc.h"
35    #include "interrupt.h"
36    
37  struct cpu_family;  struct cpu_family;
38    struct timer;
39    
40  /*  ARM CPU types:  */  /*  ARM CPU types:  */
41  struct arm_cpu_type_def {  struct arm_cpu_type_def {
# Line 69  struct arm_cpu_type_def { Line 70  struct arm_cpu_type_def {
70          "and", "eor", "sub", "rsb", "add", "adc", "sbc", "rsc", \          "and", "eor", "sub", "rsb", "add", "adc", "sbc", "rsc", \
71          "tst", "teq", "cmp", "cmn", "orr", "mov", "bic", "mvn" }          "tst", "teq", "cmp", "cmn", "orr", "mov", "bic", "mvn" }
72    
73    #define ARM_IC_ENTRIES_SHIFT            10
74    
75  #define ARM_N_IC_ARGS                   3  #define ARM_N_IC_ARGS                   3
76  #define ARM_INSTR_ALIGNMENT_SHIFT       2  #define ARM_INSTR_ALIGNMENT_SHIFT       2
 #define ARM_IC_ENTRIES_SHIFT            10  
77  #define ARM_IC_ENTRIES_PER_PAGE         (1 << ARM_IC_ENTRIES_SHIFT)  #define ARM_IC_ENTRIES_PER_PAGE         (1 << ARM_IC_ENTRIES_SHIFT)
78  #define ARM_PC_TO_IC_ENTRY(a)           (((a)>>ARM_INSTR_ALIGNMENT_SHIFT) \  #define ARM_PC_TO_IC_ENTRY(a)           (((a)>>ARM_INSTR_ALIGNMENT_SHIFT) \
79                                          & (ARM_IC_ENTRIES_PER_PAGE-1))                                          & (ARM_IC_ENTRIES_PER_PAGE-1))
80  #define ARM_ADDR_TO_PAGENR(a)           ((a) >> (ARM_IC_ENTRIES_SHIFT \  #define ARM_ADDR_TO_PAGENR(a)           ((a) >> (ARM_IC_ENTRIES_SHIFT \
81                                          + ARM_INSTR_ALIGNMENT_SHIFT))                                          + ARM_INSTR_ALIGNMENT_SHIFT))
82    
83  struct arm_instr_call {  #define ARM_F_N         8       /*  Same as ARM_FLAG_*, but        */
84          void    (*f)(struct cpu *, struct arm_instr_call *);  #define ARM_F_Z         4       /*  for the 'flags' field instead  */
85          size_t  arg[ARM_N_IC_ARGS];  #define ARM_F_C         2       /*  of cpsr.                       */
86  };  #define ARM_F_V         1
   
 /*  Translation cache struct for each physical page:  */  
 struct arm_tc_physpage {  
         uint32_t        next_ofs;       /*  or 0 for end of chain  */  
         uint32_t        physaddr;  
         int             flags;  
         struct arm_instr_call ics[ARM_IC_ENTRIES_PER_PAGE + 1];  
 };  
   
87    
88  #define ARM_FLAG_N      0x80000000      /*  Negative flag  */  #define ARM_FLAG_N      0x80000000      /*  Negative flag  */
89  #define ARM_FLAG_Z      0x40000000      /*  Zero flag  */  #define ARM_FLAG_Z      0x40000000      /*  Zero flag  */
# Line 129  struct arm_tc_physpage { Line 122  struct arm_tc_physpage {
122  #define ARM_EXCEPTION_IRQ       6  #define ARM_EXCEPTION_IRQ       6
123  #define ARM_EXCEPTION_FIQ       7  #define ARM_EXCEPTION_FIQ       7
124    
125    DYNTRANS_MISC_DECLARATIONS(arm,ARM,uint32_t)
126    
127  #define ARM_N_VPH_ENTRIES       1048576  #define ARM_MAX_VPH_TLB_ENTRIES         384
   
 #define ARM_MAX_VPH_TLB_ENTRIES         64  
 struct arm_vpg_tlb_entry {  
         int             valid;  
         int             writeflag;  
         int64_t         timestamp;  
         unsigned char   *host_page;  
         uint32_t        vaddr_page;  
         uint32_t        paddr_page;  
 };  
128    
129    
130  struct arm_cpu {  struct arm_cpu {
# Line 173  struct arm_cpu { Line 157  struct arm_cpu {
157    
158          uint32_t                tmp_pc;         /*  Used for load/stores  */          uint32_t                tmp_pc;         /*  Used for load/stores  */
159    
160          /*  Flag/status registers:  */          /*
161             *  Flag/status registers:
162             *
163             *  NOTE: 'flags' just contains the 4 flag bits. When cpsr is read,
164             *  the flags should be copied from 'flags', and when cpsr is written
165             *  to, 'flags' should be updated as well.
166             */
167            size_t                  flags;
168          uint32_t                cpsr;          uint32_t                cpsr;
169          uint32_t                spsr_svc;          uint32_t                spsr_svc;
170          uint32_t                spsr_abt;          uint32_t                spsr_abt;
# Line 185  struct arm_cpu { Line 176  struct arm_cpu {
176          /*          /*
177           *  System Control Coprocessor registers:           *  System Control Coprocessor registers:
178           */           */
179          uint32_t                control;          uint32_t                cachetype;      /*  Cache Type Register  */
180            uint32_t                control;        /*  Control Register  */
181            uint32_t                auxctrl;        /*  Aux. Control Register  */
182          uint32_t                ttb;            /*  Translation Table Base  */          uint32_t                ttb;            /*  Translation Table Base  */
183          uint32_t                dacr;           /*  Domain Access Control  */          uint32_t                dacr;           /*  Domain Access Control  */
184          uint32_t                fsr;            /*  Fault Status Register  */          uint32_t                fsr;            /*  Fault Status Register  */
185          uint32_t                far;            /*  Fault Address Register  */          uint32_t                far;            /*  Fault Address Register  */
186          uint32_t                pid;            /*  Process Id Register  */          uint32_t                pid;            /*  Process Id Register  */
187            uint32_t                cpar;           /*  CoProcessor Access Reg.  */
188    
189            /*  i80321 Coprocessor 6: ICU (Interrupt controller)  */
190            uint32_t                i80321_inten;   /*  enable  */
191            uint32_t                i80321_isteer;
192            uint32_t                i80321_isrc;    /*  current assertions  */
193            uint32_t                tmr0;
194            uint32_t                tmr1;
195            struct interrupt        tmr0_irq;
196            struct interrupt        tmr1_irq;
197            uint32_t                tcr0;
198            uint32_t                tcr1;
199            uint32_t                trr0;
200            uint32_t                trr1;
201            uint32_t                tisr;
202            uint32_t                wdtcr;
203    
204            /*  XScale Coprocessor 14: (Performance Monitoring Unit)  */
205            /*  XSC1 access style:  */
206            uint32_t                xsc1_pmnc;      /*  Perf. Monitor Ctrl Reg.  */
207            uint32_t                xsc1_ccnt;      /*  Clock Counter  */
208            uint32_t                xsc1_pmn0;      /*  Perf. Counter Reg. 0  */
209            uint32_t                xsc1_pmn1;      /*  Perf. Counter Reg. 1  */
210            /*  XSC2 access style:  */
211            uint32_t                xsc2_pmnc;      /*  Perf. Monitor Ctrl Reg.  */
212            uint32_t                xsc2_ccnt;      /*  Clock Counter  */
213            uint32_t                xsc2_inten;     /*  Interrupt Enable  */
214            uint32_t                xsc2_flag;      /*  Overflow Flag Register  */
215            uint32_t                xsc2_evtsel;    /*  Event Selection Register  */
216            uint32_t                xsc2_pmn0;      /*  Perf. Counter Reg. 0  */
217            uint32_t                xsc2_pmn1;      /*  Perf. Counter Reg. 1  */
218            uint32_t                xsc2_pmn2;      /*  Perf. Counter Reg. 2  */
219            uint32_t                xsc2_pmn3;      /*  Perf. Counter Reg. 3  */
220    
221            /*  For caching the host address of the L1 translation table:  */
222            unsigned char           *translation_table;
223            uint32_t                last_ttb;
224    
225          /*          /*
226           *  Interrupts:           *  Interrupts:
# Line 200  struct arm_cpu { Line 229  struct arm_cpu {
229    
230    
231          /*          /*
232           *  Instruction translation cache:           *  Instruction translation cache, and 32-bit virtual -> physical ->
233           */           *  host address translation:
   
         /*  cur_ic_page is a pointer to an array of ARM_IC_ENTRIES_PER_PAGE  
             instruction call entries. next_ic points to the next such  
             call to be executed.  */  
         struct arm_tc_physpage  *cur_physpage;  
         struct arm_instr_call   *cur_ic_page;  
         struct arm_instr_call   *next_ic;  
   
   
         /*  
          *  Virtual -> physical -> host address translation:  
          *  
          *  host_load and host_store point to arrays of ARM_N_VPH_ENTRIES  
          *  pointers (to host pages); phys_addr points to an array of  
          *  ARM_N_VPH_ENTRIES uint32_t.  
234           */           */
235            DYNTRANS_ITC(arm)
236            VPH_TLBS(arm,ARM)
237            VPH32_16BITVPHENTRIES(arm,ARM)
238    
239          struct arm_vpg_tlb_entry        vph_tlb_entry[ARM_MAX_VPH_TLB_ENTRIES];          /*  ARM specific: */
240          unsigned char                   *host_load[ARM_N_VPH_ENTRIES];          uint32_t                        is_userpage[N_VPH32_ENTRIES/32];
         unsigned char                   *host_store[ARM_N_VPH_ENTRIES];  
         uint32_t                        phys_addr[ARM_N_VPH_ENTRIES];  
         struct arm_tc_physpage          *phys_page[ARM_N_VPH_ENTRIES];  
241  };  };
242    
243    
# Line 244  struct arm_cpu { Line 258  struct arm_cpu {
258  #define ARM_CONTROL_RR          0x4000  #define ARM_CONTROL_RR          0x4000
259  #define ARM_CONTROL_L4          0x8000  #define ARM_CONTROL_L4          0x8000
260    
261    /*  Auxiliary Control Register bits:  */
262    #define ARM_AUXCTRL_MD          0x30    /*  MiniData Cache Attribute  */
263    #define ARM_AUXCTRL_MD_SHIFT    4
264    #define ARM_AUXCTRL_P           0x02    /*  Page Table Memory Attribute  */
265    #define ARM_AUXCTRL_K           0x01    /*  Write Buffer Coalescing Disable  */
266    
267    /*  Cache Type register bits:  */
268    #define ARM_CACHETYPE_CLASS             0x1e000000
269    #define ARM_CACHETYPE_CLASS_SHIFT       25
270    #define ARM_CACHETYPE_HARVARD           0x01000000
271    #define ARM_CACHETYPE_HARVARD_SHIFT     24
272    #define ARM_CACHETYPE_DSIZE             0x001c0000
273    #define ARM_CACHETYPE_DSIZE_SHIFT       18
274    #define ARM_CACHETYPE_DASSOC            0x00038000
275    #define ARM_CACHETYPE_DASSOC_SHIFT      15
276    #define ARM_CACHETYPE_DLINE             0x00003000
277    #define ARM_CACHETYPE_DLINE_SHIFT       12
278    #define ARM_CACHETYPE_ISIZE             0x000001c0
279    #define ARM_CACHETYPE_ISIZE_SHIFT       6
280    #define ARM_CACHETYPE_IASSOC            0x00000038
281    #define ARM_CACHETYPE_IASSOC_SHIFT      3
282    #define ARM_CACHETYPE_ILINE             0x00000003
283    #define ARM_CACHETYPE_ILINE_SHIFT       0
284    
285  /*  cpu_arm.c:  */  /*  cpu_arm.c:  */
286    void arm_setup_initial_translation_table(struct cpu *cpu, uint32_t ttb_addr);
287    void arm_translation_table_set_l1(struct cpu *cpu, uint32_t vaddr,
288            uint32_t paddr);
289    void arm_translation_table_set_l1_b(struct cpu *cpu, uint32_t vaddr,
290            uint32_t paddr);
291  void arm_exception(struct cpu *, int);  void arm_exception(struct cpu *, int);
292    int arm_run_instr(struct cpu *cpu);
293    void arm_timer_sample_tick(struct timer *, void *);
294  void arm_update_translation_table(struct cpu *cpu, uint64_t vaddr_page,  void arm_update_translation_table(struct cpu *cpu, uint64_t vaddr_page,
295          unsigned char *host_page, int writeflag, uint64_t paddr_page);          unsigned char *host_page, int writeflag, uint64_t paddr_page);
296  void arm_invalidate_translation_caches_paddr(struct cpu *cpu, uint64_t, int);  void arm_invalidate_translation_caches(struct cpu *cpu, uint64_t, int);
297  void arm_invalidate_code_translation(struct cpu *cpu, uint64_t, int);  void arm_invalidate_code_translation(struct cpu *cpu, uint64_t, int);
 void arm_setup_initial_translation_table(struct cpu *cpu, uint32_t ttb_addr);  
298  void arm_load_register_bank(struct cpu *cpu);  void arm_load_register_bank(struct cpu *cpu);
299  void arm_save_register_bank(struct cpu *cpu);  void arm_save_register_bank(struct cpu *cpu);
300  int arm_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr,  int arm_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr,
# Line 260  int arm_cpu_family_init(struct cpu_famil Line 304  int arm_cpu_family_init(struct cpu_famil
304  /*  cpu_arm_coproc.c:  */  /*  cpu_arm_coproc.c:  */
305  void arm_coproc_15(struct cpu *cpu, int opcode1, int opcode2, int l_bit,  void arm_coproc_15(struct cpu *cpu, int opcode1, int opcode2, int l_bit,
306          int crn, int crm, int rd);          int crn, int crm, int rd);
307  void arm_coproc_i80321(struct cpu *cpu, int opcode1, int opcode2, int l_bit,  void arm_coproc_i80321_6(struct cpu *cpu, int opcode1, int opcode2, int l_bit,
308          int crn, int crm, int rd);          int crn, int crm, int rd);
309  void arm_coproc_i80321_14(struct cpu *cpu, int opcode1, int opcode2, int l_bit,  void arm_coproc_xscale_14(struct cpu *cpu, int opcode1, int opcode2, int l_bit,
310          int crn, int crm, int rd);          int crn, int crm, int rd);
311    
312  /*  memory_arm.c:  */  /*  memory_arm.c:  */
313  int arm_translate_address(struct cpu *cpu, uint64_t vaddr,  int arm_translate_v2p(struct cpu *cpu, uint64_t vaddr,
314            uint64_t *return_addr, int flags);
315    int arm_translate_v2p_mmu(struct cpu *cpu, uint64_t vaddr,
316          uint64_t *return_addr, int flags);          uint64_t *return_addr, int flags);
317    
318  #endif  /*  CPU_ARM_H  */  #endif  /*  CPU_ARM_H  */

Legend:
Removed from v.14  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26