iPXE
bios_reboot.c File Reference

Standard PC-BIOS reboot mechanism. More...

#include <string.h>
#include <ipxe/reboot.h>
#include <realmode.h>
#include <bios.h>
#include <ipxe/apm.h>
#include <ipxe/acpipwr.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static void bios_reboot (int flags)
 Reboot system.
static int bios_poweroff (void)
 Power off system.
 PROVIDE_REBOOT (pcbios, reboot, bios_reboot)
 PROVIDE_REBOOT (pcbios, poweroff, bios_poweroff)

Detailed Description

Standard PC-BIOS reboot mechanism.

Definition in file bios_reboot.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ bios_reboot()

void bios_reboot ( int flags)
static

Reboot system.

Parameters
flagsReboot flags

Definition at line 44 of file bios_reboot.c.

44 {
46
47 /* Configure BIOS for cold/warm reboot */
48 type = ( ( flags & REBOOT_WARM ) ? BDA_REBOOT_WARM : 0 );
50
51 /* Jump to system reset vector */
52 __asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : );
53}
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
unsigned short uint16_t
Definition stdint.h:11
#define BDA_REBOOT_WARM
Definition bios.h:18
#define BDA_SEG
Definition bios.h:6
#define BDA_REBOOT
Definition bios.h:17
uint32_t type
Operating system type.
Definition ena.h:1
uint8_t flags
Flags.
Definition ena.h:7
#define REBOOT_WARM
Perform a warm reboot.
Definition reboot.h:59
#define put_real
Definition libkir.h:150
#define REAL_CODE(asm_code_str)
Definition libkir.h:226
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

References __asm__(), __volatile__(), BDA_REBOOT, BDA_REBOOT_WARM, BDA_SEG, flags, put_real, REAL_CODE, REBOOT_WARM, and type.

Referenced by PROVIDE_REBOOT().

◆ bios_poweroff()

int bios_poweroff ( void )
static

Power off system.

Return values
rcReturn status code

Definition at line 60 of file bios_reboot.c.

60 {
61 int rc;
62
63 /* Try APM */
64 if ( ( rc = apm_poweroff() ) != 0 )
65 DBG ( "APM power off failed: %s\n", strerror ( rc ) );
66
67 /* Try ACPI */
68 if ( ( rc = acpi_poweroff() ) != 0 )
69 DBG ( "ACPI power off failed: %s\n", strerror ( rc ) );
70
71 return rc;
72}
int acpi_poweroff(void)
Power off the computer using ACPI.
Definition acpipwr.c:115
int apm_poweroff(void)
Power off the computer using APM.
Definition apm.c:42
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79

References acpi_poweroff(), apm_poweroff(), DBG, rc, and strerror().

Referenced by PROVIDE_REBOOT().

◆ PROVIDE_REBOOT() [1/2]

PROVIDE_REBOOT ( pcbios ,
reboot ,
bios_reboot  )

References bios_reboot(), and reboot().

◆ PROVIDE_REBOOT() [2/2]

PROVIDE_REBOOT ( pcbios ,
poweroff ,
bios_poweroff  )

References bios_poweroff(), and poweroff().