mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-16 15:29:57 +00:00
base: refactor io_port session implementation
Split port API implementation into separate io_port_session_support.cc file, so that base-sel4 may implement this part alternatively. Issue #2044
This commit is contained in:
parent
027e89f91a
commit
464181b01d
@ -4,5 +4,6 @@ REQUIRES += x86
|
||||
SRC_CC += platform_x86.cc
|
||||
|
||||
vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86
|
||||
|
||||
|
@ -16,6 +16,7 @@ SRC_CC += stack_area.cc \
|
||||
io_mem_session_component.cc \
|
||||
io_mem_session_support.cc \
|
||||
io_port_session_component.cc \
|
||||
io_port_session_support.cc \
|
||||
irq_session_component.cc \
|
||||
main.cc \
|
||||
multiboot_info.cc \
|
||||
|
@ -1,10 +1,12 @@
|
||||
LD_TEXT_ADDR = 0x500000
|
||||
REQUIRES += x86
|
||||
SRC_CC += io_port_session_component.cc \
|
||||
io_port_session_support.cc \
|
||||
spec/x86/ipc_pager.cc \
|
||||
spec/x86/platform.cc
|
||||
|
||||
vpath io_port_session_component.cc $(BASE_DIR)/src/core/spec/x86
|
||||
vpath io_port_session_support.cc $(BASE_DIR)/src/core/spec/x86
|
||||
vpath platform_services.cc $(BASE_DIR)/src/core/spec/x86
|
||||
|
||||
include $(REP_DIR)/src/core/target.inc
|
||||
|
@ -18,6 +18,7 @@ SRC_CC += spec/x86/cpu.cc
|
||||
SRC_CC += spec/x86/fpu.cc
|
||||
SRC_CC += spec/x86/bios_data_area.cc
|
||||
SRC_CC += spec/x86/io_port_session_component.cc
|
||||
SRC_CC += spec/x86/io_port_session_support.cc
|
||||
|
||||
# include less specific configuration
|
||||
include $(BASE_DIR)/../base-hw/lib/mk/core.inc
|
||||
|
@ -18,6 +18,7 @@ SRC_CC = stack_area.cc \
|
||||
io_mem_session_component.cc \
|
||||
io_mem_session_support.cc \
|
||||
io_port_session_component.cc \
|
||||
io_port_session_support.cc \
|
||||
ipc_pager.cc \
|
||||
irq_session_component.cc \
|
||||
main.cc \
|
||||
@ -59,6 +60,7 @@ vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR)
|
||||
vpath region_map_component.cc $(GEN_CORE_DIR)
|
||||
vpath trace_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath io_mem_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath io_mem_session_support.cc $(GEN_CORE_DIR)
|
||||
vpath dataspace_component.cc $(GEN_CORE_DIR)
|
||||
|
@ -3,9 +3,11 @@ include $(REP_DIR)/src/core/target.inc
|
||||
REQUIRES += x86
|
||||
|
||||
SRC_CC += io_port_session_component.cc \
|
||||
io_port_session_support.cc \
|
||||
platform_thread_x86.cc
|
||||
|
||||
vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath platform_thread_x86.cc $(GEN_CORE_DIR)/spec/x86
|
||||
|
||||
|
@ -2,8 +2,10 @@ include $(REP_DIR)/src/core/target.inc
|
||||
|
||||
REQUIRES += x86
|
||||
SRC_CC += io_port_session_component.cc \
|
||||
io_port_session_support.cc \
|
||||
platform_x86.cc
|
||||
|
||||
vpath io_port_session_component.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath io_port_session_support.cc $(GEN_CORE_DIR)/spec/x86
|
||||
vpath platform_services.cc $(GEN_CORE_DIR)/spec/x86
|
||||
|
||||
|
@ -25,70 +25,6 @@ using namespace Genode;
|
||||
static const bool verbose = false;
|
||||
|
||||
|
||||
/**************
|
||||
** Port API **
|
||||
**************/
|
||||
|
||||
unsigned char Io_port_session_component::inb(unsigned short address)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned char))) return 0;
|
||||
|
||||
unsigned char v;
|
||||
asm volatile ("inb %w1, %b0" : "=a" (v) : "Nd" (address));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
unsigned short Io_port_session_component::inw(unsigned short address)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned short))) return 0;
|
||||
|
||||
unsigned short v;
|
||||
asm volatile ("inw %w1, %w0" : "=a" (v) : "Nd" (address));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
unsigned Io_port_session_component::inl(unsigned short address)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned))) return 0;
|
||||
|
||||
unsigned v;
|
||||
asm volatile ("inl %w1, %0" : "=a" (v) : "Nd" (address));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
void Io_port_session_component::outb(unsigned short address, unsigned char value)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned char))) return;
|
||||
|
||||
asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (address));
|
||||
}
|
||||
|
||||
|
||||
void Io_port_session_component::outw(unsigned short address, unsigned short value)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned short))) return;
|
||||
|
||||
asm volatile ("outw %w0, %w1" : : "a" (value), "Nd" (address));
|
||||
}
|
||||
|
||||
|
||||
void Io_port_session_component::outl(unsigned short address, unsigned value)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned))) return;
|
||||
|
||||
asm volatile ("outl %0, %w1" : : "a" (value), "Nd" (address));
|
||||
}
|
||||
|
||||
|
||||
/******************************
|
||||
** Constructor / destructor **
|
||||
******************************/
|
||||
|
81
repos/base/src/core/spec/x86/io_port_session_support.cc
Normal file
81
repos/base/src/core/spec/x86/io_port_session_support.cc
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* \brief Core implementation of the IO_PORT session interface
|
||||
* \author Christian Helmuth
|
||||
* \date 2007-04-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-2013 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* core includes */
|
||||
#include <io_port_session_component.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/**************
|
||||
** Port API **
|
||||
**************/
|
||||
|
||||
unsigned char Io_port_session_component::inb(unsigned short address)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned char))) return 0;
|
||||
|
||||
unsigned char v;
|
||||
asm volatile ("inb %w1, %b0" : "=a" (v) : "Nd" (address));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
unsigned short Io_port_session_component::inw(unsigned short address)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned short))) return 0;
|
||||
|
||||
unsigned short v;
|
||||
asm volatile ("inw %w1, %w0" : "=a" (v) : "Nd" (address));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
unsigned Io_port_session_component::inl(unsigned short address)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned))) return 0;
|
||||
|
||||
unsigned v;
|
||||
asm volatile ("inl %w1, %0" : "=a" (v) : "Nd" (address));
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
void Io_port_session_component::outb(unsigned short address, unsigned char value)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned char))) return;
|
||||
|
||||
asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (address));
|
||||
}
|
||||
|
||||
|
||||
void Io_port_session_component::outw(unsigned short address, unsigned short value)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned short))) return;
|
||||
|
||||
asm volatile ("outw %w0, %w1" : : "a" (value), "Nd" (address));
|
||||
}
|
||||
|
||||
|
||||
void Io_port_session_component::outl(unsigned short address, unsigned value)
|
||||
{
|
||||
/* check boundaries */
|
||||
if (!_in_bounds(address, sizeof(unsigned))) return;
|
||||
|
||||
asm volatile ("outl %0, %w1" : : "a" (value), "Nd" (address));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user