Lines Matching refs:state
11 static EFI_STATUS devicetree_allocate(struct devicetree_state *state, UINTN size) { in devicetree_allocate() argument
15 assert(state); in devicetree_allocate()
17 err = BS->AllocatePages(AllocateAnyPages, EfiACPIReclaimMemory, pages, &state->addr); in devicetree_allocate()
21 state->pages = pages; in devicetree_allocate()
25 static UINTN devicetree_allocated(const struct devicetree_state *state) { in devicetree_allocated() argument
26 assert(state); in devicetree_allocated()
27 return state->pages * EFI_PAGE_SIZE; in devicetree_allocated()
30 static EFI_STATUS devicetree_fixup(struct devicetree_state *state, UINTN len) { in devicetree_fixup() argument
35 assert(state); in devicetree_fixup()
42 size = devicetree_allocated(state); in devicetree_fixup()
43 err = fixup->Fixup(fixup, PHYSICAL_ADDRESS_TO_POINTER(state->addr), &size, in devicetree_fixup()
46 EFI_PHYSICAL_ADDRESS oldaddr = state->addr; in devicetree_fixup()
47 UINTN oldpages = state->pages; in devicetree_fixup()
48 void *oldptr = PHYSICAL_ADDRESS_TO_POINTER(state->addr); in devicetree_fixup()
50 err = devicetree_allocate(state, size); in devicetree_fixup()
54 CopyMem(PHYSICAL_ADDRESS_TO_POINTER(state->addr), oldptr, len); in devicetree_fixup()
59 size = devicetree_allocated(state); in devicetree_fixup()
60 err = fixup->Fixup(fixup, PHYSICAL_ADDRESS_TO_POINTER(state->addr), &size, in devicetree_fixup()
67 EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir, CHAR16 *name) { in devicetree_install() argument
73 assert(state); in devicetree_install()
77 err = LibGetSystemConfigurationTable(&EfiDtbTableGuid, &state->orig); in devicetree_install()
94 err = devicetree_allocate(state, len); in devicetree_install()
98 err = handle->Read(handle, &len, PHYSICAL_ADDRESS_TO_POINTER(state->addr)); in devicetree_install()
102 err = devicetree_fixup(state, len); in devicetree_install()
106 … return BS->InstallConfigurationTable(&EfiDtbTableGuid, PHYSICAL_ADDRESS_TO_POINTER(state->addr)); in devicetree_install()
109 EFI_STATUS devicetree_install_from_memory(struct devicetree_state *state, in devicetree_install_from_memory() argument
114 assert(state); in devicetree_install_from_memory()
117 err = LibGetSystemConfigurationTable(&EfiDtbTableGuid, &state->orig); in devicetree_install_from_memory()
121 err = devicetree_allocate(state, dtb_length); in devicetree_install_from_memory()
125 CopyMem(PHYSICAL_ADDRESS_TO_POINTER(state->addr), dtb_buffer, dtb_length); in devicetree_install_from_memory()
127 err = devicetree_fixup(state, dtb_length); in devicetree_install_from_memory()
131 … return BS->InstallConfigurationTable(&EfiDtbTableGuid, PHYSICAL_ADDRESS_TO_POINTER(state->addr)); in devicetree_install_from_memory()
134 void devicetree_cleanup(struct devicetree_state *state) { in devicetree_cleanup() argument
137 if (!state->pages) in devicetree_cleanup()
140 err = BS->InstallConfigurationTable(&EfiDtbTableGuid, state->orig); in devicetree_cleanup()
145 BS->FreePages(state->addr, state->pages); in devicetree_cleanup()
146 state->pages = 0; in devicetree_cleanup()