On Friday 12 February 2010 03:59:10 Carl-Daniel Hailfinger wrote:
> Some programmers want to run certain functions during programmer
> shutdown, but the function choice depends on the code path taken during
> programmer init.
> Rather than rebuilding the whole init logic in the shutdown function, it
> is now possible to register functions for execution on programmer shutdown.
> The behaviour is similar to atexit(), but the registered functions will
> be run on programmer shutdown instead of on exit.
> Registered functions must have the prototype
> void function(void);
> and will be executed in reverse registration order directly before
> calling the programmer-specific shutdown() function. It is recommended
> to have shutdown() only disable programmer/hardware access and leave all
> code path sensitive shutdown to functions registered with
> register_shutdown().
> If in doubt, consult man atexit.
> 
If i read this right i am going to need a wakeup() function too.. otherwise i 
will be left with a system with no keyboard, mouse, power button and 
*automatic fan control*.. i damn nearly fried my CPU when I played with this 
:-/

Correct me if there is something about this i don't understand.. the below 
little program that can call flashrom between shutdown and wakeup, and then 
detection works.

#include <stdio.h>
#include <stdlib.h>
#include <sys/io.h>
#include <unistd.h>

void write_wait();
void read_wait();

int main()
{
        unsigned char ret = 0;

        iopl (3);

        outb_p (0xb4, 0x64);
        write_wait ();
        outb_p (0xff, 0x64);
        write_wait ();

        while (! ret == 0xfa);
        {
                read_wait ();
                ret = inb_p (0x60);
        }

        /* put nifty code that does magic trickery here.. */
        /* Like calling flashrom ;-)                                    */


        outb_p (0xfb, 0x64);
        write_wait();
        outb_p (0xff, 0x64);
        write_wait ();

        return 0;
}

void write_wait()
{
        int timer = 0;

        while (inb_p(0x64) & 0x2)
        {
                if (++timer == 40000)
                {
                        printf ("KBC port 0x64 does not accept commands - \n");
                        printf ("We may in fact have been shafted..\n");
                        exit (-1);
                }
        }
}

void read_wait()
{
        int timer = 0;

        while (!inb_p(0x64) & 0x1)
        {
                if (++timer == 40000)
                {
                        printf ("KBC port 0x64 never became ready. Faulty 
Exit\n");
                        printf ("Your macine is in an unknown state.. 
great..\n");
                        exit (-1);
                }
        }
}

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to