Changeset 238 for soft/giet_vm/memo/src/pseg.cpp
- Timestamp:
- May 29, 2013, 1:24:09 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/memo/src/pseg.cpp
r227 r238 1 1 /* -*- c++ -*- 2 2 * 3 * SOCLIB_LGPL_HEADER_BEGIN3 * GIET_VM_LGPL_HEADER_BEGIN 4 4 * 5 5 * This file is part of SoCLib, GNU LGPLv2.1. … … 19 19 * 02110-1301 USA 20 20 * 21 * SOCLIB_LGPL_HEADER_END21 * GIET_VM_LGPL_HEADER_END 22 22 * 23 23 * Copyright (c) UPMC, Lip6, SoC … … 43 43 */ 44 44 45 ////////////////////////////////////// 45 46 const std::string & VSeg::name() const 46 47 { … … 48 49 } 49 50 51 ////////////////////////////////////// 50 52 const std::string & VSeg::file() const 51 53 { … … 53 55 } 54 56 57 /////////////////////////// 55 58 uintptr_t VSeg::vma() const 56 59 { … … 58 61 } 59 62 60 uintptr_t VSeg::lma() const 63 ///////////////////////// 64 paddr_t VSeg::lma() const 61 65 { 62 66 return m_lma; 63 67 } 64 68 69 /////////////////////////// 65 70 size_t VSeg::length() const 66 71 { … … 68 73 } 69 74 75 ///////////////////////// 70 76 size_t VSeg::type() const 71 77 { … … 73 79 } 74 80 81 ///////////////////////////////////////// 75 82 void VSeg::print( std::ostream &o ) const 76 83 { … … 79 86 << std::setw (8) << std::setfill('0') 80 87 << m_vma << ", to(paddr) 0x" 81 << std::setw ( 8) << std::setfill('0')88 << std::setw (16) << std::setfill('0') 82 89 << m_lma << ", size: 0x" 83 90 << std::setw (8) << std::setfill('0') … … 87 94 } 88 95 96 ///////////// 89 97 VSeg::~VSeg() 90 98 { 91 // std::cout << "Deleted VSeg " << *this << std::endl; 92 } 93 99 } 100 101 ///////////////////////////////////////// 94 102 VSeg & VSeg::operator=( const VSeg &ref ) 95 103 { … … 97 105 return *this; 98 106 99 //std::cout << "Copying " << ref << " to " << *this << std::endl;100 107 m_name = ref.m_name, 101 108 m_file = ref.m_file; … … 107 114 } 108 115 116 //////////// 109 117 VSeg::VSeg() 110 118 : m_name("No Name"), … … 115 123 m_ident(0) 116 124 { 117 //std::cout << "New empty VSeg " << *this << std::endl; 118 } 119 120 VSeg::VSeg(std::string& binaryName, std::string& name, uintptr_t vma, size_t length, bool loadable, bool ident) 125 } 126 127 //////////////////////////////////// 128 VSeg::VSeg(std::string& binaryName, 129 std::string& name, 130 uintptr_t vma, 131 size_t length, 132 bool loadable, 133 bool ident) 121 134 : m_name(name), 122 135 m_file(binaryName), … … 126 139 m_ident(ident) 127 140 { 128 //std::cout << "New VSeg " << *this << std::endl; 129 } 130 141 } 142 143 ///////////////////////////// 131 144 VSeg::VSeg( const VSeg &ref ) 132 145 : m_name("To be copied"), … … 137 150 m_ident(0) 138 151 { 139 //std::cout << "New VSeg " << *this << " copied from " << ref << std::endl;140 152 (*this) = ref; 141 153 } 142 143 144 154 145 155 … … 147 157 * PSeg 148 158 */ 149 uintptr_t PSeg::lma() const 159 160 ///////////////////////// 161 paddr_t PSeg::lma() const 150 162 { 151 163 return m_lma; 152 164 } 153 165 154 uintptr_t PSeg::limit() const 166 /////////////////////////// 167 paddr_t PSeg::limit() const 155 168 { 156 169 return m_limit; 157 170 } 158 171 159 size_t PSeg::length() const 172 ///////////////////////////// 173 paddr_t PSeg::length() const 160 174 { 161 175 return m_length; 162 176 } 163 177 178 ///////////////////////// 164 179 size_t PSeg::type() const 165 180 { … … 167 182 } 168 183 169 uintptr_t PSeg::nextLma() const 184 ///////////////////////////// 185 paddr_t PSeg::nextLma() const 170 186 { 171 187 return m_nextLma; 172 188 } 173 189 190 ////////////////////////////////////// 174 191 const std::string & PSeg::name() const 175 192 { … … 177 194 } 178 195 196 //////////////////////// initialisation used[][] ??? (AG) 179 197 void PSeg::check() const 180 198 { … … 184 202 185 203 std::vector<VSeg>::const_iterator it; 186 size_t size = m_vsegs.size();187 size_t used[size][2];//lma, lma+length188 size_t i,j,error=0;204 size_t size = m_vsegs.size(); 205 paddr_t used[size][2]; // lma, lma+length 206 size_t i,j,error=0; 189 207 190 for(it = m_vsegs.begin(), i= 0 ; it < m_vsegs.end(); it++, i++)208 for(it = m_vsegs.begin(), i= 0 ; it < m_vsegs.end() ; it++, i++) 191 209 { 192 size_t it_limit = (*it).lma() + (*it).length();210 paddr_t it_limit = (*it).lma() + (*it).length(); 193 211 for(j=0; j< i; j++) 194 212 { 195 if( (used[j][0] == (*it).lma() /*and (*it).length()?*/) ) //not the same lma ,213 if( used[j][0] == (*it).lma() ) //not the same lma , 196 214 { 197 215 error = 1; 198 216 std::cout << "ok \n"; 199 217 } 200 if( (used[j][1] == it_limit /*and (*it).legth()?*/)) // and not the same limit218 if( used[j][1] == it_limit ) // and not the same limit 201 219 { 202 220 error = 2; 203 221 } 204 if( ((used[j][0] < (*it).lma()) and ((*it).lma() < used[j][1] )) ) //lma within the used slice222 if( (used[j][0] < (*it).lma()) and ((*it).lma() < used[j][1]) ) // lma within 205 223 { 206 224 error = 3; 207 225 } 208 if( ((used[j][0] < it_limit) and (it_limit < used[j][1] )) )//limit not within the used slice226 if( ((used[j][0] < it_limit) and (it_limit < used[j][1] )) ) // limit no within 209 227 { 210 228 error = 4; … … 228 246 } 229 247 248 ////////////////////////////////////// 230 249 void PSeg::setName(std::string& name ) 231 250 { … … 233 252 } 234 253 235 size_t PSeg::align( unsigned toAlign, unsigned alignPow2) 236 { 237 return ((toAlign + (1 << alignPow2) - 1 ) >> alignPow2) << alignPow2;//page aligned 238 } 239 240 241 size_t PSeg::pageAlign( size_t toAlign ) 254 ///////////////////////////////////////////////////////// 255 paddr_t PSeg::align( paddr_t toAlign, unsigned alignPow2) 256 { 257 return ((toAlign + (1 << alignPow2) - 1 ) >> alignPow2) << alignPow2; 258 } 259 260 ////////////////////////////////////////// 261 paddr_t PSeg::pageAlign( paddr_t toAlign ) 242 262 { 243 263 size_t pgs = pageSize(); 244 264 size_t pageSizePow2 = __builtin_ctz(pgs); 245 265 246 return align(toAlign, pageSizePow2); //page aligned247 248 } 249 250 void PSeg::setLma( uintptr_t lma )266 return align(toAlign, pageSizePow2); 267 } 268 269 //////////////////////////////// 270 void PSeg::setLma( paddr_t lma ) 251 271 { 252 272 m_lma = lma; 253 273 254 m_nextLma = pageAlign(lma); //page aligned274 m_nextLma = pageAlign(lma); 255 275 256 276 m_pageLimit = pageAlign(m_lma+m_length); 257 277 258 278 m_limit = (m_lma + m_length); 259 260 } 261 262 void PSeg::setLength( size_t length )279 } 280 281 ///////////////////////////////////// 282 void PSeg::setLength( paddr_t length ) 263 283 { 264 284 m_length = length; … … 267 287 268 288 m_limit = (m_lma + m_length); 269 270 //std::cout << std::hex << " length seted, m_limit: " << m_limit << std::endl; 271 //std::cout << *this <<std::endl; 272 } 273 289 } 290 291 //////////////////////////// 274 292 void PSeg::add( VSeg& vseg ) 275 293 { 276 294 vseg.m_lma = m_nextLma; 277 incNextLma(vseg.length());//for the next vseg295 // incNextLma(vseg.length()); //for the next vseg 278 296 m_vsegs.push_back(vseg); 279 297 } 280 298 299 ///////////////////////////////// 281 300 void PSeg::addIdent( VSeg& vseg ) 282 301 { 283 302 vseg.m_lma = vseg.m_vma; 284 //incNextLma(vseg.length());//to keep track of space used285 303 m_vsegs.push_back(vseg); 286 304 } 287 305 288 void PSeg::setNextLma( uintptr_t nextLma) 306 ///////////////////////////////////////// 307 void PSeg::setNextLma( paddr_t nextLma) 289 308 { 290 309 m_nextLma = nextLma; 291 292 310 confNextLma(); 293 311 } 294 312 295 void PSeg::incNextLma( size_t inc_next) 296 { 297 298 m_nextLma += inc_next; 299 313 ////////////////////////////////// 314 void PSeg::incNextLma( size_t inc) 315 { 316 m_nextLma += inc; 300 317 confNextLma(); 301 318 } 302 319 320 //////////////////////// 303 321 void PSeg::confNextLma() 304 322 { … … 322 340 } 323 341 342 ///////////////////////////////// 324 343 void PSeg::setPageSize(size_t pg) 325 344 { … … 332 351 } 333 352 353 //////////////////////// 334 354 size_t& PSeg::pageSize() 335 355 { … … 338 358 } 339 359 360 ///////////////////////////////////////// 340 361 PSeg & PSeg::operator=( const PSeg &ref ) 341 362 { 342 363 if ( &ref == this ) 343 364 return *this; 344 345 //std::cout << "Copying " << ref << " to " << *this << std::endl;346 365 347 366 m_name = ref.m_name; … … 357 376 } 358 377 378 ////////////////////////////////////////// 359 379 void PSeg::print( std::ostream &o ) const 360 380 { … … 374 394 } 375 395 396 //////////////////////////////////// 376 397 PSeg::PSeg( const std::string &name, 377 uintptr_tlma,378 size_tlength,379 size_ttype)398 paddr_t lma, 399 paddr_t length, 400 size_t type) 380 401 { 381 402 m_name = name; … … 384 405 385 406 setLma(lma); 386 //std::cout <<"New PSeg :"<< *this ; 387 } 388 407 } 408 409 //////////////////////////////////// 389 410 PSeg::PSeg( const std::string &name): 390 411 m_lma(0), … … 396 417 } 397 418 398 PSeg::PSeg( uintptr_t lma): 419 //////////////////////// 420 PSeg::PSeg( paddr_t lma): 399 421 m_name("No name"), 400 422 m_lma(0), … … 406 428 } 407 429 408 430 //////////// 409 431 PSeg::PSeg() 410 432 : … … 415 437 m_limit(0) 416 438 { 417 //std::cout << "New empty PSeg " << *this << std::endl; 418 } 419 439 } 440 441 ///////////////////////////// 420 442 PSeg::PSeg( const PSeg &ref ) 421 443 : m_name("To be copied"), … … 425 447 m_limit(0) 426 448 { 427 //std::cout << "New PSeg " << *this << " copied from " << ref << std::endl;428 449 (*this) = ref; 429 450 } … … 431 452 PSeg::~PSeg() 432 453 { 433 // std::cout << "Deleted PSeg " << *this << std::endl;434 454 } 435 455
Note: See TracChangeset
for help on using the changeset viewer.