OSDN Git Service

[VM] Move lib* to libnew . WIP.
[csp-qt/common_source_project-fm7.git] / source / src / vm / libcpu_newdev / libcpu_i386 / vtlb.h
1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles
3 /***************************************************************************
4
5     vtlb.h
6
7     Generic virtual TLB implementation.
8
9 ***************************************************************************/
10
11 #pragma once
12
13 #ifndef __VTLB_H__
14 #define __VTLB_H__
15
16
17
18 /***************************************************************************
19     CONSTANTS
20 ***************************************************************************/
21
22 #define VTLB_FLAGS_MASK             0xff
23
24 #define VTLB_READ_ALLOWED           0x01        /* (1 << TRANSLATE_READ) */
25 #define VTLB_WRITE_ALLOWED          0x02        /* (1 << TRANSLATE_WRITE) */
26 #define VTLB_FETCH_ALLOWED          0x04        /* (1 << TRANSLATE_FETCH) */
27 #define VTLB_FLAG_VALID             0x08
28 #define VTLB_USER_READ_ALLOWED      0x10        /* (1 << TRANSLATE_READ_USER) */
29 #define VTLB_USER_WRITE_ALLOWED     0x20        /* (1 << TRANSLATE_WRITE_USER) */
30 #define VTLB_USER_FETCH_ALLOWED     0x40        /* (1 << TRANSLATE_FETCH_USER) */
31 #define VTLB_FLAG_FIXED             0x80
32
33
34
35 /***************************************************************************
36     TYPE DEFINITIONS
37 ***************************************************************************/
38
39 /* represents an entry in the VTLB */
40 typedef UINT32 vtlb_entry;
41
42
43 /* opaque structure describing VTLB state */
44 struct vtlb_state;
45
46
47
48 /***************************************************************************
49     FUNCTION PROTOTYPES
50 ***************************************************************************/
51
52
53 /* ----- initialization/teardown ----- */
54
55 /* allocate a new VTLB for the given CPU */
56 vtlb_state *vtlb_alloc(void *cpu, address_spacenum space, int fixed_entries, int dynamic_entries);
57
58 /* free an allocated VTLB */
59 void vtlb_free(vtlb_state *vtlb);
60
61
62 /* ----- filling ----- */
63
64 /* called by the CPU core in response to an unmapped access */
65 int vtlb_fill(vtlb_state *vtlb, offs_t address, int intention);
66
67 /* load a fixed VTLB entry */
68 void vtlb_load(vtlb_state *vtlb, int entrynum, int numpages, offs_t address, vtlb_entry value);
69
70 /* load a dynamic VTLB entry */
71 void vtlb_dynload(vtlb_state *vtlb, UINT32 index, offs_t address, vtlb_entry value);
72
73 /* ----- flushing ----- */
74
75 /* flush all knowledge from the dynamic part of the VTLB */
76 void vtlb_flush_dynamic(vtlb_state *vtlb);
77
78 /* flush knowledge of a particular address from the VTLB */
79 void vtlb_flush_address(vtlb_state *vtlb, offs_t address);
80
81
82 /* ----- accessors ----- */
83
84 /* return a pointer to the base of the linear VTLB lookup table */
85 const vtlb_entry *vtlb_table(vtlb_state *vtlb);
86
87
88 #endif /* __VTLB_H__ */