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

Subversion Repositories ao486

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
 
2
3
 
4
//------------------------------------------------------------------------------
5
`define CMD_CALL        #AUTOGEN_NEXT_CMD
6
 
7
`define CMDEX_CALL_Ev_STEP_0                4'd0
8
`define CMDEX_CALL_Jv_STEP_0                4'd1
9
`define CMDEX_CALL_Ep_STEP_0                4'd2
10
`define CMDEX_CALL_Ap_STEP_0                4'd3
11
 
12
`define CMDEX_CALL_Ev_Jv_STEP_1             4'd4
13
 
14
`define CMDEX_CALL_Ep_STEP_1                4'd5
15
`define CMDEX_CALL_Ap_STEP_1                4'd6
16
 
17
`define CMDEX_CALL_real_v8086_STEP_0        4'd7
18
`define CMDEX_CALL_real_v8086_STEP_1        4'd8
19
`define CMDEX_CALL_real_v8086_STEP_2        4'd9
20
`define CMDEX_CALL_real_v8086_STEP_3        4'd10
21
 
22
`define CMDEX_CALL_protected_STEP_0         4'd11
23
`define CMDEX_CALL_protected_STEP_1         4'd12
24
 
25
`define CMDEX_CALL_protected_seg_STEP_0     4'd13
26
`define CMDEX_CALL_protected_seg_STEP_1     4'd14
27
`define CMDEX_CALL_protected_seg_STEP_2     4'd15
28
 
29
//------------------------------------------------------------------------------
30
`define CMD_CALL_2      #AUTOGEN_NEXT_CMD
31
 
32
`define CMDEX_CALL_2_protected_seg_STEP_3   4'd0
33
`define CMDEX_CALL_2_protected_seg_STEP_4   4'd1
34
 
35
`define CMDEX_CALL_2_task_switch_STEP_0     4'd2
36
 
37
`define CMDEX_CALL_2_task_gate_STEP_0       4'd3
38
`define CMDEX_CALL_2_task_gate_STEP_1       4'd4
39
 
40
`define CMDEX_CALL_2_call_gate_STEP_0       4'd5
41
// glob_param_1[15:0]  -- CS selector
42
// glob_param_1[18:16] -- CS segment type
43
// glob_param_1[19]    -- 0: 286, 1: 386 CALL GATE
44
// glob_param_1[24:20] -- param count
45
// glob_param_2        -- eip
46
 
47
// glob_descriptor -- new cs descriptor
48
 
49
`define CMDEX_CALL_2_call_gate_STEP_1       4'd6
50
`define CMDEX_CALL_2_call_gate_STEP_2       4'd7
51
 
52
`define CMDEX_CALL_2_call_gate_same_STEP_0  4'd8
53
`define CMDEX_CALL_2_call_gate_same_STEP_1  4'd9
54
`define CMDEX_CALL_2_call_gate_same_STEP_2  4'd10
55
`define CMDEX_CALL_2_call_gate_same_STEP_3  4'd11
56
 
57
`define CMDEX_CALL_2_call_gate_more_STEP_0  4'd12
58
`define CMDEX_CALL_2_call_gate_more_STEP_1  4'd13
59
// glob_param_1[15:0]  -- CS selector
60
// glob_param_1[18:16] -- CS segment type
61
// glob_param_1[19]    -- 0: 286, 1: 386 CALL GATE
62
// glob_param_1[24:20] -- param count
63
// glob_param_2        -- eip
64
// glob_param_3[15:0]  -- new ss
65
// glob_param_4        -- new esp
66
 
67
// glob_descriptor -- new cs descriptor
68
 
69
//after exe:
70
// glob_param_1[15:0]  -- new ss
71
// glob_param_1[18:16] -- SS type
72
// glob_param_2        -- new eip
73
// glob_param_3        -- cs selector, type, call gate type, call gate param
74
// glob_param_4        -- new esp
75
 
76
// glob_descriptor_2   -- new cs descriptor
77
 
78
`define CMDEX_CALL_2_call_gate_more_STEP_2  4'd14
79
`define CMDEX_CALL_2_call_gate_more_STEP_3  4'd15
80
 
81
//------------------------------------------------------------------------------
82
`define CMD_CALL_3      #AUTOGEN_NEXT_CMD
83
 
84
`define CMDEX_CALL_3_call_gate_more_STEP_4  4'd0
85
// copy parameters - first
86
`define CMDEX_CALL_3_call_gate_more_STEP_5  4'd1
87
// copy parameters - second
88
 
89
`define CMDEX_CALL_3_call_gate_more_STEP_6  4'd2
90
// write return_CS
91
`define CMDEX_CALL_3_call_gate_more_STEP_7  4'd3
92
// write return_EIP; save esp
93
 
94
`define CMDEX_CALL_3_call_gate_more_STEP_8  4'd4
95
// check new_eip; load_ss()
96
 
97
`define CMDEX_CALL_3_call_gate_more_STEP_9  4'd5
98
// move glob_param,descriptor for cs save
99
// load_cs()
100
 
101
// glob_param_1[15:0]  -- new cs
102
// glob_param_1[18:16] -- CS type
103
// glob_param_2        -- new eip
104
// glob_descriptor -- new cs descriptor
105
 
106
`define CMDEX_CALL_3_call_gate_more_STEP_10 4'd6
107
// reset pipeline; save eip
108
109
 
110
111
dec_ready_call_jmp_imm && (decoder[7:0] == 8'h9A || decoder[7:0] == 8'hE8)
112
`CMD_CALL
113
IF(decoder[1] == 1'b0); SET(dec_cmdex, `CMDEX_CALL_Jv_STEP_0); ELSE(); SET(dec_cmdex, `CMDEX_CALL_Ap_STEP_0); ENDIF();
114
SET(consume_call_jmp_imm);
115
SET(dec_is_complex);
116
117
 
118
119
dec_ready_modregrm_one && decoder[7:0] == 8'hFF && (decoder[13:11] == 3'd2 || decoder[13:11] == 3'd3)
120
prefix_group_1_lock || (decoder[13:11] == 3'd3 && `DEC_MODREGRM_IS_MOD_11)
121
`CMD_CALL
122
IF(decoder[11] == 1'b0); SET(dec_cmdex, `CMDEX_CALL_Ev_STEP_0); ELSE(); SET(dec_cmdex, `CMDEX_CALL_Ep_STEP_0); ENDIF();
123
SET(consume_modregrm_one);
124
SET(dec_is_complex);
125
126
 
127
128
IF(`CMDEX_CALL_Ev_STEP_0);
129
    LOOP(`CMDEX_CALL_Ev_Jv_STEP_1);
130
ENDIF();
131
 
132
IF(`CMDEX_CALL_Jv_STEP_0);
133
    LOOP(`CMDEX_CALL_Ev_Jv_STEP_1);
134
ENDIF();
135
 
136
IF(`CMDEX_CALL_Ep_STEP_0);
137
    `CMDEX_CALL_Ep_STEP_1
138
ENDIF();
139
 
140
IF(`CMDEX_CALL_Ap_STEP_0);
141
    `CMDEX_CALL_Ap_STEP_1
142
ENDIF();
143
 
144
IF(mc_cmd == `CMD_CALL && (mc_cmdex_last == `CMDEX_CALL_Ep_STEP_1 || mc_cmdex_last == `CMDEX_CALL_Ap_STEP_1) && (real_mode || v8086_mode));
145
    `CMDEX_CALL_real_v8086_STEP_0
146
    `CMDEX_CALL_real_v8086_STEP_1
147
    `CMDEX_CALL_real_v8086_STEP_2
148
    CALL(`CMDEX_load_seg_STEP_1);
149
    LOOP(`CMDEX_CALL_real_v8086_STEP_3);
150
ENDIF();
151
 
152
IF(mc_cmd == `CMD_CALL && (mc_cmdex_last == `CMDEX_CALL_Ep_STEP_1 || mc_cmdex_last == `CMDEX_CALL_Ap_STEP_1) && (protected_mode));
153
    `CMDEX_CALL_protected_STEP_0
154
    `CMDEX_CALL_protected_STEP_1
155
 
156
    IF(`CMDEX_CALL_protected_STEP_1 && glob_descriptor[`DESC_BIT_SEG]);
157
        `CMDEX_CALL_protected_seg_STEP_0
158
        `CMDEX_CALL_protected_seg_STEP_1
159
        `CMDEX_CALL_protected_seg_STEP_2
160
        `CMDEX_CALL_2_protected_seg_STEP_3
161
        LOOP(`CMDEX_CALL_2_protected_seg_STEP_4);
162
    ENDIF();
163
 
164
    IF(`CMDEX_CALL_protected_STEP_1 && glob_descriptor[`DESC_BIT_SEG] == `FALSE && (glob_descriptor[`DESC_BITS_TYPE] == `DESC_TSS_AVAIL_386 || glob_descriptor[`DESC_BITS_TYPE] == `DESC_TSS_AVAIL_286));
165
        `CMDEX_CALL_2_task_switch_STEP_0
166
 
167
        //zero length
168
        IF(`CMDEX_CALL_2_task_switch_STEP_0 && glob_param_3[21:18] == 4'd0);
169
            `CMDEX_CALL_2_task_switch_STEP_0
170
        ENDIF();
171
 
172
        //not zero length
173
        IF(`CMDEX_CALL_2_task_switch_STEP_0 && glob_param_3[21:18] != 4'd0);
174
            JMP(`CMDEX_task_switch_STEP_1);
175
        ENDIF();
176
    ENDIF();
177
 
178
    IF(`CMDEX_CALL_protected_STEP_1 && glob_descriptor[`DESC_BIT_SEG] == `FALSE && glob_descriptor[`DESC_BITS_TYPE] == `DESC_TASK_GATE);
179
        `CMDEX_CALL_2_task_gate_STEP_0
180
        `CMDEX_CALL_2_task_gate_STEP_1
181
        JMP(`CMDEX_task_switch_STEP_1);
182
    ENDIF();
183
 
184
    IF(`CMDEX_CALL_protected_STEP_1 && glob_descriptor[`DESC_BIT_SEG] == `FALSE && (glob_descriptor[`DESC_BITS_TYPE] == `DESC_CALL_GATE_386 || glob_descriptor[`DESC_BITS_TYPE] == `DESC_CALL_GATE_286));
185
        `CMDEX_CALL_2_call_gate_STEP_0
186
        `CMDEX_CALL_2_call_gate_STEP_1
187
        `CMDEX_CALL_2_call_gate_STEP_2
188
 
189
        IF(`CMDEX_CALL_2_call_gate_STEP_2 && `DESC_IS_CODE_NON_CONFORMING(glob_descriptor) && glob_descriptor[`DESC_BITS_DPL] < cpl);
190
            `CMDEX_CALL_2_call_gate_more_STEP_0
191
            `CMDEX_CALL_2_call_gate_more_STEP_1
192
            `CMDEX_CALL_2_call_gate_more_STEP_2
193
            `CMDEX_CALL_2_call_gate_more_STEP_3
194
 
195
            IF(`CMDEX_CALL_2_call_gate_more_STEP_3 && glob_param_3[24:20] != 5'd0);
196
                `CMDEX_CALL_3_call_gate_more_STEP_4
197
 
198
                IF(`CMDEX_CALL_3_call_gate_more_STEP_4 && glob_param_3[24:20] == 5'd1);
199
                    `CMDEX_CALL_3_call_gate_more_STEP_6
200
                ENDIF();
201
 
202
                IF(`CMDEX_CALL_3_call_gate_more_STEP_4 && glob_param_3[24:20] != 5'd1);
203
                    `CMDEX_CALL_3_call_gate_more_STEP_5
204
 
205
                    IF(`CMDEX_CALL_3_call_gate_more_STEP_5 && glob_param_3[24:20] == 5'd1);
206
                        `CMDEX_CALL_3_call_gate_more_STEP_6
207
                    ENDIF();
208
 
209
                    IF(`CMDEX_CALL_3_call_gate_more_STEP_5 && glob_param_3[24:20] != 5'd1);
210
                        `CMDEX_CALL_3_call_gate_more_STEP_5
211
                    ENDIF();
212
            ENDIF();
213
 
214
            IF(`CMDEX_CALL_2_call_gate_more_STEP_3 && glob_param_3[24:20] == 5'd0);
215
                `CMDEX_CALL_3_call_gate_more_STEP_6
216
            ENDIF();
217
 
218
            IF(`CMDEX_CALL_3_call_gate_more_STEP_6);
219
                `CMDEX_CALL_3_call_gate_more_STEP_7
220
                `CMDEX_CALL_3_call_gate_more_STEP_8
221
                `CMDEX_CALL_3_call_gate_more_STEP_9
222
                LOOP(`CMDEX_CALL_3_call_gate_more_STEP_10);
223
            ENDIF();
224
        ENDIF();
225
 
226
        IF(`CMDEX_CALL_2_call_gate_STEP_2 && ~(`DESC_IS_CODE_NON_CONFORMING(glob_descriptor) && glob_descriptor[`DESC_BITS_DPL] < cpl));
227
            `CMDEX_CALL_2_call_gate_same_STEP_0
228
            `CMDEX_CALL_2_call_gate_same_STEP_1
229
            `CMDEX_CALL_2_call_gate_same_STEP_2
230
            LOOP(`CMDEX_CALL_2_call_gate_same_STEP_3);
231
        ENDIF();
232
    ENDIF();
233
ENDIF();
234
235
 
236
237
wire [4:0] rd_call_gate_param;
238
 
239
assign rd_call_gate_param = glob_param_3[24:20] - 5'd1;
240
241
 
242
243
IF(rd_cmd == `CMD_CALL && rd_cmdex == `CMDEX_CALL_Ev_STEP_0);
244
 
245
    IF(rd_modregrm_mod == 2'b11);
246
 
247
        SET(rd_src_is_rm);
248
 
249
        IF(rd_mutex_busy_modregrm_rm); SET(rd_waiting); ENDIF();
250
    ENDIF();
251
 
252
    IF(rd_modregrm_mod != 2'b11);
253
 
254
        SET(rd_src_is_memory);
255
 
256
        IF(rd_mutex_busy_memory); SET(rd_waiting);
257
        ELSE();
258
            SET(read_virtual);
259
 
260
            IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
261
        ENDIF();
262
    ENDIF();
263
ENDIF();
264
265
 
266
267
IF(rd_cmd == `CMD_CALL && rd_cmdex == `CMDEX_CALL_Jv_STEP_0);
268
    SET(rd_src_is_imm);
269
    SET(rd_dst_is_eip);
270
ENDIF();
271
272
 
273
274
IF(rd_cmd == `CMD_CALL && (rd_cmdex == `CMDEX_CALL_Ep_STEP_0 || rd_cmdex == `CMDEX_CALL_Ep_STEP_1));
275
 
276
    IF(rd_cmdex == `CMDEX_CALL_Ep_STEP_1);
277
        SET(address_ea_buffer);
278
        SET(read_length_word);
279
    ENDIF();
280
 
281
    SET(rd_src_is_memory);
282
 
283
    IF(rd_mutex_busy_memory); SET(rd_waiting);
284
    ELSE();
285
        SET(read_virtual);
286
 
287
        IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
288
    ENDIF();
289
ENDIF();
290
291
 
292
293
IF(rd_cmd == `CMD_CALL && rd_cmdex == `CMDEX_CALL_Ap_STEP_0);
294
 
295
    SET(rd_src_is_imm);
296
ENDIF();
297
298
 
299
300
IF(rd_cmd == `CMD_CALL && rd_cmdex == `CMDEX_CALL_Ap_STEP_1);
301
    SET(rd_extra_wire, rd_decoder[55:24]);
302
ENDIF();
303
304
 
305
306
IF(rd_cmd == `CMD_CALL && rd_cmdex == `CMDEX_CALL_protected_STEP_0);
307
 
308
    IF(rd_mutex_busy_active); SET(rd_waiting); // wait for previous step -- loading glob_param_1
309
    ELSE();
310
 
311
        IF(glob_param_1[15:2] != 14'd0); // load null
312
 
313
            SET(rd_error_code, `SELECTOR_FOR_CODE(glob_param_1));
314
 
315
            SET(rd_glob_descriptor_set);
316
            SET(rd_glob_descriptor_value, read_8);
317
 
318
            SET(rd_glob_param_3_set);
319
            SET(rd_glob_param_3_value, 32'd0);
320
 
321
            SET(read_system_descriptor);
322
 
323
            IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
324
        ENDIF();
325
    ENDIF();
326
ENDIF();
327
328
 
329
330
IF(rd_cmd == `CMD_CALL_2 && rd_cmdex == `CMDEX_CALL_2_task_gate_STEP_0);
331
 
332
    IF(rd_mutex_busy_active); SET(rd_waiting);  // wait for previous step -- loading glob_param_1
333
    ELSE();
334
        SET(rd_glob_param_1_set);
335
        SET(rd_glob_param_1_value, { 16'd0, glob_descriptor[31:16] });
336
    ENDIF();
337
ENDIF();
338
339
 
340
341
IF(rd_cmd == `CMD_CALL_2 && rd_cmdex == `CMDEX_CALL_2_task_gate_STEP_1);
342
 
343
//TODO: null not checked
344
    IF(glob_param_1[`SELECTOR_BIT_TI] == 1'b0); // skip if TI set
345
 
346
        SET(rd_error_code, `SELECTOR_FOR_CODE(glob_param_1));
347
 
348
        SET(rd_glob_descriptor_set);
349
        SET(rd_glob_descriptor_value, read_8);
350
 
351
        SET(read_system_descriptor);
352
 
353
        IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
354
    ENDIF();
355
ENDIF();
356
357
 
358
359
IF(rd_cmd == `CMD_CALL_2 && rd_cmdex == `CMDEX_CALL_2_call_gate_STEP_1);
360
 
361
    IF(rd_mutex_busy_active); SET(rd_waiting); // wait for previous step -- loading glob_param_1
362
    ELSE();
363
 
364
        IF(glob_param_1[15:2] != 14'd0); // load null
365
 
366
            SET(rd_error_code, `SELECTOR_FOR_CODE(glob_param_1));
367
 
368
            SET(rd_glob_descriptor_set);
369
            SET(rd_glob_descriptor_value, read_8);
370
 
371
            SET(read_system_descriptor);
372
 
373
            IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
374
        ENDIF();
375
    ENDIF();
376
ENDIF();
377
378
 
379
380
IF(rd_cmd == `CMD_CALL_3 && (rd_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_4 || rd_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_5));
381
 
382
    IF(~(glob_param_3[19])); SET(read_length_word);  ENDIF();
383
    IF(glob_param_3[19]);    SET(read_length_dword); ENDIF();
384
 
385
    IF(rd_ready);
386
        SET(rd_glob_param_3_set);
387
        SET(rd_glob_param_3_value, { 7'd0, rd_call_gate_param, glob_param_3[19:0] });
388
    ENDIF();
389
 
390
    SET(address_stack_pop_for_call);
391
    SET(address_stack_pop_next);
392
 
393
    IF(rd_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_4);
394
        SET(address_stack_save);
395
        SET(address_stack_for_call_param_first);
396
    ENDIF();
397
 
398
    IF(rd_mutex_busy_active); SET(rd_waiting); // waiting for esp in 'address_waiting'
399
    ELSE();
400
 
401
        SET(read_virtual);
402
 
403
        SET(rd_glob_param_5_set);
404
        SET(rd_glob_param_5_value, read_4);
405
 
406
        IF(~(read_for_rd_ready)); SET(rd_waiting); ENDIF();
407
    ENDIF();
408
ENDIF();
409
410
 
411
412
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_protected_STEP_1);
413
    SET(offset_esp);
414
ENDIF();
415
416
 
417
418
IF(exe_cmd == `CMD_CALL_2  && exe_cmdex == `CMDEX_CALL_2_protected_seg_STEP_3);
419
 
420
    IF(glob_param_2 > glob_desc_limit);
421
        SET(exe_waiting);
422
        SET(exe_trigger_gp_fault); //exception GP(0)
423
    ENDIF();
424
ENDIF();
425
426
 
427
428
IF(exe_cmd == `CMD_CALL && (exe_cmdex == `CMDEX_CALL_Ev_STEP_0 || exe_cmdex == `CMDEX_CALL_Ep_STEP_0 || exe_cmdex == `CMDEX_CALL_Ap_STEP_0));
429
 
430
    IF(exe_cmdex == `CMDEX_CALL_Ev_STEP_0);
431
        IF(exe_mutex_current[`MUTEX_ESP_BIT]); SET(exe_waiting); ENDIF();
432
 
433
        SET(exe_result_push, exe_eip);
434
    ENDIF();
435
 
436
    IF(exe_operand_32bit);
437
        SET(exe_glob_param_2_set);
438
        SET(exe_glob_param_2_value, src);
439
    ELSE();
440
        SET(exe_glob_param_2_set);
441
        SET(exe_glob_param_2_value, { 16'd0, src[15:0] });
442
    ENDIF();
443
ENDIF();
444
445
 
446
447
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_Jv_STEP_0);
448
 
449
    SET(exe_result_push, exe_eip);
450
 
451
    IF(exe_mutex_current[`MUTEX_ESP_BIT]); SET(exe_waiting); ENDIF();
452
 
453
    IF(exe_operand_32bit);
454
        SET(exe_glob_param_2_set);
455
        SET(exe_glob_param_2_value, exe_arith_add[31:0]);
456
    ELSE();
457
        SET(exe_glob_param_2_set);
458
        SET(exe_glob_param_2_value, { 16'd0, exe_arith_add[15:0] });
459
    ENDIF();
460
ENDIF();
461
462
 
463
464
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_Ev_Jv_STEP_1);
465
 
466
    SET(exe_eip_from_glob_param_2);
467
 
468
    IF(glob_param_2 > cs_limit);
469
        SET(exe_waiting);
470
        SET(exe_trigger_gp_fault); //exception GP(0)
471
    ENDIF();
472
ENDIF();
473
474
 
475
476
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_Ep_STEP_1);
477
 
478
    SET(exe_glob_param_1_set);
479
    SET(exe_glob_param_1_value, { 13'd0, `SEGMENT_CS, src[15:0] });
480
ENDIF();
481
482
 
483
484
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_Ap_STEP_1);
485
 
486
    IF(exe_operand_32bit);
487
        SET(exe_glob_param_1_set);
488
        SET(exe_glob_param_1_value, { 13'd0, `SEGMENT_CS, exe_extra[31:16] });
489
    ELSE();
490
        SET(exe_glob_param_1_set);
491
        SET(exe_glob_param_1_value, { 13'd0, `SEGMENT_CS, exe_extra[15:0] });
492
    ENDIF();
493
ENDIF();
494
495
 
496
497
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_real_v8086_STEP_0);
498
 
499
    SET(exe_result_push, { 16'd0, cs[15:0] });
500
 
501
    IF(exe_operand_32bit && glob_param_2 > cs_limit);
502
        SET(exe_waiting);
503
        SET(exe_trigger_gp_fault); //exception GP(0)
504
    ENDIF();
505
ENDIF();
506
507
 
508
509
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_real_v8086_STEP_1);
510
 
511
    SET(exe_result_push, exe_eip);
512
 
513
    IF(exe_mutex_current[`MUTEX_ACTIVE_BIT]); SET(exe_waiting); ENDIF(); // wait for write to finish (esp saved)
514
ENDIF();
515
516
 
517
518
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_real_v8086_STEP_2);
519
    IF(exe_operand_16bit && glob_param_2 > cs_limit);
520
        SET(exe_waiting);
521
        SET(exe_trigger_gp_fault); //exception GP(0)
522
    ENDIF();
523
ENDIF();
524
525
 
526
527
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_real_v8086_STEP_3);
528
    SET(exe_eip_from_glob_param_2);
529
ENDIF();
530
531
 
532
533
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_protected_seg_STEP_0);
534
 
535
    SET(offset_call);
536
 
537
    SET(exe_result_push, { 16'd0, cs[15:0] });
538
 
539
    SET(exe_glob_descriptor_2_set);
540
    SET(exe_glob_descriptor_2_value, glob_descriptor);
541
 
542
    SET(exe_glob_descriptor_set);
543
    SET(exe_glob_descriptor_value,  ss_cache);
544
ENDIF();
545
546
 
547
548
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_protected_seg_STEP_1);
549
 
550
    SET(offset_call);
551
 
552
    SET(exe_result_push, exe_eip);
553
ENDIF();
554
555
 
556
557
IF(exe_cmd == `CMD_CALL && exe_cmdex == `CMDEX_CALL_protected_seg_STEP_2);
558
 
559
    SET(offset_call_keep);
560
 
561
    IF(exe_mutex_current[`MUTEX_ACTIVE_BIT]);
562
        SET(exe_waiting); // wait for ss write
563
    ELSE();
564
        SET(exe_glob_descriptor_set);
565
        SET(exe_glob_descriptor_value, glob_descriptor_2);
566
    ENDIF();
567
ENDIF();
568
569
 
570
571
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_protected_seg_STEP_4);
572
    SET(exe_eip_from_glob_param_2);
573
ENDIF();
574
575
 
576
577
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_call_gate_STEP_0);
578
 
579
    SET(exe_glob_param_1_set);
580
    SET(exe_glob_param_1_value, { 7'd0, glob_descriptor[36:32], glob_descriptor[`DESC_BITS_TYPE] == `DESC_CALL_GATE_386, `SEGMENT_CS, glob_descriptor[31:16] });
581
 
582
    SET(exe_glob_param_2_set);
583
    SET(exe_glob_param_2_value, (glob_descriptor[`DESC_BITS_TYPE] == `DESC_CALL_GATE_386)? { glob_descriptor[63:48], glob_descriptor[15:0] } : { 16'd0, glob_descriptor[15:0] });
584
ENDIF();
585
586
 
587
588
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_call_gate_same_STEP_0);
589
 
590
    SET(offset_call_int_same_first);
591
 
592
    SET(exe_result_push, { 16'd0, cs[15:0] });
593
ENDIF();
594
595
 
596
597
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_call_gate_same_STEP_1);
598
 
599
    SET(offset_call_int_same_next);
600
 
601
    SET(exe_result_push, exe_eip);
602
ENDIF();
603
604
 
605
606
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_call_gate_same_STEP_2);
607
 
608
    SET(offset_call_keep);
609
 
610
    IF(glob_param_2 > glob_desc_limit);
611
        SET(exe_waiting);
612
        SET(exe_trigger_gp_fault); //exception GP(0)
613
    ENDIF();
614
ENDIF();
615
616
 
617
618
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_protected_seg_STEP_3);
619
    SET(offset_call_keep);
620
ENDIF();
621
622
 
623
624
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_call_gate_same_STEP_3);
625
    SET(exe_eip_from_glob_param_2);
626
ENDIF();
627
628
 
629
630
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_call_gate_more_STEP_1);
631
 
632
    IF(glob_param_3[15:2] == 14'd0);
633
        SET(exe_waiting);
634
        SET(exe_trigger_ts_fault); //exception TS(0)
635
    ENDIF();
636
 
637
    IF(exe_ready);
638
        SET(exe_glob_param_1_set);
639
        SET(exe_glob_param_1_value, { 13'd0, `SEGMENT_SS, glob_param_3[15:0] });
640
 
641
        SET(exe_glob_param_3_set);
642
        SET(exe_glob_param_3_value, glob_param_1);
643
 
644
        SET(exe_glob_descriptor_2_set);
645
        SET(exe_glob_descriptor_2_value, glob_descriptor);
646
    ENDIF();
647
ENDIF();
648
649
 
650
651
IF(exe_cmd == `CMD_CALL_2 && exe_cmdex == `CMDEX_CALL_2_call_gate_more_STEP_3);
652
 
653
    SET(offset_new_stack_continue);
654
 
655
    IF(ss_cache[`DESC_BIT_D_B]);
656
        SET(exe_result_push, esp);
657
    ELSE();
658
        SET(exe_result_push, { 16'd0, esp[15:0] });
659
    ENDIF();
660
ENDIF();
661
662
 
663
664
IF(exe_cmd == `CMD_CALL_3 && (exe_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_4 || exe_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_5));
665
 
666
    SET(exe_result_push, glob_param_5);
667
 
668
    SET(offset_new_stack_continue);
669
ENDIF();
670
671
 
672
673
IF(exe_cmd == `CMD_CALL_3 && exe_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_6);
674
 
675
    SET(offset_new_stack_continue);
676
 
677
    SET(exe_result_push, { 16'd0, cs[15:0] });
678
ENDIF();
679
680
 
681
682
IF(exe_cmd == `CMD_CALL_3 && exe_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_7);
683
 
684
    SET(offset_new_stack_continue);
685
 
686
    IF(glob_descriptor_2[`DESC_BIT_D_B]);
687
        SET(exe_result_push, exe_eip);
688
    ELSE();
689
        SET(exe_result_push, { 16'd0, exe_eip[15:0] });
690
    ENDIF();
691
ENDIF();
692
693
 
694
695
IF(exe_cmd == `CMD_CALL_3 && exe_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_8);
696
 
697
    IF(glob_param_2 > glob_desc_2_limit);
698
        SET(exe_waiting);
699
        SET(exe_trigger_gp_fault); //exception GP(0)
700
    ENDIF();
701
ENDIF();
702
703
 
704
705
IF(exe_cmd == `CMD_CALL_3 && exe_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_9);
706
    IF(exe_ready);
707
        SET(exe_glob_descriptor_set);
708
        SET(exe_glob_descriptor_value, glob_descriptor_2);
709
 
710
        SET(exe_glob_param_1_set);
711
        SET(exe_glob_param_1_value, glob_param_3);
712
    ENDIF();
713
ENDIF();
714
715
 
716
717
IF(exe_cmd == `CMD_CALL_3 && exe_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_10);
718
    SET(exe_eip_from_glob_param_2);
719
ENDIF();
720
721
 
722
723
IF(wr_cmd == `CMD_CALL && (wr_cmdex == `CMDEX_CALL_Ep_STEP_0 || wr_cmdex == `CMDEX_CALL_Ap_STEP_0));
724
    SET(wr_not_finished);
725
ENDIF();
726
727
 
728
729
IF(wr_cmd == `CMD_CALL && (wr_cmdex == `CMDEX_CALL_Ep_STEP_1 || wr_cmdex == `CMDEX_CALL_Ap_STEP_1));
730
    SET(wr_not_finished);
731
 
732
    SET(wr_make_esp_speculative);
733
ENDIF();
734
735
 
736
737
IF(wr_cmd == `CMD_CALL && (wr_cmdex == `CMDEX_CALL_real_v8086_STEP_0 || wr_cmdex == `CMDEX_CALL_real_v8086_STEP_1));
738
    SET(wr_not_finished);
739
 
740
    SET(wr_push_ss_fault_check);
741
    SET(wr_one_cycle_wait);
742
 
743
    IF(~(write_for_wr_ready)); SET(wr_waiting); ENDIF();
744
 
745
    IF(~(wr_push_ss_fault));
746
        SET(write_stack_virtual);
747
 
748
        SAVE(esp, wr_stack_esp);
749
    ENDIF();
750
ENDIF();
751
752
 
753
754
IF(wr_cmd == `CMD_CALL && (wr_cmdex == `CMDEX_CALL_Ev_STEP_0 || wr_cmdex == `CMDEX_CALL_Jv_STEP_0));
755
    SET(wr_not_finished);
756
 
757
    SET(wr_push_ss_fault_check);
758
    SET(wr_one_cycle_wait);
759
 
760
    IF(~(write_for_wr_ready)); SET(wr_waiting); ENDIF();
761
 
762
    IF(~(wr_push_ss_fault));
763
        SET(write_stack_virtual);
764
 
765
        SET(wr_make_esp_speculative);
766
        SAVE(esp, wr_stack_esp);
767
    ENDIF();
768
ENDIF();
769
770
 
771
772
IF(wr_cmd == `CMD_CALL && (wr_cmdex == `CMDEX_CALL_Ev_Jv_STEP_1 || wr_cmdex == `CMDEX_CALL_real_v8086_STEP_3));
773
    SET(wr_make_esp_commit);
774
 
775
    // clear pipeline
776
    SET(wr_req_reset_pr);
777
    SET(wr_req_reset_dec);
778
    SET(wr_req_reset_micro);
779
    SET(wr_req_reset_rd);
780
    SET(wr_req_reset_exe);
781
ENDIF();
782
783
 
784
785
IF(wr_cmd == `CMD_CALL && wr_cmdex == `CMDEX_CALL_real_v8086_STEP_2);
786
    SET(wr_not_finished);
787
ENDIF();
788
789
 
790
791
IF(wr_cmd == `CMD_CALL && (wr_cmdex == `CMDEX_CALL_protected_seg_STEP_0 || wr_cmdex == `CMDEX_CALL_protected_seg_STEP_1));
792
    SET(wr_not_finished);
793
 
794
    SET(wr_new_push_ss_fault_check);
795
    SET(wr_one_cycle_wait);
796
 
797
    SET(wr_error_code, (ss[`SELECTOR_BITS_RPL] != cpl)? `SELECTOR_FOR_CODE(ss) : 16'd0);
798
 
799
    IF(~(write_for_wr_ready)); SET(wr_waiting); ENDIF();
800
 
801
    IF(~(wr_new_push_ss_fault));
802
        SET(write_new_stack_virtual);
803
 
804
        SAVE(esp, wr_new_stack_esp); // speculative set in 'wr_CALL_Ep_Ap_STEP_1'
805
    ENDIF();
806
ENDIF();
807
808
 
809
810
IF(wr_cmd == `CMD_CALL && wr_cmdex == `CMDEX_CALL_protected_seg_STEP_2);
811
    SET(wr_not_finished);
812
ENDIF();
813
814
 
815
816
IF(wr_cmd == `CMD_CALL_2 && wr_cmdex == `CMDEX_CALL_2_task_switch_STEP_0);
817
    SET(wr_not_finished);
818
ENDIF();
819
820
 
821
822
IF(wr_cmd == `CMD_CALL_2 && (wr_cmdex == `CMDEX_CALL_2_call_gate_more_STEP_2 || wr_cmdex == `CMDEX_CALL_2_call_gate_more_STEP_3));
823
    SET(wr_not_finished);
824
 
825
    SET(wr_new_push_ss_fault_check);
826
    SET(wr_one_cycle_wait);
827
 
828
    SET(wr_push_length_word,  ~(glob_param_3[19]));
829
    SET(wr_push_length_dword, glob_param_3[19]);
830
 
831
    SET(wr_error_code, (glob_param_1[`SELECTOR_BITS_RPL] != cpl)? `SELECTOR_FOR_CODE(glob_param_1) : 16'd0);
832
 
833
    IF(~(write_for_wr_ready)); SET(wr_waiting); ENDIF();
834
 
835
    IF(~(wr_new_push_ss_fault));
836
        SET(write_new_stack_virtual);
837
 
838
        //esp not yet updated
839
    ENDIF();
840
ENDIF();
841
842
 
843
844
IF(wr_cmd == `CMD_CALL_3 && (
845
    wr_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_4 || wr_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_5 ||
846
    wr_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_6 || wr_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_7));
847
 
848
    SET(wr_not_finished);
849
 
850
    SET(wr_new_push_ss_fault_check);
851
    SET(wr_one_cycle_wait);
852
 
853
    SET(wr_push_length_word,  ~(glob_param_3[19]));
854
    SET(wr_push_length_dword, glob_param_3[19]);
855
 
856
    SET(wr_error_code, (glob_param_1[`SELECTOR_BITS_RPL] != cpl)? `SELECTOR_FOR_CODE(glob_param_1) : 16'd0);
857
 
858
    IF(~(write_for_wr_ready)); SET(wr_waiting); ENDIF();
859
 
860
    IF(~(wr_new_push_ss_fault));
861
        SET(write_new_stack_virtual);
862
 
863
        IF(wr_cmdex == `CMDEX_CALL_3_call_gate_more_STEP_7);
864
            SAVE(esp, wr_new_stack_esp); // speculative set in 'wr_CALL_Ep_Ap_STEP_1'
865
        ENDIF();
866
    ENDIF();
867
ENDIF();
868

powered by: WebSVN 2.1.0

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