1*13e8728fSAndroid Build Coastguard Worker /* 2*13e8728fSAndroid Build Coastguard Worker * Copyright (C) 2017 The Android Open Source Project 3*13e8728fSAndroid Build Coastguard Worker * 4*13e8728fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*13e8728fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*13e8728fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*13e8728fSAndroid Build Coastguard Worker * 8*13e8728fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*13e8728fSAndroid Build Coastguard Worker * 10*13e8728fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*13e8728fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*13e8728fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*13e8728fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*13e8728fSAndroid Build Coastguard Worker * limitations under the License. 15*13e8728fSAndroid Build Coastguard Worker */ 16*13e8728fSAndroid Build Coastguard Worker 17*13e8728fSAndroid Build Coastguard Worker #include "dt_table.h" 18*13e8728fSAndroid Build Coastguard Worker 19*13e8728fSAndroid Build Coastguard Worker #include <memory.h> 20*13e8728fSAndroid Build Coastguard Worker 21*13e8728fSAndroid Build Coastguard Worker #include "libacpi.h" 22*13e8728fSAndroid Build Coastguard Worker #include "libfdt.h" 23*13e8728fSAndroid Build Coastguard Worker #include "libufdt_sysdeps.h" 24*13e8728fSAndroid Build Coastguard Worker dt_table_header_init(struct dt_table_header * header,enum DT_TYPE dt_type)25*13e8728fSAndroid Build Coastguard Workervoid dt_table_header_init(struct dt_table_header *header, enum DT_TYPE dt_type) { 26*13e8728fSAndroid Build Coastguard Worker const uint32_t header_size = sizeof(struct dt_table_header); 27*13e8728fSAndroid Build Coastguard Worker const uint32_t entry_size = sizeof(struct dt_table_entry); 28*13e8728fSAndroid Build Coastguard Worker 29*13e8728fSAndroid Build Coastguard Worker dto_memset(header, 0, header_size); 30*13e8728fSAndroid Build Coastguard Worker if (dt_type == ACPI) 31*13e8728fSAndroid Build Coastguard Worker header->magic = cpu_to_fdt32(ACPI_TABLE_MAGIC); 32*13e8728fSAndroid Build Coastguard Worker else 33*13e8728fSAndroid Build Coastguard Worker header->magic = cpu_to_fdt32(DT_TABLE_MAGIC); 34*13e8728fSAndroid Build Coastguard Worker 35*13e8728fSAndroid Build Coastguard Worker header->total_size = cpu_to_fdt32(header_size); 36*13e8728fSAndroid Build Coastguard Worker header->header_size = cpu_to_fdt32(header_size); 37*13e8728fSAndroid Build Coastguard Worker header->dt_entry_size = cpu_to_fdt32(entry_size); 38*13e8728fSAndroid Build Coastguard Worker header->dt_entries_offset = cpu_to_fdt32(header_size); 39*13e8728fSAndroid Build Coastguard Worker header->page_size = cpu_to_fdt32(DT_TABLE_DEFAULT_PAGE_SIZE); 40*13e8728fSAndroid Build Coastguard Worker header->version = cpu_to_fdt32(DT_TABLE_DEFAULT_VERSION); 41*13e8728fSAndroid Build Coastguard Worker } 42