1 |
2 |
alfik |
/*
|
2 |
|
|
* This file is subject to the terms and conditions of the BSD License. See
|
3 |
|
|
* the file "LICENSE" in the main directory of this archive for more details.
|
4 |
|
|
*
|
5 |
|
|
* Copyright (C) 2014 Aleksander Osman
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
#include <cstdio>
|
9 |
|
|
#include <cstdlib>
|
10 |
|
|
|
11 |
|
|
#include "tests.h"
|
12 |
|
|
|
13 |
|
|
//------------------------------------------------------------------------------
|
14 |
|
|
|
15 |
|
|
void tlb_commands_till_exc_init(tst_t *tst, shared_mem_t *shared_ptr) {
|
16 |
|
|
|
17 |
|
|
for(int i=1; i<32; i++) shared_ptr->initial.reg[i-1] = rand_uint32();
|
18 |
|
|
|
19 |
|
|
shared_ptr->initial.pc = 0xA0001000;
|
20 |
|
|
|
21 |
|
|
for(int i=0; i<64; i++) shared_ptr->initial.tlb[i].vpn = rand() & 0xFFFFF;
|
22 |
|
|
|
23 |
|
|
shared_ptr->initial.index_p = rand() & 0x1;
|
24 |
|
|
shared_ptr->initial.index_index = rand() & 0x3F;
|
25 |
|
|
|
26 |
|
|
shared_ptr->initial.random = rand() & 0x3F;
|
27 |
|
|
|
28 |
|
|
shared_ptr->initial.entrylo_pfn = rand() & 0xFFFFF;
|
29 |
|
|
shared_ptr->initial.entrylo_n = rand() & 0x1;
|
30 |
|
|
shared_ptr->initial.entrylo_d = rand() & 0x1;
|
31 |
|
|
shared_ptr->initial.entrylo_v = rand() & 0x1;
|
32 |
|
|
shared_ptr->initial.entrylo_g = rand() & 0x1;
|
33 |
|
|
|
34 |
|
|
shared_ptr->initial.context_ptebase = rand() & 0x7FF;
|
35 |
|
|
shared_ptr->initial.context_badvpn = rand() & 0x7FFFF;
|
36 |
|
|
|
37 |
|
|
shared_ptr->initial.bad_vaddr = rand_uint32();
|
38 |
|
|
|
39 |
|
|
shared_ptr->initial.entryhi_vpn = rand() & 0xFFFFF;
|
40 |
|
|
shared_ptr->initial.entryhi_asid = rand() & 0x3F;
|
41 |
|
|
|
42 |
|
|
shared_ptr->initial.sr_cp_usable = rand() & 0xF;
|
43 |
|
|
shared_ptr->initial.sr_rev_endian = rand() & 0x1;
|
44 |
|
|
shared_ptr->initial.sr_bootstrap_vec = rand() & 0x1;
|
45 |
|
|
shared_ptr->initial.sr_tlb_shutdown = rand() & 0x1;
|
46 |
|
|
shared_ptr->initial.sr_parity_err = rand() & 0x1;
|
47 |
|
|
shared_ptr->initial.sr_cache_miss = rand() & 0x1;
|
48 |
|
|
shared_ptr->initial.sr_parity_zero = rand() & 0x1;
|
49 |
|
|
shared_ptr->initial.sr_switch_cache = rand() & 0x1;
|
50 |
|
|
shared_ptr->initial.sr_isolate_cache = rand() & 0x1;
|
51 |
|
|
shared_ptr->initial.sr_irq_mask = rand() & 0xFF;
|
52 |
|
|
shared_ptr->initial.sr_ku_ie = rand() & 0x3F;
|
53 |
|
|
|
54 |
|
|
shared_ptr->initial.cause_branch_delay = rand() & 0x1;
|
55 |
|
|
shared_ptr->initial.cause_cp_error = rand() & 0x3;
|
56 |
|
|
shared_ptr->initial.cause_irq_pending = 0;
|
57 |
|
|
shared_ptr->initial.cause_exc_code = rand() & 0x1F;
|
58 |
|
|
|
59 |
|
|
shared_ptr->initial.epc = rand_uint32();
|
60 |
|
|
|
61 |
|
|
//
|
62 |
|
|
shared_ptr->irq2_at_event = 0xFFFFFFFF;
|
63 |
|
|
shared_ptr->irq3_at_event = 0xFFFFFFFF;
|
64 |
|
|
|
65 |
|
|
//
|
66 |
|
|
uint32 *ptr = &shared_ptr->mem.ints[(shared_ptr->initial.pc & 0x1FFFFFFF) / 4];
|
67 |
|
|
|
68 |
|
|
for(int i=0; i<100; i++) {
|
69 |
|
|
|
70 |
|
|
uint32 type = rand() % 5;
|
71 |
|
|
|
72 |
|
|
if(type == 0) { //RFE
|
73 |
|
|
(*ptr) = rand() & 0x01FFFFC0;
|
74 |
|
|
(*ptr) |= (0b0100 << 28) | (0b00 << 26) | (0b1 << 25) | (0b010000 << 0);
|
75 |
|
|
}
|
76 |
|
|
else if(type == 1) { //TLBWR
|
77 |
|
|
(*ptr) = rand() & 0x01FFFFC0;
|
78 |
|
|
(*ptr) |= (0b0100 << 28) | (0b00 << 26) | (0b1 << 25) | (0b000110 << 0);
|
79 |
|
|
|
80 |
|
|
ptr++;
|
81 |
|
|
(*ptr) = rand() & 0x03FFFFC0;
|
82 |
|
|
(*ptr) |= 0b001100; //SYSCALL
|
83 |
|
|
}
|
84 |
|
|
else if(type == 2) { //TLBWI
|
85 |
|
|
(*ptr) = rand() & 0x01FFFFC0;
|
86 |
|
|
(*ptr) |= (0b0100 << 28) | (0b00 << 26) | (0b1 << 25) | (0b000010 << 0);
|
87 |
|
|
|
88 |
|
|
ptr++;
|
89 |
|
|
(*ptr) = rand() & 0x03FFFFC0;
|
90 |
|
|
(*ptr) |= 0b001100; //SYSCALL
|
91 |
|
|
}
|
92 |
|
|
else if(type == 3) { //TLBR
|
93 |
|
|
(*ptr) = rand() & 0x01FFFFC0;
|
94 |
|
|
(*ptr) |= (0b0100 << 28) | (0b00 << 26) | (0b1 << 25) | (0b000001 << 0);
|
95 |
|
|
}
|
96 |
|
|
else if(type == 4) { //TLBP
|
97 |
|
|
(*ptr) = rand() & 0x01FFFFC0;
|
98 |
|
|
(*ptr) |= (0b0100 << 28) | (0b00 << 26) | (0b1 << 25) | (0b001000 << 0);
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
ptr++;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
for(int i=0; i<5; i++) {
|
105 |
|
|
(*ptr) = rand() & 0x03FFFFC0;
|
106 |
|
|
(*ptr) |= 0b001100; //SYSCALL
|
107 |
|
|
ptr++;
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
//------------------------------------------------------------------------------
|