iPXE
Functions
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. More...
 
static int bios_poweroff (void)
 Power off system. More...
 
 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()

static void bios_reboot ( int  flags)
static

Reboot system.

Parameters
flagsReboot flags

Definition at line 44 of file bios_reboot.c.

44  {
45  uint16_t type;
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 }
unsigned short uint16_t
Definition: stdint.h:11
uint32_t type
Operating system type.
Definition: ena.h:12
#define BDA_REBOOT_WARM
Definition: bios.h:18
#define BDA_REBOOT
Definition: bios.h:17
#define put_real
Definition: libkir.h:150
uint8_t flags
Flags.
Definition: ena.h:18
__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))
#define REBOOT_WARM
Perform a warm reboot.
Definition: reboot.h:58
#define BDA_SEG
Definition: bios.h:6
__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")
#define REAL_CODE(asm_code_str)
Definition: libkir.h:226

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

◆ bios_poweroff()

static 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 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int acpi_poweroff(void)
Power off the computer using ACPI.
Definition: acpipwr.c:115
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int apm_poweroff(void)
Power off the computer using APM.
Definition: apm.c:42
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

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

◆ PROVIDE_REBOOT() [1/2]

PROVIDE_REBOOT ( pcbios  ,
reboot  ,
bios_reboot   
)

◆ PROVIDE_REBOOT() [2/2]

PROVIDE_REBOOT ( pcbios  ,
poweroff  ,
bios_poweroff   
)