mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
Kernel: Add TSS64 and Desciptor for 64-bit
This commit is contained in:
parent
009b196a04
commit
5a8cc07485
Notes:
sideshowbarker
2024-07-18 21:13:03 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/5a8cc074857 Pull-request: https://github.com/SerenityOS/serenity/pull/5679 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg
|
@ -672,7 +672,7 @@ class Processor {
|
|||
Atomic<u32, AK::MemoryOrder::memory_order_relaxed> m_in_critical;
|
||||
static Atomic<u32> s_idle_cpu_mask;
|
||||
|
||||
TSS32 m_tss;
|
||||
TSS m_tss;
|
||||
static FPUState s_clean_fpu_state;
|
||||
CPUFeature m_features;
|
||||
static volatile u32 g_total_processors; // atomic
|
||||
|
@ -1140,5 +1140,4 @@ ALWAYS_INLINE void clac()
|
|||
asm volatile("clac" ::
|
||||
: "cc");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
114
Kernel/Arch/x86_64/CPU.h
Normal file
114
Kernel/Arch/x86_64/CPU.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Leon Albrecht <leon2002.la@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/VirtualAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
struct [[gnu::packed]] TSS64
|
||||
{
|
||||
u32 __1; // Link?
|
||||
u64 rsp0;
|
||||
u64 rsp1;
|
||||
u64 rsp2;
|
||||
u64 __2; // IST0 -> empty?
|
||||
u64 ist1;
|
||||
u64 ist2;
|
||||
u64 ist3;
|
||||
u64 ist4;
|
||||
u64 ist5;
|
||||
u64 ist6;
|
||||
u64 ist7;
|
||||
u64 __3;
|
||||
u16 __4;
|
||||
u16 iomapbase;
|
||||
};
|
||||
|
||||
union [[gnu::packed]] Descriptor
|
||||
{
|
||||
struct {
|
||||
u16 limit_lo;
|
||||
u16 base_lo;
|
||||
u8 base_hi;
|
||||
u8 type : 4;
|
||||
u8 descriptor_type : 1;
|
||||
u8 dpl : 2;
|
||||
u8 segment_present : 1;
|
||||
u8 limit_hi : 4;
|
||||
u8 : 1;
|
||||
u8 operation_size64 : 1;
|
||||
u8 operation_size32 : 1;
|
||||
u8 granularity : 1;
|
||||
u8 base_hi2;
|
||||
};
|
||||
struct {
|
||||
u32 low;
|
||||
u32 high;
|
||||
};
|
||||
|
||||
enum Type {
|
||||
Invalid = 0,
|
||||
AvailableTSS_16bit = 0x1,
|
||||
LDT = 0x2,
|
||||
BusyTSS_16bit = 0x3,
|
||||
CallGate_16bit = 0x4,
|
||||
TaskGate = 0x5,
|
||||
InterruptGate_16bit = 0x6,
|
||||
TrapGate_16bit = 0x7,
|
||||
AvailableTSS_32bit = 0x9,
|
||||
BusyTSS_32bit = 0xb,
|
||||
CallGate_32bit = 0xc,
|
||||
InterruptGate_32bit = 0xe,
|
||||
TrapGate_32bit = 0xf,
|
||||
};
|
||||
|
||||
VirtualAddress base() const
|
||||
{
|
||||
FlatPtr base = base_lo;
|
||||
base |= base_hi << 16u;
|
||||
base |= base_hi2 << 24u;
|
||||
return VirtualAddress { base };
|
||||
}
|
||||
|
||||
void set_base(VirtualAddress base)
|
||||
{
|
||||
base_lo = base.get() & 0xffffu;
|
||||
base_hi = (base.get() >> 16u) & 0xffu;
|
||||
base_hi2 = (base.get() >> 24u) & 0xffu;
|
||||
}
|
||||
|
||||
void set_limit(u32 length)
|
||||
{
|
||||
limit_lo = length & 0xffff;
|
||||
limit_hi = (length >> 16) & 0xf;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue