fix FTBS on 64bit Linux

On 64bit the long int type is 64 bit, but the MSR operations still
are 32bit, thus we need to use uint32_t. Also need slighty modified
versions of the inline asm code, since on 64bit machines, the 32bit
(pseudo-)registers can't be used on push/pop.

This patch is mostly for CI purpose, since there isn't any known version
of this graphics device on a 64 bit machine.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2024-06-05 13:43:42 +02:00
committed by Martin-Éric Racine
parent e006c8ca51
commit 8efe8313e4
10 changed files with 100 additions and 42 deletions

View File

@@ -31,6 +31,8 @@
#ifndef _cim_defs_h
#define _cim_defs_h
#include <stdint.h>
/*-----------------------------------------*/
/* MEMORY ACCESS MACROS */
/*-----------------------------------------*/
@@ -120,7 +122,7 @@
{ \
unsigned long msr_add = (unsigned long)(msr_reg) | \
(unsigned long)(device_add); \
unsigned long data_high, data_low; \
uint32_t data_high, data_low; \
_asm { mov ecx, msr_add } \
_asm { rdmsr } \
_asm { mov data_high, edx } \
@@ -257,7 +259,7 @@
#define MSR_READ(msr_reg, device_add, data64_ptr) \
{ \
unsigned long addr, val1, val2; \
uint32_t addr, val1, val2; \
\
addr = device_add | msr_reg; \
rdmsr (addr, val1, val2); \
@@ -273,7 +275,7 @@
#define MSR_WRITE(msr_reg, device_add, data64_ptr) \
{ \
unsigned long addr, val1, val2; \
uint32_t addr, val1, val2; \
\
val2 = ((Q_WORD *)(data64_ptr))->high; \
val1 = ((Q_WORD *)(data64_ptr))->low; \
@@ -286,7 +288,7 @@
#define MSR_READ(msr_reg, device_add, data64_ptr) \
{ \
unsigned long addr, val1, val2; \
uint32_t addr, val1, val2; \
\
addr = device_add | msr_reg; \
if (cim_rdmsr) { \
@@ -299,7 +301,7 @@
#define MSR_WRITE(msr_reg, device_add, data64_ptr) \
{ \
unsigned long addr, val1, val2; \
uint32_t addr, val1, val2; \
\
val2 = ((Q_WORD *)(data64_ptr))->high; \
val1 = ((Q_WORD *)(data64_ptr))->low; \
@@ -580,8 +582,8 @@
*-------------------------------------------*/
#define OUTD(port, data) cim_outd(port, data)
void
cim_outd(unsigned short port, unsigned long data)
static inline void
cim_outd(unsigned short port, uint32_t data)
{
_asm {
pushf mov eax, data mov dx, port out dx, eax popf}}
@@ -590,7 +592,7 @@ pushf mov eax, data mov dx, port out dx, eax popf}}
* Reads one DWORD from a single I/O address.
*-------------------------------------------*/
#define IND(port) cim_ind(port)
unsigned long
static inline uint32_t
cim_ind(unsigned short port)
{
unsigned long data;
@@ -657,9 +659,8 @@ cim_inb(unsigned short port)
*-------------------------------------------*/
#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)
static inline void
cim_outd(unsigned short port, uint32_t data)
{
__asm__ __volatile__("outl %0,%w1"::"a"(data), "Nd"(port));
}
@@ -670,11 +671,10 @@ cim_outd(unsigned short port, unsigned long data)
*-------------------------------------------*/
#define IND(port) cim_ind(port)
unsigned long cim_ind(unsigned short port);
unsigned long
static inline uint32_t
cim_ind(unsigned short port)
{
unsigned long value;
uint32_t value;
__asm__ __volatile__("inl %w1,%0":"=a"(value):"Nd"(port));
return value;
@@ -742,7 +742,7 @@ cim_outb(unsigned short port, unsigned char data)
#endif /* CIMARRON_INCLUDE_IO_MACROS */
extern void (*cim_rdmsr) (unsigned long, unsigned long *, unsigned long *);
extern void (*cim_wrmsr) (unsigned long, unsigned long, unsigned long);
extern void (*cim_rdmsr) (uint32_t, uint32_t *, uint32_t *);
extern void (*cim_wrmsr) (uint32_t, uint32_t, uint32_t);
#endif

View File

@@ -113,9 +113,8 @@ typedef struct tagGeodeLinkNode {
/*---------------------------------------------*/
typedef struct tagQ_WORD {
unsigned long high;
unsigned long low;
uint32_t high;
uint32_t low;
} Q_WORD;
/*===================================================*/

View File

@@ -31,6 +31,8 @@
#ifndef _cim_rtns_h
#define _cim_rtns_h
#include <stdint.h>
/* INCLUDE USER PARAMETER DEFINITIONS */
#include "cim_parm.h"

View File

@@ -33,6 +33,8 @@
#include "config.h"
#endif
#include <stdint.h>
/*----------------------------------------------------------------------*/
/* MODULE SETTINGS */
/* The following #defines affect which modules are included in the */
@@ -186,8 +188,8 @@ unsigned char *cim_vg_ptr = (unsigned char *) 0;
* to share the MSR code with the GX code */
#ifdef CIMARRON_MSR_HOOKS
void (*cim_rdmsr) (unsigned long, unsigned long *, unsigned long *);
void (*cim_wrmsr) (unsigned long, unsigned long, unsigned long);
void (*cim_rdmsr) (uint32_t, uint32_t*, uint32_t*);
void (*cim_wrmsr) (uint32_t, uint32_t, uint32_t);
#endif
/*----------------------------------------------------------------------*/

View File

@@ -161,8 +161,32 @@ gfx_outd(unsigned short port, unsigned long data)
: "=a" (*(low)), "=d" (*(high)) \
: "c" (msr | adr))
#if __WORDSIZE == 64
#define vsa_msr_write(msr,adr,high,low) \
{ int d0, d1, d2, d3, d4; \
{ int32_t d0, d1, d2, d3, d4; \
__asm__ __volatile__( \
" push %%rbx\n" \
" mov $0x0AC1C, %%edx\n" \
" mov $0xFC530007, %%eax\n" \
" out %%eax,%%dx\n" \
" add $2,%%dl\n" \
" mov %6, %%ebx\n" \
" mov %7, %0\n" \
" mov %5, %3\n" \
" xor %2, %2\n" \
" xor %1, %1\n" \
" out %%ax, %%dx\n" \
" pop %%rbx\n" \
: "=a"(d0),"=&D"(d1),"=&S"(d2), \
"=c"(d3),"=d"(d4) \
: "1"(msr | adr),"2"(*(high)),"3"(*(low))); \
}
#else
#define vsa_msr_write(msr,adr,high,low) \
{ int32_t d0, d1, d2, d3, d4; \
__asm__ __volatile__( \
" push %%ebx\n" \
" mov $0x0AC1C, %%edx\n" \
@@ -181,12 +205,14 @@ gfx_outd(unsigned short port, unsigned long data)
: "1"(msr | adr),"2"(*(high)),"3"(*(low))); \
}
extern int GeodeWriteMSR(unsigned long, unsigned long, unsigned long);
extern int GeodeReadMSR(unsigned long, unsigned long *, unsigned long *);
#endif
extern int GeodeWriteMSR(uint32_t, uint32_t, uint32_t);
extern int GeodeReadMSR(uint32_t, uint32_t *, uint32_t *);
void
gfx_msr_asm_write(unsigned short reg, unsigned long addr,
unsigned long *hi, unsigned long *lo)
gfx_msr_asm_write(unsigned short reg, uint32_t addr,
uint32_t *hi, uint32_t *lo)
{
static int msr_method = 0;
@@ -202,8 +228,8 @@ gfx_msr_asm_write(unsigned short reg, unsigned long addr,
}
void
gfx_msr_asm_read(unsigned short reg, unsigned long addr,
unsigned long *hi, unsigned long *lo)
gfx_msr_asm_read(unsigned short reg, uint32_t addr,
uint32_t *hi, uint32_t *lo)
{
static int msr_method = 0;

View File

@@ -99,7 +99,6 @@ extern unsigned char cim_inb(unsigned short port);
extern void cim_outb(unsigned short port, unsigned char data);
extern unsigned short cim_inw(unsigned short port);
extern void cim_outw(unsigned short port, unsigned short data);
extern unsigned long cim_ind(unsigned short port);
extern void cim_outd(unsigned short port, unsigned long data);
#include "cim_rtns.h"
@@ -381,8 +380,8 @@ int GeodeCalculatePitchBytes(unsigned int width, unsigned int bpp);
void GXSetupChipsetFPtr(ScrnInfoPtr pScrn);
/* geode_msr.c */
int GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi);
int GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi);
int GeodeReadMSR(uint32_t addr, uint32_t *lo, uint32_t *hi);
int GeodeWriteMSR(uint32_t addr, uint32_t lo, uint32_t hi);
/* gx_cursor.c */
Bool GXHWCursorInit(ScreenPtr pScrn);

View File

@@ -76,7 +76,7 @@ _msr_open(void)
}
int
GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
GeodeReadMSR(uint32_t addr, uint32_t *lo, uint32_t *hi)
{
#ifdef __OpenBSD__
struct amdmsr_req req;
@@ -127,7 +127,7 @@ GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
}
int
GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
GeodeWriteMSR(uint32_t addr, uint32_t lo, uint32_t hi)
{
#ifdef __OpenBSD__
struct amdmsr_req req;

View File

@@ -31,6 +31,8 @@
* their own versions of these macros, which typically call a subroutine.
* */
#include <stdint.h>
/* ACCESS TO THE CPU REGISTERS */
#define WRITE_REG8(offset, value) \
@@ -111,10 +113,10 @@
/* ACCESS TO MSRS */
void gfx_msr_asm_write(unsigned short msrReg, unsigned long msrAddr,
unsigned long *ptrHigh, unsigned long *ptrLow);
void gfx_msr_asm_read(unsigned short msrReg, unsigned long msrAddr,
unsigned long *ptrHigh, unsigned long *ptrLow);
void gfx_msr_asm_write(unsigned short msrReg, uint32_t msrAddr,
uint32_t *ptrHigh, uint32_t *ptrLow);
void gfx_msr_asm_read(unsigned short msrReg, uint32_t msrAddr,
uint32_t *ptrHigh, uint32_t *ptrLow);
#define MSR_READ( MBD_MSR_CAP, address, valueHigh_ptr, valueLow_ptr ) \
gfx_msr_asm_read( ((unsigned short)(MBD_MSR_CAP)), address, \

View File

@@ -31,6 +31,8 @@
#ifndef _gfx_type_h
#define _gfx_type_h
#include <stdint.h>
/* MSR DEFINITIONS */
typedef enum DevStatus
@@ -44,8 +46,8 @@ typedef struct msr {
} MSR;
typedef struct mValue {
unsigned long high;
unsigned long low;
uint32_t high;
uint32_t low;
} Q_WORD;
typedef struct mbusNode {

View File

@@ -99,8 +99,32 @@ LXSaveScreen(ScreenPtr pScrn, int mode)
: "=a" (lo), "=d" (hi) \
: "c" (adr))
#if __WORDSIZE == 64
#define LX_MSR_WRITE(adr,low,high) \
{ int d0, d1, d2, d3, d4; \
{ int32_t d0, d1, d2, d3, d4; \
__asm__ __volatile__( \
" push %%rbx\n" \
" mov $0x0AC1C, %%edx\n" \
" mov $0xFC530007, %%eax\n" \
" out %%eax,%%dx\n" \
" add $2,%%dl\n" \
" mov %6, %%ebx\n" \
" mov %7, %0\n" \
" mov %5, %3\n" \
" xor %2, %2\n" \
" xor %1, %1\n" \
" out %%ax, %%dx\n" \
" pop %%rbx\n" \
: "=a"(d0),"=&D"(d1),"=&S"(d2), \
"=c"(d3),"=d"(d4) \
: "1"(adr),"2"(high),"3"(low)); \
}
#else
#define LX_MSR_WRITE(adr,low,high) \
{ int32_t d0, d1, d2, d3, d4; \
__asm__ __volatile__( \
" push %%ebx\n" \
" mov $0x0AC1C, %%edx\n" \
@@ -119,8 +143,10 @@ LXSaveScreen(ScreenPtr pScrn, int mode)
: "1"(adr),"2"(high),"3"(low)); \
}
#endif
static void
LXReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
LXReadMSR(uint32_t addr, uint32_t *lo, uint32_t *hi)
{
if (GeodeReadMSR(addr, lo, hi) == -1) {
unsigned int l, h;
@@ -132,7 +158,7 @@ LXReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
}
static void
LXWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
LXWriteMSR(uint32_t addr, uint32_t lo, uint32_t hi)
{
if (GeodeWriteMSR(addr, lo, hi) == -1)
LX_MSR_WRITE(addr, lo, hi);