iPXE
Functions
bios_reboot.c File Reference

Standard PC-BIOS reboot mechanism. More...

#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 warm)
 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  warm)
static

Reboot system.

Parameters
warmPerform a warm reboot

Definition at line 43 of file bios_reboot.c.

43  {
44  uint16_t flag;
45 
46  /* Configure BIOS for cold/warm reboot */
47  flag = ( warm ? BDA_REBOOT_WARM : 0 );
49 
50  /* Jump to system reset vector */
51  __asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : );
52 }
unsigned short uint16_t
Definition: stdint.h:11
#define BDA_REBOOT_WARM
Definition: bios.h:13
#define BDA_REBOOT
Definition: bios.h:12
#define put_real
Definition: libkir.h:150
#define BDA_SEG
Definition: bios.h:6
__asm__ __volatile__("\n1:\n\t" "movb -1(%2,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %3, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
__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
uint16_t flag
Flag number.
Definition: hyperv.h:14

References __asm__(), __volatile__(), BDA_REBOOT, BDA_REBOOT_WARM, BDA_SEG, flag, put_real, and REAL_CODE.

◆ bios_poweroff()

static int bios_poweroff ( void  )
static

Power off system.

Return values
rcReturn status code

Definition at line 59 of file bios_reboot.c.

59  {
60  int rc;
61 
62  /* Try APM */
63  if ( ( rc = apm_poweroff() ) != 0 )
64  DBG ( "APM power off failed: %s\n", strerror ( rc ) );
65 
66  /* Try ACPI */
67  if ( ( rc = acpi_poweroff() ) != 0 )
68  DBG ( "ACPI power off failed: %s\n", strerror ( rc ) );
69 
70  return rc;
71 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int acpi_poweroff(void)
Power off the computer using ACPI.
Definition: acpipwr.c:50
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   
)