blob: 552b3f4cd61ec983d9e15436e5c5829957f40660 [file] [log] [blame]
Ronald G. Minniche0e784a2014-11-26 19:25:47 +00001/*
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. Minniche0e784a2014-11-26 19:25:47 +000014 */
15
Aaron Durbin04654a22015-03-17 11:43:44 -050016#include <program_loading.h>
Ronald G. Minnichf47f5fb2015-09-22 15:53:32 -070017#include <vm.h>
18#include <arch/encoding.h>
19#include <rules.h>
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000020
Aaron Durbinb3847e62015-03-20 15:55:08 -050021void arch_prog_run(struct prog *prog)
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000022{
Ronald G. Minnichf47f5fb2015-09-22 15:53:32 -070023 void (*doit)(void *) = prog_entry(prog);
Aaron Durbinb3847e62015-03-20 15:55:08 -050024
Aaron Durbin7e7a4df2015-12-08 14:34:35 -060025 if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) {
Ronald G. Minnichf47f5fb2015-09-22 15:53:32 -070026 initVirtualMemory();
27 write_csr(mepc, doit);
28 asm volatile("eret");
29 } else {
30 doit(prog_entry_arg(prog));
31 }
Aaron Durbinb3847e62015-03-20 15:55:08 -050032}