mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 11:18:30 +00:00
Get binaries closer to running without an o/s
blinkenlights now does a pretty good job emulating what happens when binaries boot from BIOS into long mode. So it's been much easier to debug the bare metal process and wrinkle out many issues.
This commit is contained in:
parent
feed0d2b0e
commit
2d80bbc802
50 changed files with 974 additions and 1062 deletions
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_RDTSCP_H_
|
||||
#define COSMOPOLITAN_LIBC_NEXGEN32E_RDTSCP_H_
|
||||
#include "libc/bits/bits.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
@ -32,17 +33,26 @@ COSMOPOLITAN_C_START_
|
|||
*/
|
||||
#define rdpid() \
|
||||
({ \
|
||||
bool Ok; \
|
||||
long Msr; \
|
||||
Ok = false; \
|
||||
if (X86_HAVE(RDPID)) { \
|
||||
asm volatile("rdpid\t%0" : "=r"(Msr) : /* no inputs */ : "memory"); \
|
||||
Ok = true; \
|
||||
} else if (IsLinux()) { \
|
||||
asm volatile("lsl\t%1,%0" : "=r"(Msr) : "r"(0x7b) : "memory"); \
|
||||
} else if (X86_HAVE(RDTSCP)) { \
|
||||
asm volatile(ZFLAG_ASM("lsl\t%2,%1") \
|
||||
: ZFLAG_CONSTRAINT(Ok), "=r"(Msr) \
|
||||
: "r"(0x7b) \
|
||||
: "memory"); \
|
||||
} \
|
||||
if (!Ok && X86_HAVE(RDTSCP)) { \
|
||||
asm volatile("rdtscp" \
|
||||
: "=c"(Msr) \
|
||||
: /* no inputs */ \
|
||||
: "eax", "edx", "memory"); \
|
||||
} else { \
|
||||
Ok = true; \
|
||||
} \
|
||||
if (!Ok) { \
|
||||
Msr = -1; \
|
||||
} \
|
||||
Msr; \
|
||||
|
|
|
@ -1,38 +1,3 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=8 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╠──────────────────────────────────────────────────────────────────────────────╣
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░▀█▀░█░█░█▀█░█░░░█░░░█░█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█░▄░░█░░█░█░█▀█░█░░░█░░░▀█▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░▀░▀░▀▀▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░░▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░█▀█░▀█▀░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀▀░█ █░██▀░░█░░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░▀░░░▀▀▀░▀░▀░░▀░░▀░▀░▀▀▀░▀▀▀░▀▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀▀░█░█░█▀▀░█▀█░█░█░▀█▀░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░▄▄░░░▐█░░│
|
||||
│░░░░░░░█▀▀░▄▀▄░█▀▀░█░▄░█░█░░█░░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░▄▄▄░░░▄██▄░░█▀░░░█░▄░│
|
||||
│░░░░░░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░░▀░░▀░▀░▀▀▀░▀▀░▀▀▀░░░░░░░░░░▄██▀█▌░██▄▄░░▐█▀▄░▐█▀░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▐█▀▀▌░░░▄▀▌░▌░█░▌░░▌░▌░░│
|
||||
╠──────────────────────────────────────────────────────▌▀▄─▐──▀▄─▐▄─▐▄▐▄─▐▄─▐▄─│
|
||||
│ αcτµαlly pδrταblε εxεcµταblε § telecommunications │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_UART_H_
|
||||
#define COSMOPOLITAN_LIBC_NEXGEN32E_UART_H_
|
||||
|
||||
|
@ -53,22 +18,23 @@
|
|||
* @see www.lammertbies.nl/comm/info/serial-uart.html
|
||||
*/
|
||||
|
||||
#define COM1 0x0 /* offset in pc bios data area with port number (0x400) */
|
||||
#define COM2 0x2
|
||||
#define COM3 0x4
|
||||
#define COM4 0x6
|
||||
#define IRQ3 0x0b /* com2 interrupt number (irq3) */
|
||||
#define IRQ4 0x0c /* com1 interrupt number (irq4) */
|
||||
#define UART_DLAB (1 << 7) /* serial line conf mode bit */
|
||||
#define UART_DLL 0 /* divisor latch register */
|
||||
#define UART_DLM 1 /* divisor latch register */
|
||||
#define UART_IIR 2 /* interrupt identification register */
|
||||
#define UART_LCR 3 /* line control register */
|
||||
#define UART_LSR 5 /* line status register */
|
||||
#define UART_TTYDA (1 << 0) /* data available (rx ready) */
|
||||
#define UART_TTYOE (1 << 1) /* overrun error */
|
||||
#define UART_TTYPE (1 << 2) /* parity error */
|
||||
#define UART_TTYFE (1 << 3) /* framing error */
|
||||
#define COM1 0x0 /* offset in pc bios data area with port number (0x400) */
|
||||
#define COM2 0x2
|
||||
#define COM3 0x4
|
||||
#define COM4 0x6
|
||||
#define IRQ3 0x0b /* com2 interrupt number (irq3) */
|
||||
#define IRQ4 0x0c /* com1 interrupt number (irq4) */
|
||||
#define UART_DLAB (1 << 7) /* serial line conf mode bit */
|
||||
#define UART_DLL 0 /* divisor latch register */
|
||||
#define UART_DLM 1 /* divisor latch register */
|
||||
#define UART_IIR 2 /* interrupt identification register */
|
||||
#define UART_LCR 3 /* line control register */
|
||||
#define UART_MCR 4 /* modem control register */
|
||||
#define UART_LSR 5 /* line status register */
|
||||
#define UART_TTYDA (1 << 0) /* data available (rx ready) */
|
||||
#define UART_TTYOE (1 << 1) /* overrun error */
|
||||
#define UART_TTYPE (1 << 2) /* parity error */
|
||||
#define UART_TTYFE (1 << 3) /* framing error */
|
||||
#define UART_TTYBSR (1 << 4) /* break signal received */
|
||||
#define UART_TTYTXR (1 << 5) /* serial thr empty (tx ready) */
|
||||
#define UART_TTYIDL (1 << 6) /* serial thr empty and line idle */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue