coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
thread.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#include <
thread.h
>
4
5
#if ENV_X86_64
6
#error COOP_MULTITASKING does not currently support x86_64
7
#endif
8
9
/* The stack frame looks like the following after a pushad instruction. */
10
struct
pushad_regs
{
11
uint32_t
edi
;
/* Offset 0x00 */
12
uint32_t
esi
;
/* Offset 0x04 */
13
uint32_t
ebp
;
/* Offset 0x08 */
14
uint32_t
esp
;
/* Offset 0x0c */
15
uint32_t
ebx
;
/* Offset 0x10 */
16
uint32_t
edx
;
/* Offset 0x14 */
17
uint32_t
ecx
;
/* Offset 0x18 */
18
uint32_t
eax
;
/* Offset 0x1c */
19
};
20
21
static
inline
uintptr_t
push_stack
(
uintptr_t
cur_stack,
uintptr_t
value
)
22
{
23
uintptr_t
*
addr
;
24
25
cur_stack -=
sizeof
(
value
);
26
addr
= (
uintptr_t
*)cur_stack;
27
*
addr
=
value
;
28
return
cur_stack;
29
}
30
31
void
arch_prepare_thread
(
struct
thread *t,
32
asmlinkage
void
(*thread_entry)(
void
*),
void
*
arg
)
33
{
34
uintptr_t
stack = t->stack_current;
35
36
/* Imitate thread_entry(t) with return address of 0. thread_entry()
37
* is assumed to never return. */
38
stack =
push_stack
(stack, (
uintptr_t
)
arg
);
39
stack =
push_stack
(stack, (
uintptr_t
)0);
40
stack =
push_stack
(stack, (
uintptr_t
)thread_entry);
41
/* Make room for the registers. Ignore initial values. */
42
stack -=
sizeof
(
struct
pushad_regs
);
43
44
t->stack_current = stack;
45
}
value
pte_t value
Definition:
mmu.c:91
asmlinkage
#define asmlinkage
Definition:
cpu.h:8
push_stack
static uintptr_t push_stack(uintptr_t cur_stack, uintptr_t value)
Definition:
thread.c:21
arch_prepare_thread
void arch_prepare_thread(struct thread *t, asmlinkage void(*thread_entry)(void *), void *arg)
Definition:
thread.c:31
addr
static u32 addr
Definition:
cirrus.c:14
arg
struct bootblock_arg arg
Definition:
decompressor.c:22
uint32_t
unsigned int uint32_t
Definition:
stdint.h:14
uintptr_t
unsigned long uintptr_t
Definition:
stdint.h:21
pushad_regs
Definition:
thread.c:10
pushad_regs::ebp
uint32_t ebp
Definition:
thread.c:13
pushad_regs::edx
uint32_t edx
Definition:
thread.c:16
pushad_regs::ecx
uint32_t ecx
Definition:
thread.c:17
pushad_regs::ebx
uint32_t ebx
Definition:
thread.c:15
pushad_regs::esp
uint32_t esp
Definition:
thread.c:14
pushad_regs::edi
uint32_t edi
Definition:
thread.c:11
pushad_regs::esi
uint32_t esi
Definition:
thread.c:12
pushad_regs::eax
uint32_t eax
Definition:
thread.c:18
thread.h
src
arch
x86
thread.c
Generated by
1.9.1