flat assembler
Message board for the users of flat assembler.

Index > Windows > EC I/O synchronisation

Author
Thread Post new topic Reply to topic
Alphonso



Joined: 16 Jan 2007
Posts: 294
Alphonso
Looking at the Event Log I get this.
Quote:
:The embedded controller (EC) returned data when none was requested. The BIOS might be trying to access the EC without synchronizing with the operating system.
So is there a special way to synchronize? All I've done is check the IBF / OBF status while communicating using winring0 as the driver.
Post 09 Sep 2009, 16:09
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
alphonso, perhaps you should post the code your using. Does winring0 put a cli sti around the code you execute through it, it could be something as simple as that.
Post 09 Sep 2009, 16:24
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 294
Alphonso
Well my code is a bit messy at the moment, I've tried to clean up the 'read EC byte routine' to post but WinRing0 does the dirty work. We just need to pass the port number and either the data byte or storage location depending whether we're writing or reading. AFAIK there is no encapsulated CLI/STI.
Code:
;-------------------------------------------
proc    GetEcByte
        inc     [FailECB]                               ;Fail Flag for reading EC Byte

@@:
        invoke  ReadIoPortByteEx,66h,PByte              ;Read EC CMD/Status Register
        cmp     eax,0
        je      Fail                                    ;WinRing0.dll call failed

        mov     al,byte[PByte]
        and     al,7bh                                  ;Mask input bits
        cmp     al,0                                    ;Nothing pending
        je      @f
        cmp     al,8                                    ;Seems something writes a command to the EC and never finishes off
                                                        ;if we don't ignore this first time we never get any EC data.
                                                        ;Once we're talking all seems to go as expected !?!

        jne     Fail                                    ;Some other flag set so we just give up talking to the EC this time round
@@:

        invoke  WriteIoPortByteEx,66h,80h               ;Send 'Read Byte' command (0x80) to EC CMD/Status port 0x66 via  WingRing0.dll
        cmp     eax,0
        je      Fail                                    ;WinRing0.dll call failed

@@:
        invoke  ReadIoPortByteEx,66h,PByte              ;Read EC CMD/Status port 0x66 to PByte
        cmp     eax,0
        je      Fail
        mov     al,byte[PByte]
        and     al,1 shl 1                              ;Check if Bit 1 Input Buffer Full (IBF = 0) ie EC has read command
        jnz     @b

        invoke  WriteIoPortByteEx,62h,[OffSet]          ;Set Byte position Offset that we wish to read
        cmp     eax,0
        je      Fail

@@:
        invoke  ReadIoPortByteEx,66h,PByte
        cmp     eax,0
        je      Fail
        mov     al,byte[PByte]
        cmp     al,1 shl 1                              ;Check if Bit 1 Input Buffer Full (IBF = 0) ie EC has read command
                                                        ;Maybe we can skip this and just check for data
        jnz     @b

@@:
        invoke  ReadIoPortByteEx,66h,PByte
        cmp     eax,0
        je      Fail
        mov     al,byte[PByte]
        cmp     al,1 shl 0                              ;Check if Bit 0 Output Buffer Full (OBF = 1) ie EC has sent data byte
        jne     @b

        invoke  ReadIoPortByteEx,62h,ECByte             ;Read the data byte and save in ECByte
        cmp     eax,0
        je      Fail

        mov     [FailECB],0                             ;Clear the fail flag, ie we were successful
Fail:
        ret
endp
;-------------------------------------------        

I think it's strange that when I go to read the EC cmd/status register for the first time bit 3 (CMD) is set which I think means something sent a command to the EC but never finished off.

I'm wondering if I need to use the ACPI GlobalLock to get the synchronisation while accessing the EC.

I did think about writing my own driver but quickly decided my ability and patience wasn't up to it so wimped out. Laughing Besides WinRing0 seems to offer what I need plus it's certified too. Smile
Post 10 Sep 2009, 04:04
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
You should really try the code in your own driver. There are a lot of Win 32 driver examples just plug your code into one of the sources compile and run the scmanager util. If it doesn't cause the event to be fired you know it's winring0's fault.
Post 10 Sep 2009, 16:03
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 294
Alphonso
Yeah, I guess I should but with drivers heading towards having to be certified it takes away some of the enthusiasm. There are still some other tests that I will probably do before though. Thanks for the input.
Post 11 Sep 2009, 04:32
View user's profile Send private message Reply with quote
phpdevpad



Joined: 12 Jan 2013
Posts: 37
phpdevpad
How can you include winring0 into fasm?
Post 29 Jan 2013, 21:02
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.