Esempio n. 1
0
 public void Add(long start, long end, IBusRegistered <IBusPeripheral> peripheral, PeripheralAccessMethods accessMethods)
 {
     // the idea here is that we prefer the peripheral to go to dictionary
     // ideally it can go to dicitonary wholly, but we try to put there as much as we can
     lock (sync)
     {
         var name = string.Format("{0} @ {1}.", peripheral.Peripheral.GetType().Name, peripheral.RegistrationPoint);
         // TODO: check index (and start/stop)
         var block = new Block {
             Start = start, End = end, AccessMethods = accessMethods, Peripheral = peripheral
         };
         // let's decide whether block should go to array, dictionary or both
         var goToDictionary = true;
         // is the peripheral properly aligned?
         if ((start & PageAlign) != 0)
         {
             sysbus.NoisyLog("{0} is at not aligned address - not using dictionary.", name);
             goToDictionary = false;
         }
         // is the peripheral small enough?
         var size       = end - start;
         var numOfPages = size / PageSize;
         if (numOfPages > NumOfPagesThreshold)
         {
             sysbus.NoisyLog("{0} is too large - not using dictionary.", name);
             goToDictionary = false;
         }
         var goToArray = !goToDictionary; // peripheral will go to array if we couldn't put it in dictionary
         if (goToDictionary && size % PageSize != 0)
         {
             // but it should also go to array if it isn't properly aligned on its last page
             goToArray = true;
         }
         if (goToArray)
         {
             blocks = blocks.Union(new [] { block }).OrderBy(x => x.Start).ToArray();
             sysbus.NoisyLog("Added {0} to binary search array.", name);
         }
         if (!goToDictionary)
         {
             return;
         }
         // note that truncating is in fact good thing here
         for (var i = 0; i < numOfPages; i++)
         {
             shortBlocks.Add(start + i * PageSize, block);
         }
         sysbus.NoisyLog("Added {0} to dictionary.", name);
     }
 }
Esempio n. 2
0
 public void Add(long start, long end, IBusRegistered<IBusPeripheral> peripheral, PeripheralAccessMethods accessMethods)
 {
     // the idea here is that we prefer the peripheral to go to dictionary
     // ideally it can go to dicitonary wholly, but we try to put there as much as we can
     lock(sync)
     {
         var name = string.Format("{0} @ {1}.", peripheral.Peripheral.GetType().Name, peripheral.RegistrationPoint);
         // TODO: check index (and start/stop)
         var block = new Block { Start = start, End = end, AccessMethods = accessMethods, Peripheral = peripheral };
         // let's decide whether block should go to array, dictionary or both
         var goToDictionary = true;
         // is the peripheral properly aligned?
         if((start & PageAlign) != 0)
         {
             sysbus.NoisyLog("{0} is at not aligned address - not using dictionary.", name);
             goToDictionary = false;
         }
         // is the peripheral small enough?
         var size = end - start;
         var numOfPages = size/PageSize;
         if(numOfPages > NumOfPagesThreshold)
         {
             sysbus.NoisyLog("{0} is too large - not using dictionary.", name);
             goToDictionary = false;
         }
         var goToArray = !goToDictionary; // peripheral will go to array if we couldn't put it in dictionary
         if(goToDictionary && size % PageSize != 0)
         {
             // but it should also go to array if it isn't properly aligned on its last page
             goToArray = true;
         }
         if(goToArray)
         {
             blocks = blocks.Union(new [] { block }).OrderBy(x => x.Start).ToArray();
             sysbus.NoisyLog("Added {0} to binary search array.", name);
         }
         if(!goToDictionary)
         {
             return;
         }
         // note that truncating is in fact good thing here
         for(var i = 0; i < numOfPages; i++)
         {
             shortBlocks.Add(start + i*PageSize, block);
         }
         sysbus.NoisyLog("Added {0} to dictionary.", name);
     }
 }
Esempio n. 3
0
 public static IBusRegistered <TTo> Convert <TFrom, TTo>(this IBusRegistered <TFrom> conversionSource) where TTo : TFrom where TFrom : IBusPeripheral
 {
     return(new BusRegistered <TTo>((TTo)conversionSource.Peripheral, new BusRangeRegistration(conversionSource.RegistrationPoint.Range,
                                                                                               conversionSource.RegistrationPoint.Offset)));
 }