Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # -*- perl -*- |
2 | ||
3 | package Midas::MMU::Niagara; | |
4 | use strict; | |
5 | ||
6 | use Midas::Command; | |
7 | use Midas::Error; | |
8 | use Midas::Configure; | |
9 | use Midas::Globals; | |
10 | use Midas::Segment; | |
11 | ||
12 | use TRELoad 'BitFieldTie'; | |
13 | ||
14 | use base qw(Midas::MMU); | |
15 | use fields qw( | |
16 | rasize | |
17 | ); | |
18 | ||
19 | ||
20 | ||
21 | ||
22 | ############################################################################## | |
23 | ||
24 | sub new { | |
25 | my $class = shift; | |
26 | my %args = @_; | |
27 | my $this = fields::new($class); | |
28 | $this->SUPER::new(); | |
29 | ||
30 | foreach my $key (keys %args) { | |
31 | $this->{$key} = $args{$key}; | |
32 | } | |
33 | ||
34 | $this->set_defaults(); | |
35 | ||
36 | $this->{mapattr_type} = 'Midas::MMU::Niagara::SectionAttrs'; | |
37 | ||
38 | return $this; | |
39 | } | |
40 | ||
41 | ############################################################################## | |
42 | ||
43 | sub set_defaults { | |
44 | my $this = shift; | |
45 | ||
46 | $this->{vasize} = 64 unless defined $this->{vasize}; | |
47 | $this->{pasize} = 40 unless defined $this->{pasize}; | |
48 | $this->{rasize} = 40 unless defined $this->{rasize}; | |
49 | $this->{type} = 'niagara' unless defined $this->{type}; | |
50 | ||
51 | ||
52 | $this->SUPER::set_defaults(); | |
53 | } | |
54 | ||
55 | ############################################################################## | |
56 | ||
57 | sub mmu_cpp_args { | |
58 | my $this = shift; | |
59 | my $list = ['-DNIAGARA']; | |
60 | push @$list, '-DALLOW_TSB_COL' if $CONFIG{allow_tsb_conflicts}; | |
61 | return $list; | |
62 | } | |
63 | ||
64 | ############################################################################## | |
65 | ||
66 | ############################################################################## | |
67 | ############################################################################## | |
68 | ||
69 | { | |
70 | package Midas::MMU::Niagara::SectionAttrs; | |
71 | use strict; | |
72 | ||
73 | use Carp; | |
74 | use Midas::Command; | |
75 | use Midas::Globals; | |
76 | use Midas::Error; | |
77 | use Midas::MMU::SunSectionAttrs; | |
78 | use Midas::MMU::TTEFormat; | |
79 | use BitFieldTie; | |
80 | ||
81 | ||
82 | use base qw(Midas::MMU::SunHyperAttrs); | |
83 | use fields (qw(), | |
84 | ( | |
85 | # Hard-code MMU type because 'use fields' directive needs | |
86 | # to happen at compile-time | |
87 | keys %{ get_union_tte_field_hash('niagara') } | |
88 | ) | |
89 | ); | |
90 | ||
91 | our @Settable = (); | |
92 | ||
93 | our %Settable = map { $_ => 1} Midas::MMU::Niagara::SectionAttrs->settable(); | |
94 | our %FieldSizes = (); | |
95 | ||
96 | ############################################################################ | |
97 | ||
98 | sub new { | |
99 | my $this = shift; | |
100 | my %args = @_; | |
101 | ||
102 | unless (ref $this) { | |
103 | $this = fields::new($this); | |
104 | } | |
105 | ||
106 | $this->{settable} = \%Settable; | |
107 | foreach my $key (keys %args) { | |
108 | $this->{$key} = $args{$key}; | |
109 | } | |
110 | ||
111 | return $this; | |
112 | } | |
113 | ||
114 | ############################################################################ | |
115 | ||
116 | sub set_defaults { | |
117 | my $this = shift; | |
118 | ||
119 | $this->SUPER::set_defaults(); | |
120 | ||
121 | foreach my $field (keys %FieldSizes) { | |
122 | $this->{$field} = 0 unless defined $this->{$field}; | |
123 | } | |
124 | } | |
125 | ||
126 | ############################################################################# | |
127 | ||
128 | sub settable { | |
129 | my $this = shift; | |
130 | my @settable = $this->SUPER::settable(); | |
131 | push @settable, @Settable; | |
132 | return @settable; | |
133 | } | |
134 | ||
135 | ############################################################################# | |
136 | ||
137 | sub get_field_size_hash { | |
138 | my $this = shift; | |
139 | my $sizes = $this->SUPER::get_field_size_hash(); | |
140 | ||
141 | foreach my $field (keys %FieldSizes) { | |
142 | $sizes->{$field} = $FieldSizes{$field}; | |
143 | } | |
144 | ||
145 | return $sizes; | |
146 | } | |
147 | ||
148 | ############################################################################ | |
149 | ||
150 | sub legal_page_bits { | |
151 | my $this = shift; | |
152 | return (0, 1, 3, 5); | |
153 | } | |
154 | ||
155 | ########################################################################### | |
156 | ||
157 | } | |
158 | ||
159 | ############################################################################## | |
160 | ||
161 | ############################################################################## | |
162 | ||
163 | 1; |