Two minor changes to the copyright and license marking for these files: (1) Stacey D Son is used instead of variations of his name. (2) The GPL boilerplate is replaced by SPDX markings. No change to the terms of the license are intended, and this matches current QEMU practice. There's no changes to the license or additional claims to any IP that others may hold in these files. All the S-o-bs in this commit have given me permission to do this to the extent they may hold rights. git blame over multiple repos and branches suggests that only minimal other material is present (much of it likely not subject to copyright protection). The project's long and complex history as well as tooling limitations make it hard to be 100% sure. Any omissions are unintentional and I will correct them as they come to light. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Sean Bruno <sbruno@FreeBSD.org> Signed-off-by: Mikaël Urankar <mikael.urankar@gmail.com> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Guy Yur <guyyur@gmail.com> Signed-off-by: Alexander Kabaev <kan@FreeBSD.org> Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Ed Schouten <ed@nuxi.nl> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Warner Losh <imp@bsdimp.com>
60 lines
1.3 KiB
C
60 lines
1.3 KiB
C
/*
|
|
* x86_64 cpu related code
|
|
*
|
|
* Copyright (c) 2013 Stacey D. Son
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "cpu.h"
|
|
#include "qemu.h"
|
|
#include "qemu/timer.h"
|
|
|
|
#include "target_arch.h"
|
|
|
|
static uint64_t *idt_table;
|
|
|
|
uint64_t cpu_get_tsc(CPUX86State *env)
|
|
{
|
|
return cpu_get_host_ticks();
|
|
}
|
|
|
|
void bsd_x86_64_write_dt(void *ptr, unsigned long addr,
|
|
unsigned long limit, int flags)
|
|
{
|
|
unsigned int e1, e2;
|
|
uint32_t *p;
|
|
e1 = (addr << 16) | (limit & 0xffff);
|
|
e2 = ((addr >> 16) & 0xff) | (addr & 0xff000000) | (limit & 0x000f0000);
|
|
e2 |= flags;
|
|
p = ptr;
|
|
p[0] = tswap32(e1);
|
|
p[1] = tswap32(e2);
|
|
}
|
|
|
|
static void set_gate64(void *ptr, unsigned int type, unsigned int dpl,
|
|
uint64_t addr, unsigned int sel)
|
|
{
|
|
uint32_t *p, e1, e2;
|
|
e1 = (addr & 0xffff) | (sel << 16);
|
|
e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8);
|
|
p = ptr;
|
|
p[0] = tswap32(e1);
|
|
p[1] = tswap32(e2);
|
|
p[2] = tswap32(addr >> 32);
|
|
p[3] = 0;
|
|
}
|
|
|
|
/* only dpl matters as we do only user space emulation */
|
|
void bsd_x86_64_set_idt(int n, unsigned int dpl)
|
|
{
|
|
set_gate64(idt_table + n * 2, 0, dpl, 0, 0);
|
|
}
|
|
|
|
void bsd_x86_64_set_idt_base(uint64_t base)
|
|
{
|
|
idt_table = g2h_untagged(base);
|
|
}
|