-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hello,
I made some fix for xmmstack.c found in SerialICE.
leal (%esp), %ecx
Its simple:
- --- old.c 2009-05-14 15:43:45.000000000 +0200 +++ xmmstack.c 2009-10-02 00:19:52.755673296 +0200 @@ -547,9 +547,23 @@ getxmml:\n\ continue; } #endif + + fprintf(w,"#%s #ORIG\n", buf); + + /* leal is tricky */ + if (regexp("^leal\s+(\d*)\(\%esp\)\s*,\s*(.*)$",buf,len,find)) + { + fprintf(w,"movl %%dr2,%%esp #NOSTACK\n"); + fprintf(w,"%s\n",buf); + fprintf(w,"movl %%esp,%%dr2 #NOSTACK\n"); + continue; + } +
It makes things compile. Maybe there are other issues don't know.
Rudolf
On Fri, 02 Oct 2009 00:36:06 +0200, Rudolf Marek r.marek@assembler.cz wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hello,
I made some fix for xmmstack.c found in SerialICE.
leal (%esp), %ecx
Its simple:
- --- old.c 2009-05-14 15:43:45.000000000 +0200
+++ xmmstack.c 2009-10-02 00:19:52.755673296 +0200 @@ -547,9 +547,23 @@ getxmml:\n\ continue; } #endif
- fprintf(w,"#%s #ORIG\n", buf);
- /* leal is tricky */
if
(regexp("^leal\s+(\d*)\(\%esp\)\s*,\s*(.*)$",buf,len,find))
{
fprintf(w,"movl %%dr2,%%esp #NOSTACK\n");
fprintf(w,"%s\n",buf);
fprintf(w,"movl %%esp,%%dr2 #NOSTACK\n");
continue;
}
It makes things compile. Maybe there are other issues don't know.
Cool, thanks Rudolf. Stefan, do you plan a svn repo for SerialICE?
On Fri, Oct 02, 2009 at 12:36:06AM +0200, Rudolf Marek wrote:
Hello,
I made some fix for xmmstack.c found in SerialICE.
leal (%esp), %ecx
I was looking at xmmstack - it's a neat hack! However, as near as I can tell, it only fixes up %esp references. If gcc were to copy %esp to %ecx and then issue a memory access to %ecx then xmmstack isn't going to fixup that memory access. So, unless I missed something, the leal change is likely to just mask the problem.
-Kevin
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
leal (%esp), %ecx
Yes good note!
Well it was because of stack realign. The GCC generates some odd code for stack realign in the main. At the end of function it put stack back. And the stack realign will be removed with gcc option.
Thanks,
Rudolf
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi all
During the weekend train trips I managed to get serialICE 1.2 working with the XMM stack (in qemu).
There were some gotchas:
#1 missing SSE enable #2 missing stack setup ;) (taken from RemoteBIOS) #3 wrong LD script, the rodata section relocation did not work #4 the stack realign feature #5 missing -O2 ;)
I'm attaching the modified files right now. Not so big deal hopefully.
Please can someone fix the ld script in proper way? I borrowed this change from the RemoteBIOS.
Btw now it has just 17KB and not nearly 60KB or so with romcc ;)
With that we have 128B of stack.
Thanks,
Rudolf
## ## SerialICE ## ## Copyright (C) 2009 coresystems GmbH ## ## 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 ##
VERSION="1.2"
HOSTCC=gcc HOSTCFLAGS= -O2 -Wall PCREFLAGS=-I/opt/local/include -L/opt/local/lib -lpcre
CROSS= AS=$(CROSS)as CC=$(CROSS)gcc OBJCOPY=$(CROSS)objcopy NM=$(CROSS)nm
LDFLAGS=-Wa,--divide -nostdlib -nostartfiles -static -T serialice.ld
SOURCES = serialice.c chipset.c config.h serial.c types.h mainboard/*.c
all: serialice.rom
serialice.rom: serialice.elf $(OBJCOPY) -O binary $< $@
serialice.elf: serialice.o start.o serialice.ld $(CC) $(LDFLAGS) -o $@ serialice.o start.o $(NM) $@ | sort -u > serialice.map
serialice.S: $(SOURCES) ./romcc ./romcc -mcpu=i386 -I. -Imainboard -DVERSION="$(VERSION)" -o $@ $<
romcc: util/romcc.c $(HOSTCC) $(HOSTCFLAGS) -o $@ $^
# #####################################################################
serialice-gcc.rom: serialice-gcc.elf $(OBJCOPY) -O binary $< $@
serialice-gcc.elf: serialice-gcc.o start.o serialice.ld $(CC) $(LDFLAGS) -o $@ serialice-gcc.o start.o $(NM) $@ | sort -u > serialice-gcc.map
serialice-pre.s: $(SOURCES) ./xmmstack $(CC) -O2 -march=i486 -mno-stackrealign -mpreferred-stack-boundary=2 -I. -Imainboard -fomit-frame-pointer -fno-stack-protector -DVERSION="$(VERSION)" -S $< -o serialice-pre.s
serialice-gcc.S: serialice-pre.s ./xmmstack -xmm serialice-pre.s mv serialice-pre.sn.s serialice-gcc.S # cp serialice-pre.s serialice-gcc.S
xmmstack: util/xmmstack.c $(HOSTCC) $(HOSTCFLAGS) $(PCREFLAGS) -o $@ $^
# #####################################################################
clean: rm -f romcc serialice.S *.o *.o.s rm -f serialice.elf serialice.rom serialice.map rm -f serialice-gcc.S serialice-pre.s xmmstack serialice-gcc.map
dongle: serialice.rom dongle.py -v -c /dev/cu.usbserial-00* serialice.rom 4032K
%.o: %.S $(CPP) -DVERSION="$(VERSION)" -o $@.s $^ $(AS) -o $@ $@.s
/* * SerialICE * * Copyright (C) 2009 coresystems GmbH * * 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 */
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH(i386)
_ROMSIZE = (1024 * 64); _ROMBASE = 0x100000000 - (_ROMSIZE);
SECTIONS { . = _ROMBASE;
.rombase : { *(.rodata.*); *(.rodata); *(.rom.text); *(.rom.data); *(.text); *(.data); *(.bss); } /*
.text . : { . = ALIGN(16); _main = . ; *(.rom.text) *(.text) . = ALIGN(16); }
.data . : { . = ALIGN(16); *(.rom.data) *(.data) *(.rodata) . = ALIGN(16); } */ . = 0xffffff80; .messages . : { *(.messages) . = 111; BYTE(0x00); }
. = 0xfffffff0; .reset . : { *(.reset) . = 15; BYTE(0x00); } }
/* * SerialICE * * Copyright (C) 2009 coresystems GmbH * * 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 */
.code32
_c_main: /* Enable FPU registers */ movl %eax, %ebp movl %cr0, %eax andl $~(1 << 2), %eax movl %eax, %cr0 movl %ebp, %eax
/* enable SSE */ movl %cr4, %eax orl $(3<<9), %eax movl %eax, %cr4
xorl %esp,%esp movl $0x7f,%esp #Start address of XMM/MMX stack. movl %esp,%dr2 #DR2 contains stack(low byte) and offset(hi byte)
jmp main
_pmode_start: /* Set up protected mode registers */ lgdt %cs:gdt ljmp $0x08, $1f 1: movl %eax, %ebp movw $0x10, %ax movw %ax, %ds movw %ax, %es movw %ax, %ss movw %ax, %fs movw %ax, %gs
movl %ebp, %eax
jmp _c_main
.code16 _start: /* Go to protected mode */ cli movl %eax, %ebp xorl %eax, %eax movl %eax, %cr3 movw %cs, %ax shlw $4, %ax movw $gdt, %bx subw %ax, %bx data32 lgdt %cs:(%bx)
movl %cr0, %eax andl $0x7ffaffd1, %eax orl $0x60000001, %eax movl %eax, %cr0
movl %ebp, %eax data32 ljmp $0x08, $_pmode_start
/* GDT */ .align 4 gdt: .word gdt_size .long gdt .word 0
.word 0xffff, 0x0000 .byte 0x00, 0x9b, 0xcf, 0x00
.word 0xffff, 0x0000 .byte 0x00, 0x93, 0xcf, 0x00 gdt_size = (. - gdt - 1)
/* Messages */ .section ".messages" .globl program_name program_name: .ascii "SerialICE v" VERSION " (" __DATE__ ")" .byte 0x00 .globl program_copyright program_copyright: .string "Copyright (C) 2009 coresystems GmbH."
/* Reset Vector */ .section ".reset" .globl reset_vector reset_vector: .code16 jmp _start
On Sun, 04 Oct 2009 21:40:48 +0200, Rudolf Marek r.marek@assembler.cz wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi all
During the weekend train trips I managed to get serialICE 1.2 working
with
the XMM stack (in qemu).
There were some gotchas:
#1 missing SSE enable #2 missing stack setup ;) (taken from RemoteBIOS) #3 wrong LD script, the rodata section relocation did not work #4 the stack realign feature #5 missing -O2 ;)
I'm attaching the modified files right now. Not so big deal hopefully.
Please can someone fix the ld script in proper way? I borrowed this
change
from the RemoteBIOS.
Btw now it has just 17KB and not nearly 60KB or so with romcc ;)
With that we have 128B of stack.
Cool thanks Rudolf :-) I will test this out as soon as I can get crossgcc to work (I think I am having hardware issues with the Linux box I am using right now). I wish we had a SerailICE svn repo for these fixes (even a private one), Stefan???
Joseph Smith wrote:
I will test this out as soon as I can get crossgcc to work (I think I am having hardware issues with the Linux box I am using right now). I wish we had a SerailICE svn repo for these fixes (even a private one), Stefan???
We have a private one.
Stefan