nova: add syscall pt_ctrl bindings

Issue #667
This commit is contained in:
Alexander Boettcher 2013-02-22 14:42:32 +01:00 committed by Norman Feske
parent 2664afbd7d
commit 46447d531e
4 changed files with 50 additions and 16 deletions

View File

@ -67,9 +67,9 @@ namespace Nova {
ALWAYS_INLINE
inline uint8_t syscall_1(Syscall s, uint8_t flags, mword_t p1)
inline uint8_t syscall_1(Syscall s, uint8_t flags, unsigned sel, mword_t p1)
{
mword_t status = eax(s, flags, 0);
mword_t status = eax(s, flags, sel);
asm volatile (" mov %%esp, %%ecx;"
" call 0f;"
@ -222,9 +222,22 @@ namespace Nova {
ALWAYS_INLINE
inline uint8_t create_pt(unsigned pt, unsigned pd, unsigned ec, Mtd mtd, mword_t eip)
inline uint8_t pt_ctrl(mword_t pt, mword_t pt_id)
{
return syscall_4(NOVA_CREATE_PT, 0, pt, pd, ec, mtd.value(), eip);
return syscall_1(NOVA_PT_CTRL, 0, pt, pt_id);
}
ALWAYS_INLINE
inline uint8_t create_pt(unsigned pt, unsigned pd, unsigned ec, Mtd mtd,
mword_t eip, bool id_equal_pt = true)
{
uint8_t res = syscall_4(NOVA_CREATE_PT, 0, pt, pd, ec, mtd.value(), eip);
if (!id_equal_pt || res != NOVA_OK)
return res;
return pt_ctrl(pt, pt);
}
@ -238,7 +251,7 @@ namespace Nova {
ALWAYS_INLINE
inline uint8_t revoke(Crd crd, bool self = true)
{
return syscall_1(NOVA_REVOKE, self, crd.value());
return syscall_1(NOVA_REVOKE, self, 0, crd.value());
}

View File

@ -62,9 +62,10 @@ namespace Nova {
ALWAYS_INLINE
inline uint8_t syscall_1(Syscall s, uint8_t flags, mword_t p1, mword_t * p2 = 0)
inline uint8_t syscall_1(Syscall s, uint8_t flags, mword_t sel, mword_t p1,
mword_t * p2 = 0)
{
mword_t status = rdi(s, flags, 0);
mword_t status = rdi(s, flags, sel);
asm volatile ("syscall"
: "+D" (status), "+S" (p1)
@ -76,7 +77,8 @@ namespace Nova {
ALWAYS_INLINE
inline uint8_t syscall_2(Syscall s, uint8_t flags, mword_t sel, mword_t p1, mword_t p2)
inline uint8_t syscall_2(Syscall s, uint8_t flags, mword_t sel, mword_t p1,
mword_t p2)
{
mword_t status = rdi(s, flags, sel);
@ -183,9 +185,22 @@ namespace Nova {
ALWAYS_INLINE
inline uint8_t create_pt(mword_t pt, mword_t pd, mword_t ec, Mtd mtd, mword_t rip)
inline uint8_t pt_ctrl(mword_t pt, mword_t pt_id)
{
return syscall_4(NOVA_CREATE_PT, 0, pt, pd, ec, mtd.value(), rip);
return syscall_1(NOVA_PT_CTRL, 0, pt, pt_id);
}
ALWAYS_INLINE
inline uint8_t create_pt(mword_t pt, mword_t pd, mword_t ec, Mtd mtd,
mword_t rip, bool id_equal_pt = true)
{
uint8_t res = syscall_4(NOVA_CREATE_PT, 0, pt, pd, ec, mtd.value(), rip);
if (!id_equal_pt || res != NOVA_OK)
return res;
return pt_ctrl(pt, pt);
}
@ -199,7 +214,7 @@ namespace Nova {
ALWAYS_INLINE
inline uint8_t revoke(Crd crd, bool self = true)
{
return syscall_1(NOVA_REVOKE, self, crd.value());
return syscall_1(NOVA_REVOKE, self, 0, crd.value());
}
@ -207,7 +222,7 @@ namespace Nova {
inline uint8_t lookup(Crd &crd)
{
mword_t crd_r;
uint8_t res=syscall_1(NOVA_LOOKUP, 0, crd.value(), &crd_r);
uint8_t res = syscall_1(NOVA_LOOKUP, 0, 0, crd.value(), &crd_r);
crd = Crd(crd_r);
return res;
}
@ -243,8 +258,10 @@ namespace Nova {
return syscall_2(NOVA_ASSIGN_PCI, 0, pd, mem, rid);
}
ALWAYS_INLINE
inline uint8_t assign_gsi(mword_t sm, mword_t dev, mword_t cpu, mword_t &msi_addr, mword_t &msi_data)
inline uint8_t assign_gsi(mword_t sm, mword_t dev, mword_t cpu,
mword_t &msi_addr, mword_t &msi_data)
{
msi_addr = dev;
msi_data = cpu;

View File

@ -59,9 +59,10 @@ namespace Nova {
NOVA_LOOKUP = 0x8,
NOVA_EC_CTRL = 0x9,
NOVA_SC_CTRL = 0xa,
NOVA_SM_CTRL = 0xb,
NOVA_ASSIGN_PCI = 0xc,
NOVA_ASSIGN_GSI = 0xd,
NOVA_PT_CTRL = 0xb,
NOVA_SM_CTRL = 0xc,
NOVA_ASSIGN_PCI = 0xd,
NOVA_ASSIGN_GSI = 0xe,
};
/**

View File

@ -205,6 +205,9 @@ Platform::Platform() :
_vm_base(0x1000), _vm_size(0)
{
Hip *hip = (Hip *)__initial_sp;
/* check for right API version */
if (hip->api_version != 6)
nova_die();
/* register UTCB of main thread */
__main_thread_utcb = (Utcb *)(__initial_sp - get_page_size());