Fix-Mapped Linear Addresses

  • Initial part of the 4th gigabyte is used to map to the same physical addresses as 0x00000000
  • At least 128mB is left for noncontiguous memory allocation and fix mapped linear addresses
    • Noncontiguous memory allocation is a way to dynamically allocate and deallocate pages of memory (Ch8)
    • Fix mapped linear addresses: A constant linear address (eg. 0xffffc000) is mapped to any arbitrary physical address.  Each fix mapped linear address maps to one page frame
      • More efficient for variable pointers. Constant linear addresses require one less memory access (paging)
      • Since it is a constant linear address no need to check for null (?)
  • Fix-mapped linear addresses are stored in the enum fixed_addresses data structure
    • An explanation enumerated data structs can be found here
    • Essentially each fix mapped linear address is stored as an integer index in this structure
  • Conversion from a fix mapped linear address to a virtual address is performed by the fix_to_virt() function
    • Note: UL=Unsigned Long
    • Inline functions are copied and pasted at compilation where they are called instead of referenced to another included object file
    • The computation places fix mapped linear addresses at the end of the 4th gigabyte of linear addresses
inline unsigned long fix_to_virt(const unsigned int idx){
    if (idx >= _ _end_of_fixed_addresses)
        _ _this_fixmap_does_not_exist();
    return (0xfffff000UL - (idx << PAGE_SHIFT));
  • For example in the case of FIX_TO_APIC_BASE_0, the input to fix_to_virt==3
  • Note also these are const unsigned ints if the compiler sees that the input given is not constant or greater than the __this_fixmap_does_not_exist idx it will issue an error
  • The compiler computes 0xfffff000-(3<<PAGE_SHIFT) and replaces the fix_to_
    function call with the constant linear address 0xffffc000.
enum fixed_addresses {
    _ _end_of_fixed_addresses
  • set_fixmap(idx, phys) and set_fixmap_nocach(idx, phys) are two macros which help create enum fixed_addresses
    • The second function sets the PCD flag disabling hardware cache
  • clear_fixmap(idx) removes the linking between a fix mapped linear address and the physical address

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s