summaryrefslogtreecommitdiff
path: root/src/cpu/amd/model_gx2
diff options
context:
space:
mode:
authorRonald G. Minnich <rminnich@gmail.com>2006-05-25 22:08:23 +0000
committerRonald G. Minnich <rminnich@gmail.com>2006-05-25 22:08:23 +0000
commitb5fcfdbf899139d71f2bcd0ab4a9628b06abd967 (patch)
treed440570a3da1db96fc3973da45f18f3d17b96145 /src/cpu/amd/model_gx2
parentd0cffada3cbdd801d984242939b6f51ef1e090fc (diff)
downloadcoreboot-b5fcfdbf899139d71f2bcd0ab4a9628b06abd967.tar.xz
add DK8HTX support.
VSAs now required to be nrv2 compressed git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2312 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/cpu/amd/model_gx2')
-rw-r--r--src/cpu/amd/model_gx2/vsmsetup.c96
1 files changed, 94 insertions, 2 deletions
diff --git a/src/cpu/amd/model_gx2/vsmsetup.c b/src/cpu/amd/model_gx2/vsmsetup.c
index 62e17893b9..4b35ad570f 100644
--- a/src/cpu/amd/model_gx2/vsmsetup.c
+++ b/src/cpu/amd/model_gx2/vsmsetup.c
@@ -5,6 +5,97 @@
#undef __KERNEL__
#include <arch/io.h>
#include <string.h>
+
+/* what a mess this uncompress thing is. I am not at all happy about how this
+ * was done, but can't fix it yet. RGM
+ */
+#warning "Fix the uncompress once linuxbios knows how to do it"
+// This GETBIT is supposed to work on little endian
+// 32bit systems. The algorithm will definitely need
+// some fixing on other systems, but it might not be
+// a problem since the nrv2b binary behaves the same..
+
+#ifndef ENDIAN
+#define ENDIAN 0
+#endif
+#ifndef BITSIZE
+#define BITSIZE 32
+#endif
+
+#define GETBIT_8(bb, src, ilen) \
+ (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1)
+
+#define GETBIT_LE16(bb, src, ilen) \
+ (bb*=2,bb&0xffff ? (bb>>16)&1 : (ilen+=2,((bb=(src[ilen-2]+src[ilen-1]*256u)*2+1)>>16)&1))
+#define GETBIT_LE32(bb, src, ilen) \
+ (bc > 0 ? ((bb>>--bc)&1) : (bc=31,\
+ bb=*(const uint32_t *)((src)+ilen),ilen+=4,(bb>>31)&1))
+
+#if ENDIAN == 0 && BITSIZE == 8
+#define GETBIT(bb, src, ilen) GETBIT_8(bb, src, ilen)
+#endif
+#if ENDIAN == 0 && BITSIZE == 16
+#define GETBIT(bb, src, ilen) GETBIT_LE16(bb, src, ilen)
+#endif
+#if ENDIAN == 0 && BITSIZE == 32
+#define GETBIT(bb, src, ilen) GETBIT_LE32(bb, src, ilen)
+#endif
+
+static unsigned long unrv2b(uint8_t * src, uint8_t * dst)
+{
+ unsigned long ilen = 0, olen = 0, last_m_off = 1;
+ uint32_t bb = 0;
+ unsigned bc = 0;
+ const uint8_t *m_pos;
+ unsigned long file_len = *(unsigned long *) src;
+
+ printk_debug("compressed file len is supposed to be %d bytes\n", file_len);
+ // skip length
+ src += 4;
+ /* FIXME: check olen with the length stored in first 4 bytes */
+
+ for (;;) {
+ unsigned int m_off, m_len;
+ while (GETBIT(bb, src, ilen)) {
+ dst[olen++] = src[ilen++];
+ }
+
+ m_off = 1;
+ do {
+ m_off = m_off * 2 + GETBIT(bb, src, ilen);
+ } while (!GETBIT(bb, src, ilen));
+ if (m_off == 2) {
+ m_off = last_m_off;
+ } else {
+ m_off = (m_off - 3) * 256 + src[ilen++];
+ if (m_off == 0xffffffffU)
+ break;
+ last_m_off = ++m_off;
+ }
+
+ m_len = GETBIT(bb, src, ilen);
+ m_len = m_len * 2 + GETBIT(bb, src, ilen);
+ if (m_len == 0) {
+ m_len++;
+ do {
+ m_len = m_len * 2 + GETBIT(bb, src, ilen);
+ } while (!GETBIT(bb, src, ilen));
+ m_len += 2;
+ }
+ m_len += (m_off > 0xd00);
+
+ m_pos = dst + olen - m_off;
+ dst[olen++] = *m_pos++;
+ do {
+ dst[olen++] = *m_pos++;
+ } while (--m_len > 0);
+ }
+
+ printk_debug("computed len is %d, file len is %d\n", olen, file_len);
+ return olen;
+
+}
+
/* vsmsetup.c derived from vgabios.c. Derived from: */
/*------------------------------------------------------------ -*- C -*-
@@ -264,7 +355,8 @@ void do_vsmbios(void)
/* the VSA starts at the base of rom - 64 */
rom = ((unsigned long) 0) - (ROM_SIZE + 64*1024);
- buf = (unsigned char *) rom;
+ buf = (unsigned char *) 0x60000;
+ unrv2b((uint8_t *)rom, buf);
printk_debug("buf %p *buf %d buf[256k] %d\n",
buf, buf[0], buf[256*1024]);
printk_debug("buf[0x20] signature is %x:%x:%x:%x\n",
@@ -277,7 +369,7 @@ void do_vsmbios(void)
return;
}
- memcpy((void *) 0x60000, buf, size);
+ //memcpy((void *) 0x60000, buf, size);
//for (i = 0; i < 0x800000; i++)
// outb(0xaa, 0x80);