Add support for the ASUS M2V-MX SE board and enable the password for
MSR on AMD arch.
You will need to use the XMM stack version because I did not want to change
the romcc.
Signed-off-by: Rudolf Marek <r.marek@assembler.cz>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
===================================================================
@@ -42,26 +42,10 @@
/* PnP / SuperIO access functions */
-static inline void pnp_enter_ext_func_mode(u16 port)
-{
- outb(0x87, port);
- outb(0x87, port);
-}
-
-static inline void pnp_enter_ext_func_mode_alt(u16 port)
-{
- outb(0x55, port);
-}
-
-static void pnp_exit_ext_func_mode(u16 port)
-{
- outb(0xaa, port);
-}
-
static inline void pnp_write_register(u16 port, u8 reg, u8 value)
{
outb(reg, port);
- outb(value, port +1);
+ outb(value, port + 1);
}
static inline void pnp_set_logical_device(u8 port, u8 device)
@@ -85,5 +69,35 @@
pnp_write_register(port, 0x70, irq);
}
+static inline void pnp_enter_ext_func_mode(u16 port)
+{
+ outb(0x87, port);
+ outb(0x87, port);
+}
+
+static inline void pnp_enter_ext_func_mode_alt(u16 port)
+{
+ outb(0x55, port);
+}
+
+static inline void pnp_enter_ext_func_mode_ite(u16 port)
+{
+ outb(0x87, port);
+ outb(0x01, port);
+ outb(0x55, port);
+ outb((port == 0x2e) ? 0x55 : 0xaa, port);
+}
+
+static void pnp_exit_ext_func_mode(u16 port)
+{
+ outb(0xaa, port);
+}
+
+static void pnp_exit_ext_func_mode_ite(u16 port)
+{
+ pnp_set_logical_device(port, 0);
+ pnp_write_register(port, 0x02, 0x02);
+}
+
#include MAINBOARD
===================================================================
@@ -20,5 +20,7 @@
#define ECHO_MODE 1
#define SIO_SPEED 115200
#define SIO_PORT 0x3f8
+#define VIA_ROMSTRAP 1
//#define MAINBOARD "kontron_986lcd-m.c"
//#define MAINBOARD "intel_d945gclf.c"
+#define MAINBOARD "asus_m2v-mx_se.c"
===================================================================
@@ -0,0 +1,56 @@
+/*
+ * SerialICE
+ *
+ * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2009 Rudolf Marek <r.marek@assembler.cz>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define SUPERIO_CONFIG_PORT 0x2e
+
+static void superio_init(void)
+{
+ pnp_enter_ext_func_mode_ite(SUPERIO_CONFIG_PORT);
+
+ /* Disable the watchdog. */
+ pnp_set_logical_device(SUPERIO_CONFIG_PORT, 7);
+ pnp_write_register(SUPERIO_CONFIG_PORT, 0x72, 0x00);
+
+ /* Enable the serial port. */
+ pnp_set_logical_device(SUPERIO_CONFIG_PORT, 1); /* COM1 */
+ pnp_set_enable(SUPERIO_CONFIG_PORT, 0);
+ pnp_set_iobase0(SUPERIO_CONFIG_PORT, 0x3f8);
+ pnp_set_irq0(SUPERIO_CONFIG_PORT, 4);
+ pnp_set_enable(SUPERIO_CONFIG_PORT, 1);
+
+ pnp_exit_ext_func_mode_ite(SUPERIO_CONFIG_PORT);
+}
+
+static void chipset_init(void)
+{
+ superio_init();
+
+ __asm__ __volatile__("\
+ jmp skip\n\
+ .align 128\n\
+ .global via_romstrap\n\
+ via_romstrap:\n\
+ .long 0x504400AA, 0x61970FC2 //;200M\n\
+ .long 0x504400AA, 0x61970FC2 //;400M\n\
+ .long 0x504400AA, 0x61970FC2 //;600M\n\
+ .long 0x504400AA, 0x61970FC2 //;800M\n\
+ .long 0x504400AA, 0x61970FC2 //;1000M\n\
+ skip:\n");
+}
===================================================================
@@ -130,7 +130,7 @@
__asm__ __volatile__ (
"rdmsr"
: "=a" (result.lo), "=d" (result.hi)
- : "c" (index)
+ : "c" (index), "D" (0x9c5a203a)
);
return result;
}
@@ -140,7 +140,7 @@
__asm__ __volatile__ (
"wrmsr"
: /* No outputs */
- : "c" (index), "a" (msr.lo), "d" (msr.hi)
+ : "c" (index), "a" (msr.lo), "d" (msr.hi), "D" (0x9c5a203a)
);
}
===================================================================
@@ -35,13 +35,19 @@
*(.rodata.*);
}
- . = 0xffffff80;
+ . = 0xffffff40;
.messages . : {
*(.messages)
. = 111;
BYTE(0x00);
}
+ . = 0xffffffd0;
+ .romstrap . : {
+ *(.romstrap)
+ }
+
+
. = 0xfffffff0;
.reset . : {
*(.reset)
===================================================================
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "config.h"
+
.code32
_c_main:
@@ -108,3 +110,12 @@
.code16
jmp _start
+ /* VIA romstrap */
+ .section ".romstrap", "a", @progbits
+
+#ifdef VIA_ROMSTRAP
+/* The pointer to above table should be at 0xffffd,
+ * the table itself MUST be aligned to 128B it seems!
+ */
+ .long via_romstrap
+#endif
===================================================================
@@ -162,6 +162,30 @@
//bswap and xchg also not affect flags.
//dr2 must be initially 0x7f
+ fprintf(w,"docall:\nmovl %%eax,%%dr0 #NOSTACK\n\
+ movl %%dr2,%%eax #NOSTACK\n\
+ movzbl %%al,%%eax #NOSTACK\n\
+ leal -4(%%eax),%%eax #NOSTACK\n\
+ movb %%al,%%ah #NOSTACK\n\
+ movl %%eax,%%dr2 #NOSTACK\n\
+ leal 8(%%esp),%%eax #NOSTACK\n\
+ jmp setxmml\n\
+ dopop:\n movl %%eax,%%dr0 #NOSTACK\n\
+ movl %%dr2,%%eax #NOSTACK\n\
+ movzbl %%al,%%eax #NOSTACK\n\
+ movb %%al,%%ah #NOSTACK\n\
+ leal 4(%%eax),%%eax #NOSTACK\n\
+ movl %%eax,%%dr2 #NOSTACK\n\
+ jmp getxmml\n\
+ dopush:\n movl %%eax,%%dr3 #NOSTACK\n\
+ movl %%dr2,%%eax #NOSTACK\n\
+ movzbl %%al,%%eax #NOSTACK\n\
+ leal -4(%%eax),%%eax #NOSTACK\n\
+ movb %%al,%%ah #NOSTACK\n\
+ movl %%eax,%%dr2 #NOSTACK\n\
+ movl %%dr3,%%eax\n\
+ jmp setxmml\n");
+
//16 bytes table xmm/12 mmx, pextrw and pinsrw consumes 5 bytes, and jmp *esp consumes 2, nop consumes 1 byte, movb consumes 2 bytes
//Align of each,must 16 bytes, for use 1,2,4,8 escalar multiple.
fprintf(w,"setxmm:\n");
@@ -550,6 +574,23 @@
fprintf(w,"#%s #ORIG\n", buf);
+ /* handle pushl xxx(%esp) */
+ if (regexp("^pushl\\s+(\\d*)\\(\\%esp\\)",buf,len,find)) {
+ fprintf(w,"movl %%eax,%%dr0 #NOSTACK\n");
+ fprintf(w,"movl %%dr2,%%eax #NOSTACK\n");
+ fprintf(w,"movzbl %%al,%%eax #NOSTACK\n");
+ fprintf(w,"movb %%al,%%ah #NOSTACK\n");
+ fprintf(w,"leal %d(%%eax),%%eax #NOSTACK\n",256*atoi(find[1]));
+ fprintf(w,"movl %%eax,%%dr2 #NOSTACK\n");
+ fprintf(w,"movl %%dr0,%%eax #NOSTACK\n");
+ fprintf(w,"movl $.+10,%%esp\n");
+ fprintf(w,"jmp getxmml\n");
+ fprintf(w,"movl $.+10,%%esp\n");
+ fprintf(w,"jmp dopush\n");
+ fprintf(w,"movl %%dr0,%%eax #NOSTACK\n");
+ continue;
+ }
+
/* leal is tricky */
if (regexp("^leal\\s+(\\d*)\\(\\%esp\\)\\s*,\\s*(.*)$",buf,len,find))
{
@@ -675,27 +716,17 @@
if (regexp("^pushl\\s+(.*)$",buf,len,find))
{
fprintf(w,"movl %%eax,%%dr0 #NOSTACK\n");
- fprintf(w,"movl %%dr2,%%eax #NOSTACK\n");
- fprintf(w,"movzbl %%al,%%eax #NOSTACK\n");
- fprintf(w,"leal -4(%%eax),%%eax #NOSTACK\n");
- fprintf(w,"movb %%al,%%ah #NOSTACK\n");
- fprintf(w,"movl %%eax,%%dr2 #NOSTACK\n");
fprintf(w,"movl %s,%%eax\n",find[1]);
fprintf(w,"movl $.+10,%%esp\n");
- fprintf(w,"jmp setxmml\n");
+ fprintf(w,"jmp dopush\n");
fprintf(w,"movl %%dr0,%%eax #NOSTACK\n");
continue;
}
if (regexp("^popl\\s+(.*)$",buf,len,find))
{
- fprintf(w,"movl %%eax,%%dr0 #NOSTACK\n");
- fprintf(w,"movl %%dr2,%%eax #NOSTACK\n");
- fprintf(w,"movzbl %%al,%%eax #NOSTACK\n");
- fprintf(w,"movb %%al,%%ah #NOSTACK\n");
- fprintf(w,"leal 4(%%eax),%%eax #NOSTACK\n");
- fprintf(w,"movl %%eax,%%dr2 #NOSTACK\n");
+
fprintf(w,"movl $.+10,%%esp\n");
- fprintf(w,"jmp getxmml\n");
+ fprintf(w,"jmp dopop\n");
fprintf(w,"movl %%eax,%s\n",find[1]);
if (strcmp(find[1],"%eax"))
fprintf(w,"movl %%dr0,%%eax #NOSTACK\n");
@@ -703,15 +734,8 @@
}
if (regexp("^call\\s+(.*)$",buf,len,find))
{
- fprintf(w,"movl %%eax,%%dr0 #NOSTACK\n");
- fprintf(w,"movl %%dr2,%%eax #NOSTACK\n");
- fprintf(w,"movzbl %%al,%%eax #NOSTACK\n");
- fprintf(w,"leal -4(%%eax),%%eax #NOSTACK\n");
- fprintf(w,"movb %%al,%%ah #NOSTACK\n");
- fprintf(w,"movl %%eax,%%dr2 #NOSTACK\n");
- fprintf(w,"movl $.+23,%%eax #NOSTACK\n");
fprintf(w,"movl $.+10,%%esp\n");
- fprintf(w,"jmp setxmml\n");
+ fprintf(w,"jmp docall\n");
fprintf(w,"movl %%dr0,%%eax #NOSTACK\n");
fprintf(w,".byte 0xe9\n.long %s-4-. #NOSTACK\n",find[1]);//jmp, not works with .global??? gcc???
continue;
===================================================================
@@ -26,8 +26,8 @@
ifneq ($(shell which i386-elf-gcc),)
CROSS=i386-elf-
endif
-AS=$(CROSS)as
-CC=$(CROSS)gcc
+AS=$(CROSS)as --32
+CC=$(CROSS)gcc -m32
OBJCOPY=$(CROSS)objcopy
NM=$(CROSS)nm
On Fri, Oct 09, 2009 at 10:30:24PM +0200, Rudolf Marek wrote: > Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Here's an improved/simplified version of your patch. I factored out all common superio code into chipset.c (had to reorder functions a bit, too). I didn't touch or test any of the non-superio stuff in the patch. Uwe.