blob: efdf422488b367643322ef72822a50cc97fb43cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2012 The ChromiumOS Authors. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc.
*/
#ifndef __INCLUDE_ARCH_CBFS__
#define __INCLUDE_ARCH_CBFS__
#include <cbfs_serialized.h>
#include <endian.h>
#define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + ntohl((_p)->offset))) )
static struct cbfs_file *walkcbfs_head(char *target)
{
void *entry;
asm volatile (
"mov $1f, %%esp\n\t"
"jmp walkcbfs_asm\n\t"
"1:\n\t" : "=a" (entry) : "S" (target) : "ebx", "ecx", "edi", "esp");
return entry;
}
static void *walkcbfs(char *target)
{
struct cbfs_file *head = walkcbfs_head(target);
if ((u32)head != 0)
return CBFS_SUBHEADER(head);
/* We should never reach this if 'target' exists */
return (void *)0;
}
/* just enough to support findstage. copied because the original version doesn't easily pass through romcc */
struct cbfs_stage_restricted {
unsigned long compression;
unsigned long entry; // this is really 64bit, but properly endianized
};
static inline unsigned long findstage(char* target)
{
struct cbfs_stage_restricted *stage = walkcbfs(target);
if ((u32)stage != 0)
return stage->entry;
/* We should never reach this if 'target' exists */
return 0;
}
static inline void call(unsigned long addr, unsigned long bist)
{
asm volatile ("jmp *%0\n\t" : : "r" (addr), "a" (bist));
}
#endif
|