AddressSpace Part2

现在我们知道了AddressSpace, MemoryRegion, FlatView, RAMBlock。那就来看看这几个角色在一起的样子。

    AddressSpace               
    +-------------------------+
    |name                     |
    |   (char *)              |          FlatView (An array of FlatRange)
    +-------------------------+          +----------------------+
    |current_map              | -------->|nr                    |
    |   (FlatView *)          |          |nr_allocated          |
    +-------------------------+          |   (unsigned)         |         FlatRange             FlatRange
    |                         |          +----------------------+         
    |                         |          |ranges                | ------> +---------------------+---------------------+
    |                         |          |   (FlatRange *)      |         |offset_in_region     |offset_in_region     |
    |                         |          +----------------------+         |    (hwaddr)         |    (hwaddr)         |
    |                         |                                           +---------------------+---------------------+
    |                         |                                           |addr(AddrRange)      |addr(AddrRange)      |
    |                         |                                           |    +----------------|    +----------------+
    |                         |                                           |    |start (Int128)  |    |start (Int128)  |
    |                         |                                           |    |size  (Int128)  |    |size  (Int128)  |
    |                         |                                           +----+----------------+----+----------------+
    |                         |                                           |mr                   |mr                   |
    |                         |                                           | (MemoryRegion *)    | (MemoryRegion *)    |
    |                         |                                           +---------------------+---------------------+
    |                         |
    |                         |
    |                         |
    |                         |          MemoryRegion(system_memory/system_io)
    +-------------------------+          +------------------------+
    |root                     |          |name                    | root of a MemoryRegion
    |   (MemoryRegion *)      | -------->|  (const char *)        | tree
    +-------------------------+          +------------------------+
                                         |addr                    |
                                         |  (hwaddr)              |
                                         |size                    |
                                         |  (Int128)              |
                                         +------------------------+
                                         |subregions              |
                                         |    QTAILQ_HEAD()       |
                                         +------------------------+
                                                      |
                                                      |
                              ----+-------------------+---------------------+----
                                  |                                         |
                                  |                                         |
                                  |                                         |

                    struct MemoryRegion                            struct MemoryRegion
                    +------------------------+                     +------------------------+
                    |name                    |                     |name                    |
                    |  (const char *)        |                     |  (const char *)        |
                    +------------------------+                     +------------------------+
                    |addr                    |   GPA               |addr                    |
                    |  (hwaddr)              |                     |  (hwaddr)              |
                    |size                    |                     |size                    |
                    |  (Int128)              |                     |  (Int128)              |
                    +------------------------+                     +------------------------+
                    |ram_block               |                     |ram_block               |
                    |    (RAMBlock *)        |                     |    (RAMBlock *)        |
                    +------------------------+                     +------------------------+
                               |
                               |
                               |
                               |
                               v
                    RAMBlock                     
                    +---------------------------+
                    |next                       |
                    |    QLIST_ENTRY(RAMBlock)  |
                    +---------------------------+
                    |offset                     |
                    |used_length                |
                    |max_length                 |
                    |    (ram_addr_t)           |
                    +---------------------------+
                    |host                       |   HVA
                    |    (uint8_t *)            |
                    +---------------------------+
                    |mr                         |
                    |    (struct MemoryRegion *)|
                    +---------------------------+

Last updated