Ronald G. Minnich | e0e784a | 2014-11-26 19:25:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Ronald G. Minnich | e0e784a | 2014-11-26 19:25:47 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Aaron Durbin | 04654a2 | 2015-03-17 11:43:44 -0500 | [diff] [blame] | 16 | #include <program_loading.h> |
Ronald G. Minnich | f47f5fb | 2015-09-22 15:53:32 -0700 | [diff] [blame] | 17 | #include <vm.h> |
| 18 | #include <arch/encoding.h> |
| 19 | #include <rules.h> |
Ronald G. Minnich | e0e784a | 2014-11-26 19:25:47 +0000 | [diff] [blame] | 20 | |
Aaron Durbin | b3847e6 | 2015-03-20 15:55:08 -0500 | [diff] [blame] | 21 | void arch_prog_run(struct prog *prog) |
Ronald G. Minnich | e0e784a | 2014-11-26 19:25:47 +0000 | [diff] [blame] | 22 | { |
Ronald G. Minnich | f47f5fb | 2015-09-22 15:53:32 -0700 | [diff] [blame] | 23 | void (*doit)(void *) = prog_entry(prog); |
Aaron Durbin | b3847e6 | 2015-03-20 15:55:08 -0500 | [diff] [blame] | 24 | |
Aaron Durbin | 7e7a4df | 2015-12-08 14:34:35 -0600 | [diff] [blame] | 25 | if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) { |
Ronald G. Minnich | f47f5fb | 2015-09-22 15:53:32 -0700 | [diff] [blame] | 26 | initVirtualMemory(); |
| 27 | write_csr(mepc, doit); |
| 28 | asm volatile("eret"); |
| 29 | } else { |
| 30 | doit(prog_entry_arg(prog)); |
| 31 | } |
Aaron Durbin | b3847e6 | 2015-03-20 15:55:08 -0500 | [diff] [blame] | 32 | } |