I386_VM86(2)
β¨ i386_vm86 β control vm86-related functions β¨
okay bestie, welcome to the System Calls Manual section of the Unix lore π this one's a deep cut, like a b-side from 1998 that only the real ones know about. It's giving vintage. It's giving x86 real mode. Let's get into it π
πΈ LIBRARY πΈ
Standard C Library (libc, -lc) β yeah she lives in libc, no extra credit needed, you already have her π«Ά
π¦ SYNOPSIS π¦
#include <sys/types.h>
#include <machine/sysarch.h>
#include <machine/vm86.h>
int
i386_vm86(int function, void *data);
like three whole includes, she's high maintenance but honestly? worth it β¨
π DESCRIPTION π
So i386_vm86() is the syscall you call when you want to do various vm86 related functions. That's the whole vibe. It's a multiplexer, she contains multitudes π
The function argument is the main character here, and she can be one of these three values:
VM86_INITβ this initializes the kernel's vm86 parameter area for the process, and permits the process to make vm86 calls π Thedataargument points to this structure:
struct vm86_init_args {
int debug;
int cpu_type;
u_char int_map[32];
};
- the
debugargument is used to turn on debugging code (not me turning on debug mode and immediately forgetting what I was doing π) - the
cpu_typeargument controls the type of CPU being emulated, and is currently unimplemented β so like, she's there, she's just not doing anything yet, queen of showing up π - the
int_mapargument is a bitmap that decides whether vm86 interrupts should be handled in vm86 mode, or reflected back to the process. If the Nth bit is set, the interrupt will be reflected to the process, otherwise it will be dispatched by the vm86 interrupt table. periodt β¨
VM86_INTCALLβ this lets the process make calls to vm86 interrupt handlers. It effectively simulates anINTinstruction, no cap.datashould point to this structure:
struct vm86_intcall_args {
int intnum;
struct vm86frame vmf;
};
intnumspecifies the operand ofINTfor the simulated call. A value of0x10, for example, would often be used to call into the VGA BIOS. iconic behavior fr frvmfis used to initialize CPU registers according to the calling convention for the interrupt handler π§
VM86_GET_VMEβ this one's a little getter, she retrieves the current state of the Pentium(r) processor's VME (Virtual-8086 Mode Extensions) flag, which is bit 0 of CR4.datashould be initialized to point to this:
struct vm86_vme_args {
int state; /* status */
};
statewill contain the state of the VME flag on return π
okay and now the part that's giving actual lore π«Ά
vm86 mode is entered by calling sigreturn(2) with the correct machine context for vm86, and with the PSL_VM bit set. Control returns to the process upon delivery of a signal. that's the whole ritual bestie, that's the vibe check π
π RETURN VALUES π
The i386_vm86() function returns the value 0 if successful β slay β¨ otherwise the value -1 is returned and the global variable errno is set to indicate the error. we hate to see it but at least she tells you why π
π₯ ERRORS π₯
The i386_vm86() system call will fail if:
[EINVAL]β the kernel does not have vm86 support, or an invalidfunctionwas specified. (either your kernel said "not today" or you asked for something that doesn't exist π)[ENOMEM]β there is not enough memory to initialize the kernel data structures. she's broke, it happens π
π AUTHORS π
This man page was written by Jonathan Lemon, and updated by Bruce M Simpson. absolute legends, we stan π«Άπ
ngl bestie, this page is old old. like, July 27, 1998 old. Debian shipped it, the manual section is I386_VM86(2), and she has aged like fine wine β still out here controlling vm86-related functions after all these years ππΈ bye bestie, go make some vm86 calls responsibly π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1998 Jonathan Lemon
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms