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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [ao486_tool/] [src/] [ao486/] [module/] [memory/] [PrefetchListener.java] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/*
2
 * Copyright (c) 2014, Aleksander Osman
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * * Redistributions of source code must retain the above copyright notice, this
9
 *   list of conditions and the following disclaimer.
10
 *
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 *   this list of conditions and the following disclaimer in the documentation
13
 *   and/or other materials provided with the distribution.
14
 *
15
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
 
27
package ao486.module.memory;
28
 
29
public class PrefetchListener implements Listener {
30
 
31
    public interface PrefetchInterface {
32
        void prefetched(int cycle, long value, long size) throws Exception;
33
        void prefetch_page_fault(int cycle, long cr2, long error_code) throws Exception;
34
        void prefetch_gp_fault(int cycle) throws Exception;
35
    }
36
 
37
    public void prefetch(long cpl, long eip, long cs_base, long cs_limit, PrefetchListener.PrefetchInterface prefetch_interface) throws Exception {
38
 
39
        prefetch_input = new Input();
40
        prefetch_input.cpl      = cpl;
41
        prefetch_input.eip      = eip;
42
        prefetch_input.cs_base  = cs_base;
43
        prefetch_input.cs_limit = cs_limit;
44
 
45
        prefetch = prefetch_interface;
46
    }
47
 
48
    //------------------------------
49
 
50
 
51
    @Override
52
    public void set_input(int cycle, Input input) throws Exception {
53
 
54
        input.cpl       = prefetch_input.cpl;
55
        input.eip       = prefetch_input.eip;
56
        input.cs_base   = prefetch_input.cs_base;
57
        input.cs_limit  = prefetch_input.cs_limit;
58
 
59
        input.prefetchfifo_accept_do = true;
60
    }
61
 
62
    @Override
63
    public void get_output(int cycle, Output output) throws Exception {
64
        if(output.prefetchfifo_accept_empty == false) {
65
            long value = output.prefetchfifo_accept_data.longValue();
66
            long size = output.prefetchfifo_accept_data.shiftRight(64).longValue() & 0xFL;
67
 
68
            if(size == 14) { //page fault
69
                prefetch.prefetch_page_fault(cycle, output.tlb_code_pf_cr2, output.tlb_code_pf_error_code);
70
            }
71
            else if(size == 15) { //gp fault
72
                prefetch.prefetch_gp_fault(cycle);
73
            }
74
            else if(size > 0) {
75
                prefetch.prefetched(cycle, value, size);
76
            }
77
        }
78
    }
79
 
80
    /*
81
    //Input
82
    public long    cpl                             = 0; //2
83
    public long    eip                             = 0; //32
84
    public long    cs_base                         = 0; //32
85
    public long    cs_limit                        = 0; //32
86
 
87
    public boolean prefetchfifo_accept_do          = false;
88
 
89
    //Output
90
    public BigInteger prefetchfifo_accept_data; //68
91
    public boolean prefetchfifo_accept_empty;
92
 
93
    public long    tlb_code_pf_cr2; //32
94
    public long    tlb_code_pf_error_code; //16
95
    */
96
 
97
    PrefetchInterface   prefetch;
98
    Input               prefetch_input;
99
}

powered by: WebSVN 2.1.0

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