grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dell Media Direct button


From: Per Öberg
Subject: Re: Dell Media Direct button
Date: Thu, 21 Aug 2008 09:21:19 +0200
User-agent: Thunderbird 2.0.0.6 (X11/20070728)

Javier Martín wrote:
> 2008/8/20 Colin D Bennett <address@hidden>:
>> On Wed, 20 Aug 2008 12:12:59 +0200
>> Robert Millan <address@hidden> wrote:
>>
>>> On Wed, Aug 20, 2008 at 10:57:22AM +0200, Per Öberg wrote:
>>>> Hi
>>>>
>>>> Some laptops, e.g., from Dell have a special button that they use to
>>>> boot a special embedded OS for media only instead of the ordinary
>>>> OS.
>>>>
>>>> For my Dell XPS1330M I can determine if the Media button was
>>>> pressed by first writing 0xf9 to port 0x70 and then testing bit
>>>> 0x08 of port 0x71.
>>>>
>>>> It would be really nice if such a test could be enabled in grub so
>>>> that grub can go directly to a specific menu alternative without
>>>> showing the gui if the media button was pressed.
>>>>
>>>> Is this interesting? I'd like to contribute but I don't know where
>>>> to start.
>>> Sounds interesting, but this needs some thought on how to design it.
>>>
>>> I suppose what you want is change the 'default' variable.  Perhaps
>>> increase it by 1?  But then, where do you do this?  grub_machine_init
>>> is too early as 'default' hasn't been set yet.
>>>
>>> Maybe we could have a global 'int default_offset' variable that is
>>> initialized in grub_machine_init and later on used by normal.mod?
>> If I pressed the "Media Direct" button, I would also want to have a
>> timeout of 0, since by pressing the Media Direct button instead of the
>> power button, I've already indicated which entry I want to boot, and
>> there is no need to show the menu -- unless, perhaps, we decided to
>> show a different "media" menu... so hopefully giving all the power to
>> the grub.cfg script would be enough to make all this possible.
>>
>> Regards,
>> Colin
>>
>> _______________________________________________
>> Grub-devel mailing list
>> address@hidden
>> http://lists.gnu.org/mailman/listinfo/grub-devel
>>
>>
> 
> Well, I own a XPS1330 myself (I'm writing from it now, as I'm taking a
> week at the beach in Benidorm ^^). This functionality could be
> implemented by a module that used the pre-menu hooks proposed by Bean:
> it would check the status before the menu is shown, then act on the
> result.
> 
> However, all this assumes that pressing that key creates no additional
> side effect like the replacement of the MBR by the system firmware,
> booting another MBR written in flash memory or something like that: I
> thought the choice took place at the "real" MBR, but disassembling it
> revealed that it does not use the mentioned I/O ports interface, so
> most likely what the system firmware does is set the active flag in
> the MediaDirect partition.
> 
> I'm ready to check any related patches on the actual hardware _once
> I'm back in Madrid_ because here I have no recovery tools.
> 
> -Habbit
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel

It works for me =)

See how below...

There might be different firmware versions out there and there's been a
lot of fuss about early versions of MD screwing up you partition table.
There has also been suggestions on how to disable it by overwriting your
MBR (http://ubuntuforums.org/showthread.php?t=606345).

There seems to be a number of different versions in the range of 1-3 and
some uses a hidden HPA partion while some "hides" the partition by
changing the partition id. The installation process and the possibility
to upgrade between the different version indicates (not same as proof, i
know) that the firmware does about the same for the different releases
and that it is the MBR that is important since this is what you install
to make it work.

Dan Goodell has a website that describes his findings of how the Dell
MBR works (http://www.goodells.net/dellrestore/hpa-issues.htm). On this
website he indicates that these ports exists. I believe that his
documentation is for MD v1-2 and I have v3.3. He has disassembled the
MBR code and the procedure showed in the part he sent me showed out to
work perfectly when using in my test setup.

--------------------------------------------------------------------------
My setup:
--------------------------------------------------------------------------
Comp: Dell XPS1330M,
Media Direct version: 3.3
Delivered: 2008-07-14
Disk layout:
 - grub legacy on MBR,
 - 100Mb (/dev/sda1, Main grub partiton, config chainloads sda2, sda3 or
sda5)
 - 100Mb  (/dev/sda2, geexbox, with own grub and grub config files in /boot)
 -  30Gb, (/dev/sda3, Kubuntu with own grub and grub config files)
 - Extended partition ~250Gb linux (/dev/sda5, Not using yet but with
test-boot-loader) ,~2Gb swap (/dev/sda6) N

I have a small boot loader written from scratch, which is attached to
the mail, that i dd to /dev/sda5 using "dd if=boot.bin of=/dev/sda5
count=512 bs=1"

If i press the MD button it will show a splash screen and then show grub
main menu, same menu as with ordinary power button (but the graphics
mode is different). I can then choose to chainload /dev/sda5 which
changes the graphics mode and turns the screen red for MD or green for
ordinary power button (or was it the opposite...)

Sometimes when i press the MD button it will hang for a while before
showing me the grub menu, pressing esc will then go directly to grub. I
have not done any statistics of when this happens.

Also, sometimes the first part of bootup will take forever but I am
unsure of why. This might indicate that the firmware is looking for
something on disk (or just that i have triggered some complete POST by
aborting the boot process in some way, the BIOS indicates that this is
possible)

If someone wants to test my boot code please be warned. The MD button
has been known to screw things up and I can't guarantee that that my dd
command is correct. Also, I might have changed something since I tried
it yesterday and I haven't got my computer with me so I cant't test the
version I'm sending. I am, however, very curios if this works for anyone
else so I can't wait till I tested it again...

Regards Per Öberg

Attachment: boot.bin
Description: Binary data

[org 0x0]       ; Offset zero is desired

jmp START       ; jump to executable code 

; definition of boot sector data for a diskette
        
BS_OEMName      db "MSWIN4.1"    ; 8 characters 
BPB_BytsPerSec  dw 0x0200        ; 512 bytes per sector
BPB_SecPerClus  db 0x01          ; one sector per cluster
BPB_RsvdSecCnt  dw 0x0001        ; one reserved sector
BPB_NumFATs     db 0x02          ; two FATs
BPB_RootEntCnt  dw 0x00E0        ; 224 entries 
BPB_TotSec16    dw 0x0B40        ; 2880 sectors on disk
BPB_Media       db 0xF0          ; media type code
BPB_FATSz16     dw 0x0009        ; 9 sectors in one FAT
BPB_SecPerTrk   dw 0x0012        ; 18 sectors per track
BPB_NumHeads    dw 0x0002        ; 2 heads
BPB_HiddSec     dd 0x00000000    ; no hidden sectors
BPB_TotSec32    dd 0x00000000    ; no FAT32 sectors
BS_DrvNum       db 0x00          ; drive number 0
BS_Reserved1    db 0x00          ; reserved
BS_BootSig      db 0x29          ; extended boot signature
BS_VolID        dd 0x12345678    ; serial number 
BS_VolLab       db "a_nice_disc" ; volume label 
BS_FilSysType   db "FAT12   "    ; file system 


%define MD_Get_MD_Status 0xf9   
%define MD_Write_Port    0x70
%define MD_Read_Port     0x71
%define MD_Bit_To_Test   0x08

        
START:                          ; start of CODE
        cli                     ; disable interrupts 

;; Enable 320x200 graphics mode
        mov     eax,0x13        
        int     0x10

;; Check if the button is pressed
        mov     al,MD_Get_MD_Status
        out     MD_Write_Port,al
        in      al,MD_Read_Port
        test    al,MD_Bit_To_Test
        mov     al,0x0
        out     MD_Write_Port,al 
        jz      set_red
        

;; Set green in first palette position
set_green:      
        mov     ax,0
        mov     dx,0x3c8        ; Set first palette value
        out     dx,al
        inc     dx              ; Palette is at 0x3c9
        mov     al,0x00         ; Set red value
        out     dx,al           
        mov     al,0xff         ; Set green value
        out     dx,al           
        mov     ax,0x0          ; Set blue value
        out     dx,al           
        jmp     hang_here       


;; Set red in first palette position    
set_red:        
        mov     ax,0
        mov     dx,0x3c8        ; Set first palette value
        out     dx,al
        inc     dx              ; Palette is at 0x3c9
        mov     al,0xff         
        out     dx,al           ; Set red value
        mov     al,0x0
        out     dx,al           ; Set green value
        mov     ax,0x0
        out     dx,al           ; Set blue value
        
        
hang_here:
        jmp hang_here
;; ----------------------
;; Finish up
;; ----------------------
        
times 512-($-$$)-2 db 0 ; make the code exactly 512 bytes
dw 0xAA55               ; the required final two bytes for a boot sector
# Per Öberg

BINDIR=.
# Build tools
CC=gcc
LD=gcc
NASM=nasm
NFLAGS=-f elf
NFLAGS_BIN = -f bin 
EXTRA_CFLAGS=
#EXTRA_CFLAGS=-g -DDEBUG 
CFLAGS= -m32 -Wall  -std=c89 -pedantic -Wunreachable-code
LFLAGS= -m32 

OBJS = boot_loader.o
TARGETS = 

all:
        nasm  -f bin -o boot.bin boot_loader.asm

#dd:
#       dd if=boot.bin of=/dev/sda5 bs=1 count=512

cleanup:
        find . -name '*.[aos]' -o -name '*~' -type f | xargs rm -f
        find . -name 'semantic.cache' | xargs rm -f

clean: cleanup
        cd $(BINDIR) ; rm -f $(TARGETS)

Attachment: oberg.vcf
Description: Vcard


reply via email to

[Prev in Thread] Current Thread [Next in Thread]