Address.hh (7002:48a19d52d939) Address.hh (7027:46b02e79bf2c)
1
2/*
3 * Copyright (c) 1999 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 52 unchanged lines hidden (view full) ---

61 // ~Address();
62
63 // Public Methods
64
65 void setAddress(physical_address_t address) { m_address = address; }
66 physical_address_t getAddress() const {return m_address;}
67 // selects bits inclusive
68 physical_address_t bitSelect(int small, int big) const;
1
2/*
3 * Copyright (c) 1999 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 52 unchanged lines hidden (view full) ---

61 // ~Address();
62
63 // Public Methods
64
65 void setAddress(physical_address_t address) { m_address = address; }
66 physical_address_t getAddress() const {return m_address;}
67 // selects bits inclusive
68 physical_address_t bitSelect(int small, int big) const;
69 physical_address_t bitRemove(int small, int big) const;
69 physical_address_t maskLowOrderBits(int number) const;
70 physical_address_t maskHighOrderBits(int number) const;
71 physical_address_t shiftLowOrderBits(int number) const;
72 physical_address_t getLineAddress() const
73 { return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH); }
74 physical_address_t getOffset() const
75 { return bitSelect(0, RubySystem::getBlockSizeBits()-1); }
76

--- 80 unchanged lines hidden (view full) ---

157 } else {
158 mask = ~((physical_address_t)~0 << (big + 1));
159 // FIXME - this is slow to manipulate a 64-bit number using 32-bits
160 physical_address_t partial = (m_address & mask);
161 return (partial >> small);
162 }
163}
164
70 physical_address_t maskLowOrderBits(int number) const;
71 physical_address_t maskHighOrderBits(int number) const;
72 physical_address_t shiftLowOrderBits(int number) const;
73 physical_address_t getLineAddress() const
74 { return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH); }
75 physical_address_t getOffset() const
76 { return bitSelect(0, RubySystem::getBlockSizeBits()-1); }
77

--- 80 unchanged lines hidden (view full) ---

158 } else {
159 mask = ~((physical_address_t)~0 << (big + 1));
160 // FIXME - this is slow to manipulate a 64-bit number using 32-bits
161 physical_address_t partial = (m_address & mask);
162 return (partial >> small);
163 }
164}
165
166// removes bits inclusive
165inline
167inline
168physical_address_t Address::bitRemove(int small, int big) const
169{
170 physical_address_t mask;
171 assert((unsigned)big >= (unsigned)small);
172
173 if (small >= ADDRESS_WIDTH - 1) {
174 return m_address;
175 } else if (big >= ADDRESS_WIDTH - 1) {
176 mask = (physical_address_t)~0 >> small;
177 return (m_address & mask);
178 } else if (small == 0) {
179 mask = (physical_address_t)~0 << big;
180 return (m_address & mask);
181 } else {
182 mask = ~((physical_address_t)~0 << small);
183 physical_address_t lower_bits = m_address & mask;
184 mask = (physical_address_t)~0 << (big + 1);
185 physical_address_t higher_bits = m_address & mask;
186
187 //
188 // Shift the valid high bits over the removed section
189 //
190 higher_bits = higher_bits >> (big - small);
191 return (higher_bits | lower_bits);
192 }
193}
194
195inline
166physical_address_t Address::maskLowOrderBits(int number) const
167{
168 physical_address_t mask;
169
170 if (number >= ADDRESS_WIDTH - 1) {
171 mask = ~0;
172 } else {
173 mask = (physical_address_t)~0 << number;

--- 74 unchanged lines hidden ---
196physical_address_t Address::maskLowOrderBits(int number) const
197{
198 physical_address_t mask;
199
200 if (number >= ADDRESS_WIDTH - 1) {
201 mask = ~0;
202 } else {
203 mask = (physical_address_t)~0 << number;

--- 74 unchanged lines hidden ---