def _use_untyped(self, objects, untyped, size_bytes, is_device, spec): assert (untyped.remaining() >= size_bytes) while size_bytes: size_bits = min(ctz(size_bytes), ctz(untyped.watermark_paddr())) if is_device: self._add_placeholder(untyped, size_bits, spec) else: res = self._fill_from_objects(objects, untyped, size_bits, spec) if res == size_bits: # we failed to fill from objects at all self._add_placeholder(untyped, size_bits, spec) size_bytes -= (1 << size_bits) assert (size_bytes >= 0)
def _use_untyped(self, objects, untyped, size_bytes, is_device, spec): assert(untyped.remaining() >= size_bytes) while size_bytes: # size_bits is calculated from the minimum alignment between the goal # size_bytes and the watermark. If the watermark is 0 (which is valid) # then just take the alignment of the size_bytes as it's guaranteed to # be smaller. size_bits = min(ctz(size_bytes), ctz(untyped.watermark_paddr()) ) if untyped.watermark_paddr() else ctz(size_bytes) if is_device: self._add_placeholder(untyped, size_bits, spec) else: res = self._fill_from_objects(objects, untyped, size_bits, spec) if res == size_bits: # we failed to fill from objects at all self._add_placeholder(untyped, size_bits, spec) size_bytes -= (1 << size_bits) assert(size_bytes >= 0)
def create_untypeds_for_region(object_sizes, region, arch, device): untyped = [] start = region.start end = region.end while start != end: assert (start <= end) size_bits = (end - start).bit_length() - 1 if start < end else arch.word_size_bits() align_bits = ctz(start) if start > 0 else size_bits size_bits = min(size_bits, align_bits, object_sizes['seL4_Value_MaxUntypedBits']) if size_bits > object_sizes['seL4_Value_MinUntypedBits']: untyped.append({'device': device, 'size_bits': size_bits, 'paddr': start}) start += 1 << size_bits return untyped
def get_alignment_bits(addr): return ctz(addr)