Debian Codegraph @

Documentation/util/cbfstool/mmap_windows.md

raw symbols SCIP
1 # cbfstool: Handling memory mapped boot media
2
3 `cbfstool` is a utility used for managing coreboot file system (CBFS)
4 components in a ROM image. x86 platforms are special since they have
5 the SPI flash boot media memory mapped into host address space at
6 runtime. This requires `cbfstool` to deal with two separate address
7 spaces for any CBFS components that are eXecute-In-Place (XIP) - one
8 is the SPI flash address space and other is the host address space
9 where the SPI flash gets mapped.
10
11 By default, all x86 platforms map a maximum of 16MiB of SPI flash at
12 the top of 4G in host address space. If the flash is greater than
13 16MiB, then only the top 16MiB of the flash is mapped in the host
14 address space. If the flash is smaller than 16MiB, then the entire SPI
15 flash is mapped at the top of 4G and the rest of the space remains
16 unused.
17
18 In more recent platforms like Tiger Lake (TGL), it is possible to map
19 more than 16MiB of SPI flash. Since the host address space has legacy
20 fixed device addresses mapped below `4G - 16M`, the SPI flash is split
21 into separate windows when being mapped to the host address space.
22 Default decode window of maximum 16MiB size still lives just below the
23 4G boundary. The additional decode window is free to live in any
24 available MMIO space that the SoC chooses.
25
26 Following diagram shows different combinations of SPI flash being
27 mapped into host address space when using multiple windows:
28
29 ![MMAP window combinations with different flash sizes][mmap_windows]
30
31 *(a) SPI flash of size 16MiB (b) SPI flash smaller than 16MiB (c) SPI flash
32 of size (16MiB+ext window size) (d) SPI flash smaller than (16MiB+ext
33 window size)*
34
35 The location of standard decode window is fixed in host address space
36 `(4G - 16M) to 4G`. However, the platform is free to choose where the
37 extended window lives in the host address space. Since `cbfstool`
38 needs to know the exact location of the extended window, it allows the
39 platform to pass in one parameter `mmap` that provide the base and the
40 size of the extended window in host address space.
41
42 `cbfstool` creates two memory map windows using the knowledge about the
43 standard decode window and the information passed in by the platform
44 about the extended decode window. These windows are useful in
45 converting addresses from one space to another (flash space and host
46 space) when dealing with XIP components.
47
48 ## Assumptions
49
50 1. Top 16MiB is still decoded in the fixed decode window just below 4G
51 boundary.
52 1. Rest of the SPI flash below the top 16MiB is mapped at the top of
53 the extended window. Even though the platform might support a
54 larger extended window, the SPI flash part used by the mainboard
55 might not be large enough to be mapped in the entire window. In
56 such cases, the mapping is assumed to be in the top part of the
57 extended window with the bottom part remaining unused.
58
59 ## Example
60
61 If the platform supports extended window and the SPI flash size is
62 greater, then `cbfstool` creates a mapping for the extended window as
63 well.
64
65 ```
66 ext_win_base = 0xF8000000
67 ext_win_size = 32 * MiB
68 ext_win_limit = ext_win_base + ext_win_size - 1 = 0xF9FFFFFF
69 ```
70
71 If SPI flash is 32MiB, then top 16MiB is mapped from `0xFF000000 -
72 0xFFFFFFFF` whereas the bottom 16MiB is mapped from `0xF9000000 -
73 0xF9FFFFFF`. The extended window `0xF8000000 - 0xF8FFFFFF` remains
74 unused.
75
76 [mmap_windows]: mmap_windows.svg