Hello.

I have SoC machine (dmesg below) which hangs on reboot in most cases.
Serial console shows this:
login: /etc/rc.shutdown in progress...
stopping local daemons:.
Rsyncing disks... omplete.
then:
Rsyncing disks... doneete.
rebooting...
and then it hangs.

It hangs here almost 100% if serial console attached.
Meanwhile "halt -p" always switch off machine completely, without
hangs (as far as I remember).
It halts with or without sysctl option machdep.apmhalt=1.

I tried to adopt linux reboot.c quirks for reboot machine using BIOS
functions. I found these quirks here
http://lxr.linux.no/#linux+v2.6.37.2/arch/x86/kernel/reboot.c#L297
(many detail explanations here) and pulled code from
machine_real_restart().
This is what I tried to add into /usr/src/sys/arch/i386/i386/machdep.c
into cpu_rest() frunction (tried in different places). It is
completely ugly, but that was for the test (again, details in
reboot.c, link above):

//try to do what the CMOS_WRITE supposed to do...
outb(0x8f, 0x70);
outb(0x00, 0x70 + 1);
// skipped load_cr3 - don't know how to do
*((unsigned short *)0x472) = 0x1234;
static const unsigned char real_mode_switch [] =
{
0x66, 0x0f, 0x20, 0xc0,                 /*    movl  %cr0,%eax        */
0x66, 0x83, 0xe0, 0x11,                 /*    andl  $0x00000011,%eax */
0x66, 0x0d, 0x00, 0x00, 0x00, 0x60,     /*    orl   $0x60000000,%eax */
0x66, 0x0f, 0x22, 0xc0,                 /*    movl  %eax,%cr0        */
0x66, 0x0f, 0x22, 0xd8,                 /*    movl  %eax,%cr3        */
0x66, 0x0f, 0x20, 0xc3,                 /*    movl  %cr0,%ebx        */
0x66, 0x81, 0xe3, 0x00, 0x00, 0x00, 0x60,       /*    andl  $0x60000000,%ebx
*/
0x74, 0x02,                             /*    jz    f                */
0x0f, 0x09,                             /*    wbinvd                 */
0x24, 0x10,                             /* f: andb  $0x10,al         */
0x66, 0x0f, 0x22, 0xc0                  /*    movl  %eax,%cr0        */
};
static const unsigned char jump_to_bios [] =
{
0xea, 0x00, 0x00, 0xff, 0xff            /*    ljmp  $0xffff,$0x0000  */
};
memcpy((void *)(0x1000 - sizeof(real_mode_switch) - 100),
real_mode_switch, sizeof (real_mode_switch));
memcpy((void *)(0x1000 - 100), jump_to_bios, sizeof(jump_to_bios));
static const unsigned long long real_mode_gdt_entries [3] =
{
        0x0000000000000000ULL,  /* Null descriptor */
        0x00009b000000ffffULL,  /* 16-bit real-mode 64k code at 0x00000000 */
        0x000093000100ffffULL   /* 16-bit real-mode 64k data at 0x00000100 */
};
struct desc_ptr {
        unsigned short size;
        unsigned long address;
} __attribute__((packed)) ;
struct desc_ptr real_mode_idt = { 0x3ff, 0 };
struct desc_ptr real_mode_gdt = { sizeof (real_mode_gdt_entries) - 1,
(long)real_mode_gdt_entries };
__asm __volatile("lidt %0"::"m" (real_mode_idt));
__asm __volatile("lgdt %0"::"m" (real_mode_gdt));
__asm __volatile("movl $0x0010,%%eax\n"
"\tmovl %%eax,%%ds\n"
"\tmovl %%eax,%%es\n"
"\tmovl %%eax,%%fs\n"
"\tmovl %%eax,%%gs\n"
"\tmovl %%eax,%%ss" : : : "eax");
__asm __volatile("ljmp $0x0008,%0"
:
: "i" ((void *)(0x1000 - sizeof (real_mode_switch) - 100)));

But it always break into ddb, interrupts disabled, so I don't know
what to do more and how.
Maybe someone help me to adopt this or show me better way to resolve
reboot hangs?


Machine has flash SD card slot. By BIOS option it is connected to IDE
controller.
boot>
booting hd0a:/bsd: 8254588+1100008 [61+372432+358069]=0x99e4c8
entry point at 0x200120

[ using 730980 bytes of bsd ELF symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2011 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 4.9 (GENERIC) #664: Tue Feb 22 12:19:01 MST 2011
    t...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Vortex86 SoC  (586-class) 1.01 GHz
cpu0: FPU,TSC,CX8
real mem  = 536440832 (511MB)
avail mem = 517533696 (493MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 06/29/10, BIOS32 rev. 0 @ 0xf0010
apm0 at bios0: Power Management spec V1.2
apm0: AC on, battery charge unknown
pcibios0 at bios0: rev 3.0 @ 0xf0000/0x10000
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xf34d0/240 (13 entries)
pcibios0: no compatible PCI ICU found: ICU vendor 0x17f3 product 0x6036
pcibios0: Warning, unable to fix up PCI interrupt routing
pcibios0: PCI bus #0 is the last bus
bios0: ROM list: 0xc0000/0x8000 0xe9400/0x200!
cpu0 at mainbus0: (uniprocessor)
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "RDC R6021 Host" rev 0x02
pcib0 at pci0 dev 7 function 0 vendor "RDC", unknown product 0x6036 rev 0x00
vte0 at pci0 dev 8 function 0 "RDC R6040 Ethernet" rev 0x00: irq 7, address
00:f
rdcphy0 at vte0 phy 1: R6040 10/100 PHY, rev. 1
ohci0 at pci0 dev 10 function 0 "RDC R6060 USB" rev 0x12: irq 3, version 1.0,
lt
ehci0 at pci0 dev 10 function 1 "RDC R6061 USB" rev 0x03: irq 3
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "RDC EHCI root hub" rev 2.00/1.00 addr 1
ohci1 at pci0 dev 11 function 0 "RDC R6060 USB" rev 0x12: irq 3, version 1.0,
lt
ehci1 at pci0 dev 11 function 1 "RDC R6061 USB" rev 0x03: irq 3
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "RDC EHCI root hub" rev 2.00/1.00 addr 1
pciide0 at pci0 dev 12 function 0 "Intel 82801EB/ER IDE" rev 0x01: DMA,
channely
wd0 at pciide0 channel 0 drive 0: <SD04G RDC SD-IDE HOST CONTROLLER>
wd0: 1-sector PIO, LBA, 3796MB, 7774208 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
pciide0: channel 1 disabled (no drives)
vga1 at pci0 dev 13 function 0 vendor "RDC", unknown product 0x2010 rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
azalia0 at pci0 dev 14 function 0 vendor "RDC", unknown product 0x3010 rev
0x015
azalia0: codecs: Realtek ALC262
audio0 at azalia0
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
                                                       com0: console
com2: irq 5 already in use
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
usb2 at ohci0: USB revision 1.0
uhub2 at usb2 "RDC OHCI root hub" rev 1.00/1.00 addr 1
usb3 at ohci1: USB revision 1.0
uhub3 at usb3 "RDC OHCI root hub" rev 1.00/1.00 addr 1
biomask ff4d netmask ffcd ttymask ffdf
vscsi0 at root
scsibus0 at vscsi0: 256 targets
softraid0 at root
root on wd0a swap on wd0b dump on wd0b
Automatic boot in progress: starting file system checks.
/dev/rwd0a: file system is clean; not checking
/dev/rwd0e: file system is clean; not checking
/dev/rwd0d: file system is clean; not checking
setting tty flags
...

# usbdevs
addr 1: EHCI root hub, RDC
addr 1: EHCI root hub, RDC
addr 1: OHCI root hub, RDC
addr 1: OHCI root hub, RDC
# pcidump
Domain /dev/pci0:
 0:0:0: RDC R6021 Host
 0:7:0: RDC unknown
 0:8:0: RDC R6040 Ethernet
 0:10:0: RDC R6060 USB
 0:10:1: RDC R6061 USB
 0:11:0: RDC R6060 USB
 0:11:1: RDC R6061 USB
 0:12:0: Intel 82801EB/ER IDE
 0:13:0: RDC unknown
 0:14:0: RDC unknown

--
antonvm

Reply via email to