summaryrefslogtreecommitdiff
path: root/src/durango.c
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2007-04-11 13:37:02 -0600
committerJordan Crouse <jordan.crouse@amd.com>2007-04-11 13:37:52 -0600
commit8bfed84a1f972325cdf61876d7f7dfd0e8f0d4d5 (patch)
treef2fc2c5527a285a0cfa4d7a843026c22c6955482 /src/durango.c
parent2d7689990c19fd74d5fad11bcf6317a7874a6057 (diff)
Add Linux MSR suport for LX
Extend the GX MSR support to LX - this is to support the VSAless OFW, and share code.
Diffstat (limited to 'src/durango.c')
-rw-r--r--src/durango.c67
1 files changed, 4 insertions, 63 deletions
diff --git a/src/durango.c b/src/durango.c
index 527e02b..77ba16a 100644
--- a/src/durango.c
+++ b/src/durango.c
@@ -177,67 +177,8 @@ gfx_outd(unsigned short port, unsigned long data)
: "1"(msr | adr),"2"(*(high)),"3"(*(low))); \
}
-static int lnx_msr_open(void)
-{
- static int msrfd = 0;
-
- if (msrfd == 0) {
- msrfd = open("/dev/cpu/0/msr", O_RDWR);
- if (msrfd == -1)
- ErrorF("Unable to open /dev/cpu/0/msr: %d\n", errno);
- }
-
- return msrfd;
-}
-
-/* These are the preferred method (in Linux) to read the MSRs */
-
-int lnx_msr_read(unsigned long addr, unsigned long *hi, unsigned long *lo)
-{
- unsigned int data[2];
- int fd = lnx_msr_open();
- int ret;
-
- if (fd == -1)
- return - 1;
-
- ret = lseek64(fd, (off64_t) addr, SEEK_SET);
-
- if (ret == -1) {
- return -1;
- }
-
- ret = read(fd, (void *) data, sizeof(data));
-
- if (ret != 8) {
- return -1;
- }
-
- *hi = data[1];
- *lo = data[0];
-
- return 0;
-}
-
-int lnx_msr_write(unsigned long addr, unsigned long *hi, unsigned long *lo)
-{
- unsigned int data[2];
- int fd = lnx_msr_open();
-
- if (fd == -1)
- return - 1;
-
- if (lseek64(fd, (off64_t) addr, SEEK_SET) == -1)
- return -1;
-
- data[0] = *lo;
- data[1] = *hi;
-
- if (write(fd, (void *) data, 8) != 8)
- return -1;
-
- return 0;
-}
+extern int GeodeWriteMSR(unsigned long, unsigned long, unsigned long);
+extern int GeodeReadMSR(unsigned long, unsigned long *, unsigned long *);
void gfx_msr_asm_write(unsigned short reg, unsigned long addr,
unsigned long *hi, unsigned long *lo)
@@ -245,7 +186,7 @@ unsigned long *hi, unsigned long *lo)
static int msr_method = 0;
if (msr_method == 0) {
- if (!(lnx_msr_write(addr | reg, hi, lo)))
+ if (!GeodeWriteMSR(addr | reg, *lo, *hi))
return;
msr_method = 1;
@@ -261,7 +202,7 @@ unsigned long *hi, unsigned long *lo)
static int msr_method = 0;
if (msr_method == 0) {
- if (!(lnx_msr_read(addr | reg, hi, lo)))
+ if (!GeodeReadMSR(addr | reg, lo, hi))
return;
ErrorF("Unable to read the MSR - reverting to the VSA method.\n");