📄 cim_defs.h
字号:
/*-----------------------------------------------------------------
* WRITE_HOST_SOURCE_STRING8
* Write a series of bytes to the host source register
*-----------------------------------------------------------------*/
#define WRITE_HOST_SOURCE_STRING8(dataptr, dataoffset, byte_count) \
{ \
unsigned long temp1 = (unsigned long)dataptr + (dataoffset); \
unsigned long temp2 = 0; \
unsigned long shift = 0; \
unsigned long counter; \
if (byte_count) \
{ \
for (counter = 0; counter < byte_count; counter++) \
{ \
temp2 |= ((unsigned long)(*((unsigned char *)(temp1 + counter)))) << shift; \
shift += 8; \
} \
WRITE_GP32 (GP3_HST_SRC, temp2); \
} \
}
/*-----------------------------------------*/
/* CUSTOM STRING MACROS */
/*-----------------------------------------*/
#ifndef CIMARRON_EXCLUDE_CUSTOM_MACROS
#define WRITE_CUSTOM_COMMAND_STRING32 WRITE_COMMAND_STRING32
#define WRITE_CUSTOM_COMMAND_STRING8 WRITE_COMMAND_STRING8
#endif
/*-----------------------------------------*/
/* IO ACCESS MACROS */
/*-----------------------------------------*/
#ifdef CIMARRON_INCLUDE_IO_MACROS
#if CIMARRON_IO_DIRECT_ACCESS
/*-------------------------------------------
* OUTD
* Writes one DWORD to a single I/O address.
*-------------------------------------------*/
#define OUTD(port, data) cim_outd(port, data)
void cim_outd (unsigned short port, unsigned long data)
{
_asm {
pushf
mov eax, data
mov dx, port
out dx, eax
popf
}
}
/*-------------------------------------------
* IND
* Reads one DWORD from a single I/O address.
*-------------------------------------------*/
#define IND(port) cim_ind(port)
unsigned long cim_ind (unsigned short port)
{
unsigned long data;
_asm {
pushf
mov dx, port
in eax, dx
mov data, eax
popf
}
return data;
}
/*-------------------------------------------
* OUTW
* Writes one WORD to a single I/O address.
*-------------------------------------------*/
#define OUTW(port, data) cim_outw(port, data)
void cim_outw (unsigned short port, unsigned short data)
{
_asm {
pushf
mov ax, data
mov dx, port
out dx, ax
popf
}
}
/*-------------------------------------------
* INW
* Reads one WORD from a single I/O address.
*-------------------------------------------*/
#define INW(port) cim_inw(port)
unsigned short cim_inw (unsigned short port)
{
unsigned short data;
_asm {
pushf
mov dx, port
in ax, dx
mov data, ax
popf
}
return data;
}
/*-------------------------------------------
* OUTB
* Writes one BYTE to a single I/O address.
*-------------------------------------------*/
#define OUTB(port, data) cim_outb(port, data)
void cim_outb (unsigned short port, unsigned char data)
{
_asm {
pushf
mov al, data
mov dx, port
out dx, al
popf
}
}
/*-------------------------------------------
* INB
* Reads one BYTE from a single I/O address.
*-------------------------------------------*/
#define INB(port) cim_inb(port)
unsigned char cim_inb (unsigned short port)
{
unsigned char data;
_asm {
pushf
mov dx, port
in al, dx
mov data, al
popf
}
return data;
}
#elif CIMARRON_IO_ABSTRACTED_ASM
/*-------------------------------------------
* OUTD
* Writes one DWORD to a single I/O address.
*-------------------------------------------*/
#define OUTD(port, data) cim_outd(port, data)
void cim_outd (unsigned short port, unsigned long data);
void cim_outd (unsigned short port, unsigned long data)
{
__asm__ __volatile__ ("outl %0,%w1" : : "a" (data), "Nd" (port));
}
/*-------------------------------------------
* IND
* Reads one DWORD from a single I/O address.
*-------------------------------------------*/
#define IND(port) cim_ind(port)
unsigned long cim_ind (unsigned short port);
unsigned long cim_ind (unsigned short port)
{
unsigned long value;
__asm__ __volatile__ ("inl %w1,%0" : "=a" (value) : "Nd" (port) );
return value;
}
/*-------------------------------------------
* OUTW
* Writes one WORD to a single I/O address.
*-------------------------------------------*/
#define OUTW(port, data) cim_outw(port, data)
void cim_outw (unsigned short port, unsigned short data);
void cim_outw (unsigned short port, unsigned short data)
{
__asm__ volatile ("out %0,%1" : : "a" (data),"d" (port));
}
/*-------------------------------------------
* INW
* Reads one WORD from a single I/O address.
*-------------------------------------------*/
#define INW(port) cim_inw(port)
unsigned short cim_inw (unsigned short port);
unsigned short cim_inw (unsigned short port)
{
unsigned short value;
__asm__ volatile ("in %1,%0" : "=a" (value) : "d" (port));
return value;
}
/*-------------------------------------------
* INB
* Reads one BYTE from a single I/O address.
*-------------------------------------------*/
#define INB(port) cim_inb(port)
unsigned char cim_inb(unsigned short port);
unsigned char cim_inb(unsigned short port)
{
unsigned char value;
__asm__ volatile ("inb %1,%0":"=a" (value):"d"(port));
return value;
}
/*-------------------------------------------
* OUTB
* Writes one BYTE to a single I/O address.
*-------------------------------------------*/
#define OUTB(port) cim_outb(port)
void cim_outb(unsigned short port, unsigned char data);
void cim_outb(unsigned short port, unsigned char data)
{
__asm__ volatile ("outb %0,%1"::"a" (data), "d"(port));
}
#endif
#endif /* CIMARRON_INCLUDE_IO_MACROS */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -