paul@60 | 1 | /* |
paul@60 | 2 | * Payload initialisation functions. |
paul@60 | 3 | * |
paul@60 | 4 | * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@60 | 5 | * |
paul@60 | 6 | * This program is free software: you can redistribute it and/or modify |
paul@60 | 7 | * it under the terms of the GNU General Public License as published by |
paul@60 | 8 | * the Free Software Foundation, either version 3 of the License, or |
paul@60 | 9 | * (at your option) any later version. |
paul@60 | 10 | * |
paul@60 | 11 | * This program is distributed in the hope that it will be useful, |
paul@60 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@60 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@60 | 14 | * GNU General Public License for more details. |
paul@60 | 15 | * |
paul@60 | 16 | * You should have received a copy of the GNU General Public License |
paul@60 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@60 | 18 | */ |
paul@60 | 19 | |
paul@60 | 20 | #include <stdint.h> |
paul@60 | 21 | |
paul@60 | 22 | /* Relocate the .data section's contents to initialise mutable structures. */ |
paul@60 | 23 | |
paul@60 | 24 | void relocate_data(uint32_t *original, uint32_t *current, uint32_t size) |
paul@60 | 25 | { |
paul@60 | 26 | /* Reference stored content as values. */ |
paul@60 | 27 | |
paul@60 | 28 | uint32_t *source, *target; |
paul@60 | 29 | |
paul@60 | 30 | /* Copy data from program memory to the relocated data area in RAM. */ |
paul@60 | 31 | |
paul@60 | 32 | for (source = original, target = current; source < original + size; |
paul@60 | 33 | source++, target++) |
paul@60 | 34 | |
paul@60 | 35 | *target = *source; |
paul@60 | 36 | } |