OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [commands/] [CMD_load_seg.txt] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
 
2
3
`define CMD_load_seg    #AUTOGEN_NEXT_CMD
4
// glob_param_1[15:0]  --> new selector
5
// glob_param_1[18:16] --> segment to load (0-5, ES,CS,SS,DS,FS,GS, 6-LDT, 7-TR)
6
// glob_param_1[19]    --> flag: no write bit
7
// glob_param_1[20]    --> flag: cpl from mc_param_3[1:0]
8
 
9
`define CMDEX_load_seg_STEP_1    4'd0
10
`define CMDEX_load_seg_STEP_2    4'd1
11
12
 
13
 
14
15
IF(mc_cmd == `CMD_load_seg && (~(protected_mode) || (protected_mode && mc_cmdex_last == `CMDEX_load_seg_STEP_2)));
16
    RETURN();
17
ENDIF();
18
 
19
IF(mc_cmd == `CMD_load_seg && protected_mode && mc_cmdex_last == `CMDEX_load_seg_STEP_1);
20
    `CMDEX_load_seg_STEP_2
21
ENDIF();
22
23
 
24
25
IF(rd_cmd == `CMD_load_seg && rd_cmdex == `CMDEX_load_seg_STEP_1);
26
    IF(v8086_mode);
27
        SET(rd_glob_descriptor_set);
28
        SET(rd_glob_descriptor_value, `DESC_MASK_P | `DESC_MASK_DPL | `DESC_MASK_SEG | `DESC_MASK_DATA_RWA | { 24'd0, 4'd0, glob_param_1[15:12], glob_param_1[11:0], 4'd0, 16'hFFFF });
29
    ENDIF();
30
 
31
    IF(real_mode);
32
        SET(rd_glob_descriptor_set);
33
        SET(rd_glob_descriptor_value, `DESC_MASK_P | `DESC_MASK_SEG | { 24'd0, 4'd0, glob_param_1[15:12], glob_param_1[11:0], 4'd0, 16'd0 });
34
    ENDIF();
35
 
36
    IF(protected_mode);
37
        SET(rd_glob_descriptor_set);
38
        SET(rd_glob_descriptor_value, `DESC_MASK_SEG | { 24'd0, 24'd0, 16'd0 });
39
    ENDIF();
40
ENDIF();
41
42
 
43
44
IF(rd_cmd == `CMD_load_seg && rd_cmdex == `CMDEX_load_seg_STEP_2);
45
 
46
    IF(~(protected_mode && glob_param_1[15:2] == 14'd0)); // load null
47
 
48
        SET(rd_error_code, { glob_param_1[15:2], 2'd0 });
49
 
50
        SET(rd_glob_descriptor_set);
51
        SET(rd_glob_descriptor_value, read_8);
52
 
53
        IF(rd_mutex_busy_active); SET(rd_waiting); // wait for previous step -- exception possible
54
        ELSE();
55
            SET(read_system_descriptor);
56
 
57
            IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
58
        ENDIF();
59
    ENDIF();
60
ENDIF();
61
62
 
63
64
wire [1:0] e_cpl_current;
65
 
66
assign e_cpl_current = (glob_param_1[`MC_PARAM_1_FLAG_CPL_FROM_PARAM_3_BIT])? glob_param_3[`SELECTOR_BITS_RPL] : cpl;
67
 
68
assign exe_load_seg_gp_fault =
69
    exe_cmd == `CMD_load_seg && exe_cmdex == `CMDEX_load_seg_STEP_2 && (
70
        (exe_segment < `SEGMENT_LDT && exe_segment != `SEGMENT_CS) && (
71
            exe_descriptor[`DESC_BIT_SEG] == `FALSE ||
72
            (exe_segment == `SEGMENT_SS && (
73
                exe_selector[`SELECTOR_BITS_RPL] != e_cpl_current ||
74
                `DESC_IS_CODE(exe_descriptor) ||
75
                `DESC_IS_DATA_RO(exe_descriptor) ||
76
                exe_descriptor[`DESC_BITS_DPL] != e_cpl_current
77
            )) ||
78
            (exe_segment != `SEGMENT_SS && (
79
                `DESC_IS_CODE_EO(exe_descriptor) ||
80
                ((`DESC_IS_DATA(exe_descriptor) || `DESC_IS_CODE_NON_CONFORMING(exe_descriptor)) && exe_privilege_not_accepted)
81
            ))
82
        ) ||
83
        (exe_segment == `SEGMENT_LDT && (exe_descriptor[`DESC_BIT_SEG] || exe_descriptor[`DESC_BITS_TYPE] != `DESC_LDT)
84
        ) ||
85
        (exe_segment == `SEGMENT_TR && (exe_descriptor[`DESC_BIT_SEG] ||
86
            (exe_descriptor[`DESC_BITS_TYPE] != `DESC_TSS_AVAIL_386 && exe_descriptor[`DESC_BITS_TYPE] != `DESC_TSS_AVAIL_286))
87
        ) ||
88
        (exe_segment == `SEGMENT_CS && (
89
            exe_selector[`SELECTOR_BITS_RPL] < cpl ||
90
            exe_descriptor[`DESC_BIT_SEG] == `FALSE ||
91
            `DESC_IS_DATA(exe_descriptor) ||
92
            (`DESC_IS_CODE_NON_CONFORMING(exe_descriptor) && exe_descriptor[`DESC_BITS_DPL] != exe_selector[`SELECTOR_BITS_RPL]) ||
93
            // check_rpl > check_cpl : ignored
94
            (`DESC_IS_CODE_CONFORMING(exe_descriptor) && exe_descriptor[`DESC_BITS_DPL] > exe_selector[`SELECTOR_BITS_RPL])
95
        ))
96
    );
97
//exception, cmd_load_seg
98
assign exe_load_seg_ss_fault =
99
    exe_cmd == `CMD_load_seg && exe_cmdex == `CMDEX_load_seg_STEP_2 &&
100
    ~(glob_param_1[`MC_PARAM_1_FLAG_NP_NOT_SS_BIT]) && exe_segment == `SEGMENT_SS && exe_descriptor[`DESC_BIT_P] == `FALSE;
101
 
102
//exception, cmd_load_seg
103
assign exe_load_seg_np_fault =
104
    exe_cmd == `CMD_load_seg && exe_cmdex == `CMDEX_load_seg_STEP_2 &&
105
    (glob_param_1[`MC_PARAM_1_FLAG_NP_NOT_SS_BIT] || exe_segment != `SEGMENT_SS) && exe_descriptor[`DESC_BIT_P] == `FALSE; // with cs
106
107
 
108
 
109
110
IF(exe_cmd == `CMD_load_seg && exe_cmdex == `CMDEX_load_seg_STEP_1);
111
 
112
    IF(protected_mode);
113
        IF(((glob_param_1[18:16] == `SEGMENT_SS || glob_param_1[18:16] == `SEGMENT_TR || glob_param_1[18:16] == `SEGMENT_CS) && glob_param_1[15:2] == 14'd0) || // CS, SS or TR can not be null
114
           ((glob_param_1[18:16] == `SEGMENT_LDT || glob_param_1[18:16] == `SEGMENT_TR) && glob_param_1[`SELECTOR_BIT_TI] == 1'b1));
115
 
116
            SET(exe_waiting);
117
            SET(exe_trigger_gp_fault); //exception GP(val)
118
            SET(exe_error_code, { glob_param_1[15:2], 2'd0 });
119
        ENDIF();
120
    ENDIF();
121
ENDIF();
122
123
 
124
125
IF(exe_cmd == `CMD_load_seg && exe_cmdex == `CMDEX_load_seg_STEP_2);
126
 
127
    IF(~(protected_mode && glob_param_1[15:2] == 14'd0)); // load null
128
        SET(exe_error_code, { glob_param_1[15:2], 2'd0 });
129
 
130
        IF(exe_load_seg_gp_fault || exe_load_seg_ss_fault || exe_load_seg_np_fault); SET(exe_waiting); ENDIF();
131
    ENDIF();
132
ENDIF();
133
134
 
135
136
IF(wr_cmd == `CMD_load_seg && wr_cmdex == `CMDEX_load_seg_STEP_1);
137
 
138
    SET(wr_not_finished);
139
 
140
    SET(wr_seg_sel, glob_param_1[15:0]);
141
 
142
    IF(v8086_mode);
143
        SET(wr_seg_cache_valid,  `TRUE);
144
 
145
        SET(write_seg_cache);
146
 
147
        SET(write_seg_sel);
148
        SET(write_seg_cache_valid);
149
 
150
        SET(wr_seg_rpl,      2'd3);
151
        SET(write_seg_rpl);
152
    ENDIF();
153
 
154
    IF(real_mode);
155
        SET(wr_seg_cache_valid,  `TRUE);
156
 
157
        SET(write_seg_cache);
158
        SET(wr_seg_cache_mask, `DESC_MASK_G | `DESC_MASK_D_B | `DESC_MASK_AVL | `DESC_MASK_LIMIT | `DESC_MASK_DPL | `DESC_MASK_TYPE);
159
 
160
        SET(write_seg_sel);
161
        SET(write_seg_cache_valid);
162
 
163
        SET(wr_seg_rpl,      2'd0);
164
        SET(write_seg_rpl);
165
    ENDIF();
166
 
167
    IF(protected_mode && glob_param_1[15:2] == 14'd0); // load null
168
        //wr_seg_cache_valid -- default false
169
        SET(write_seg_cache);
170
 
171
        SET(write_seg_sel);
172
        SET(write_seg_cache_valid);
173
 
174
        SET(wr_seg_rpl, glob_param_1[1:0]);
175
        SET(write_seg_rpl);
176
    ENDIF();
177
ENDIF();
178
179
 
180
181
IF(wr_cmd == `CMD_load_seg && wr_cmdex == `CMDEX_load_seg_STEP_2);
182
 
183
    SET(wr_not_finished);
184
 
185
    IF(~(protected_mode && (glob_param_1[15:2] == 14'd0 || glob_param_1[`MC_PARAM_1_FLAG_NO_WRITE_BIT]))); // load null or cs
186
 
187
        SET(wr_seg_rpl,          glob_param_1[1:0]);
188
        SET(wr_seg_cache_valid,  `TRUE);
189
        SET(wr_seg_sel,          glob_param_1[15:0]);
190
 
191
        IF(glob_param_1[18:16] == `SEGMENT_TR || (glob_param_1[18:16] < `SEGMENT_LDT && `DESC_IS_NOT_ACCESSED(glob_descriptor)));
192
 
193
            IF(glob_param_1[18:16] == `SEGMENT_TR); SET(write_system_busy_tss);
194
            ELSE();                                 SET(write_system_touch);
195
            ENDIF();
196
 
197
            IF(~(write_for_wr_ready)); SET(wr_waiting);
198
            ELSE();
199
                SET(write_seg_cache);
200
                //wr_seg_cache_mask zero
201
 
202
                SET(write_seg_sel);
203
                SET(write_seg_cache_valid);
204
                SET(write_seg_rpl);
205
            ENDIF();
206
        ENDIF();
207
 
208
        IF(glob_param_1[18:16] == `SEGMENT_LDT || (glob_param_1[18:16] < `SEGMENT_LDT && `DESC_IS_ACCESSED(glob_descriptor)));
209
            SET(write_seg_cache);
210
            //wr_seg_cache_mask zero
211
 
212
            SET(write_seg_sel);
213
            SET(write_seg_cache_valid);
214
            SET(write_seg_rpl);
215
        ENDIF();
216
    ENDIF();
217
ENDIF();
218
219
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.