public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* ACPI problems
@ 2009-01-21  9:52 mohd.adil
  2009-01-27 22:53 ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: mohd.adil @ 2009-01-21  9:52 UTC (permalink / raw)
  To: majordomo, acpi-bugzilla-request, linux-pm-devel-request,
	linux-pm

[-- Attachment #1: Type: text/html, Size: 4770 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread
* ACPI problems
@ 2009-01-21  9:54 mohd.adil
  0 siblings, 0 replies; 6+ messages in thread
From: mohd.adil @ 2009-01-21  9:54 UTC (permalink / raw)
  To: linux-pm, linux-pm-devel-request, acpi-bugzilla-request,
	majordomo

[-- Attachment #1: Type: text/html, Size: 4405 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: ACPI problems
@ 2009-01-28  9:04 mohd.adil
  2009-01-28  9:31 ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: mohd.adil @ 2009-01-28  9:04 UTC (permalink / raw)
  To: Pavel Machek
  Cc: majordomo, mohd.adil, linux-pm, acpi-bugzilla-request,
	linux-pm-devel-request

[-- Attachment #1: Type: text/html, Size: 8359 bytes --]

[-- Attachment #2: source code for acpi.txt --]
[-- Type: text/plain, Size: 7197 bytes --]

/* A simple linux kernel module */

/* Include the required headers */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <asm/rtc.h>

void do_acpi_stuff( void );
void print_acpi_buffer (acpi_string);
void print_acpi_int (acpi_string);
void print_acpi_string  (acpi_string);
void print_acpi_int2 (acpi_string);
void print_acpi_integer (acpi_string);
void print_acpi_string2  (acpi_string);
void setup_pmem_reboot (void);
void unsetup_pmem_reboot (void);
void show_cmos (void);
void cmos_setsize(void);

MODULE_PARM_DESC(choice, "A short integer");
MODULE_PARM_DESC(data, "Unsigned Long");

static short choice = 0;
static long data = 0;

module_param(choice , short, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
module_param(data , long, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);

/* The module initialisation function */
int init_module(void)
{

        printk(KERN_EMERG "Simple module inserted. Choice = %d, Data = %X \n", choice, data);

        /* extracting acpi namespace information */
        switch ( choice ) {
        case 1 : show_cmos();
                 break ;

        case 2 : setup_pmem_reboot();
                 break ;

        case 3 : unsetup_pmem_reboot();
                 break ;

        case 4 : cmos_setsize();
                 break ;

        case 5 : do_acpi_stuff();
                 break ;

        default :  printk(KERN_EMERG "Invalid choice" );
                 break;
        }

        return 0;
}

/* The module cleanup function */
void cleanup_module()
{
        printk(KERN_EMERG "Removing simple module.\n");
}

void setup_pmem_reboot (void)
{
        int temp = 0;
        outb ( 0xDD, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
        temp = temp | 0x10 ;
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
        outb (0xDD, 0x72);
        outb (temp , 0x73 );
}
void show_cmos (void)
{
        unsigned int temp = 0;
        outb ( 0xDD, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
        outb ( 0xCB, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Size = %d ", temp );
}
void unsetup_pmem_reboot (void)
{
        unsigned int temp = 0;
        outb ( 0xDD, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
        temp = temp & 0xEF ;
        outb (0xDD, 0x72);
        outb (temp , 0x73 );
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
}
void cmos_setsize(void)
{
        unsigned int temp = 0;
        outb ( 0xCB, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Size = %d ", temp );
        outb ( 0xCB, 0x72);
        outb ( data,  0x73);
        printk(KERN_EMERG "Size = %d ", temp );
}
void do_acpi_stuff( void )
{

        print_acpi_buffer ("\\_SB.PERB");
        print_acpi_integer ("\\_SB.PERL");
}
void print_acpi_integer (acpi_string astr) {

        acpi_handle s_b = (acpi_handle)0 ;
        acpi_status status ;
        unsigned long dat = 0;

        status = acpi_get_handle ( 0, astr, &s_b );
        if (status == AE_OK)
        {
                printk(KERN_EMERG " get_handle success %d, %x : ", status, s_b);
                status = acpi_evaluate_integer ( s_b, astr, NULL, &dat);
                if (status == AE_OK)
                        printk(KERN_EMERG " Integer Value = %d " , dat ) ;
                else
                        printk(KERN_EMERG " Error  evaluation %d " , status);
        }
        else
                printk(KERN_EMERG " get_handle error %d : ", status );
}

void print_acpi_buffer (acpi_string astr)
{

        acpi_handle s_b = (acpi_handle)0 ;
        acpi_status status ;
        struct acpi_buffer rels = { 0, NULL };
        union acpi_object *out_objs;
        u8 *cp ;
        int i;

        out_objs =  kmalloc (sizeof(union acpi_object), GFP_KERNEL);
        if ( !out_objs)
        {
                printk(KERN_EMERG " Could Not allocate memory rels pointer , buffer ");
                return;
        }
        status = acpi_get_handle ( 0, astr, &s_b );
        if (status == AE_OK)
        {
                printk(KERN_EMERG " get_handle success %d, %x : ", status, s_b);

                memset(out_objs, 0, sizeof(union acpi_object));
                rels.length = 2 * (sizeof(union acpi_object));
                rels.pointer = out_objs;
                status = acpi_evaluate_object(s_b, NULL , NULL, &rels);
                if (status == AE_OK)
                {
                        printk(KERN_EMERG " eval_object buffer success.result: %d, %d ", out_objs->type,  rels.length );
                        cp  = (u8 *)(out_objs->buffer.pointer) ;
                        for (i = 0; i< out_objs->buffer.length ;  i++) {

                                printk(KERN_EMERG " %X", cp[i]);
                        }

                }
                else
                {
                        printk(KERN_EMERG " error %d : ", status);
                        printk(KERN_EMERG " result buffer : %d " , (int)rels.length);
                }
        }
        else
                printk(KERN_EMERG " get_handle error %d : ", status );

kfree (out_objs);
}

void print_acpi_int (acpi_string astr)
{
        acpi_handle *s_b;
        acpi_status status ;
        struct acpi_buffer *rels;
        union acpi_object *out_objs;

        s_b = kmalloc ( sizeof (acpi_handle),  GFP_KERNEL);
        if (!s_b)
        {
                printk(KERN_EMERG " Could Not allocate memory s_b , int ");
                return;
        }
        rels = kmalloc ( sizeof (struct acpi_buffer) , GFP_KERNEL);
        if ( !rels)
        {
                printk(KERN_EMERG " Could Not allocate memory rels , int");
                return;
        }
        rels->pointer =  kmalloc ( sizeof(union acpi_object), GFP_KERNEL);
        if ( !rels->pointer)
        {
                printk(KERN_EMERG " Could Not allocate memory rels pointer , int");
                return;
        }

        status = acpi_get_handle ( 0, astr, &s_b );
        if (status == AE_OK)
        {
                printk(KERN_EMERG "get_handle success %d, %d : ", status, *s_b);
                rels->length = sizeof(union acpi_object);
                status = acpi_evaluate_object(*s_b, 0, 0, rels);
                out_objs = (union acpi_object *) rels->pointer;
                if (status == AE_OK)
                {
                        printk(KERN_EMERG " eval_object int success. result  : %d, %d, ", out_objs->type, rels->length );
                        printk(KERN_EMERG "Int value = %d", out_objs->integer.value  );
                }
                else
                {
                        printk(KERN_EMERG " error %d : ", status);
                }
        }
        else
                printk(KERN_EMERG " get_handle error %d : ", status);


kfree (rels->pointer);
kfree (rels);
kfree (s_b);
}

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: ACPI problems
@ 2009-01-28 13:59 mohd.adil
  0 siblings, 0 replies; 6+ messages in thread
From: mohd.adil @ 2009-01-28 13:59 UTC (permalink / raw)
  To: Pavel Machek
  Cc: majordomo, mohd.adil, linux-pm, acpi-bugzilla-request,
	linux-pm-devel-request

[-- Attachment #1: Type: text/html, Size: 29566 bytes --]

[-- Attachment #2: source code for acpi.txt --]
[-- Type: text/plain, Size: 7197 bytes --]

/* A simple linux kernel module */

/* Include the required headers */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <asm/rtc.h>

void do_acpi_stuff( void );
void print_acpi_buffer (acpi_string);
void print_acpi_int (acpi_string);
void print_acpi_string  (acpi_string);
void print_acpi_int2 (acpi_string);
void print_acpi_integer (acpi_string);
void print_acpi_string2  (acpi_string);
void setup_pmem_reboot (void);
void unsetup_pmem_reboot (void);
void show_cmos (void);
void cmos_setsize(void);

MODULE_PARM_DESC(choice, "A short integer");
MODULE_PARM_DESC(data, "Unsigned Long");

static short choice = 0;
static long data = 0;

module_param(choice , short, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
module_param(data , long, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);

/* The module initialisation function */
int init_module(void)
{

        printk(KERN_EMERG "Simple module inserted. Choice = %d, Data = %X \n", choice, data);

        /* extracting acpi namespace information */
        switch ( choice ) {
        case 1 : show_cmos();
                 break ;

        case 2 : setup_pmem_reboot();
                 break ;

        case 3 : unsetup_pmem_reboot();
                 break ;

        case 4 : cmos_setsize();
                 break ;

        case 5 : do_acpi_stuff();
                 break ;

        default :  printk(KERN_EMERG "Invalid choice" );
                 break;
        }

        return 0;
}

/* The module cleanup function */
void cleanup_module()
{
        printk(KERN_EMERG "Removing simple module.\n");
}

void setup_pmem_reboot (void)
{
        int temp = 0;
        outb ( 0xDD, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
        temp = temp | 0x10 ;
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
        outb (0xDD, 0x72);
        outb (temp , 0x73 );
}
void show_cmos (void)
{
        unsigned int temp = 0;
        outb ( 0xDD, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
        outb ( 0xCB, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Size = %d ", temp );
}
void unsetup_pmem_reboot (void)
{
        unsigned int temp = 0;
        outb ( 0xDD, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
        temp = temp & 0xEF ;
        outb (0xDD, 0x72);
        outb (temp , 0x73 );
        printk(KERN_EMERG "Pmem_reboot = %d ", temp );
}
void cmos_setsize(void)
{
        unsigned int temp = 0;
        outb ( 0xCB, 0x72);
        temp = inb ( 0x73 );
        printk(KERN_EMERG "Size = %d ", temp );
        outb ( 0xCB, 0x72);
        outb ( data,  0x73);
        printk(KERN_EMERG "Size = %d ", temp );
}
void do_acpi_stuff( void )
{

        print_acpi_buffer ("\\_SB.PERB");
        print_acpi_integer ("\\_SB.PERL");
}
void print_acpi_integer (acpi_string astr) {

        acpi_handle s_b = (acpi_handle)0 ;
        acpi_status status ;
        unsigned long dat = 0;

        status = acpi_get_handle ( 0, astr, &s_b );
        if (status == AE_OK)
        {
                printk(KERN_EMERG " get_handle success %d, %x : ", status, s_b);
                status = acpi_evaluate_integer ( s_b, astr, NULL, &dat);
                if (status == AE_OK)
                        printk(KERN_EMERG " Integer Value = %d " , dat ) ;
                else
                        printk(KERN_EMERG " Error  evaluation %d " , status);
        }
        else
                printk(KERN_EMERG " get_handle error %d : ", status );
}

void print_acpi_buffer (acpi_string astr)
{

        acpi_handle s_b = (acpi_handle)0 ;
        acpi_status status ;
        struct acpi_buffer rels = { 0, NULL };
        union acpi_object *out_objs;
        u8 *cp ;
        int i;

        out_objs =  kmalloc (sizeof(union acpi_object), GFP_KERNEL);
        if ( !out_objs)
        {
                printk(KERN_EMERG " Could Not allocate memory rels pointer , buffer ");
                return;
        }
        status = acpi_get_handle ( 0, astr, &s_b );
        if (status == AE_OK)
        {
                printk(KERN_EMERG " get_handle success %d, %x : ", status, s_b);

                memset(out_objs, 0, sizeof(union acpi_object));
                rels.length = 2 * (sizeof(union acpi_object));
                rels.pointer = out_objs;
                status = acpi_evaluate_object(s_b, NULL , NULL, &rels);
                if (status == AE_OK)
                {
                        printk(KERN_EMERG " eval_object buffer success.result: %d, %d ", out_objs->type,  rels.length );
                        cp  = (u8 *)(out_objs->buffer.pointer) ;
                        for (i = 0; i< out_objs->buffer.length ;  i++) {

                                printk(KERN_EMERG " %X", cp[i]);
                        }

                }
                else
                {
                        printk(KERN_EMERG " error %d : ", status);
                        printk(KERN_EMERG " result buffer : %d " , (int)rels.length);
                }
        }
        else
                printk(KERN_EMERG " get_handle error %d : ", status );

kfree (out_objs);
}

void print_acpi_int (acpi_string astr)
{
        acpi_handle *s_b;
        acpi_status status ;
        struct acpi_buffer *rels;
        union acpi_object *out_objs;

        s_b = kmalloc ( sizeof (acpi_handle),  GFP_KERNEL);
        if (!s_b)
        {
                printk(KERN_EMERG " Could Not allocate memory s_b , int ");
                return;
        }
        rels = kmalloc ( sizeof (struct acpi_buffer) , GFP_KERNEL);
        if ( !rels)
        {
                printk(KERN_EMERG " Could Not allocate memory rels , int");
                return;
        }
        rels->pointer =  kmalloc ( sizeof(union acpi_object), GFP_KERNEL);
        if ( !rels->pointer)
        {
                printk(KERN_EMERG " Could Not allocate memory rels pointer , int");
                return;
        }

        status = acpi_get_handle ( 0, astr, &s_b );
        if (status == AE_OK)
        {
                printk(KERN_EMERG "get_handle success %d, %d : ", status, *s_b);
                rels->length = sizeof(union acpi_object);
                status = acpi_evaluate_object(*s_b, 0, 0, rels);
                out_objs = (union acpi_object *) rels->pointer;
                if (status == AE_OK)
                {
                        printk(KERN_EMERG " eval_object int success. result  : %d, %d, ", out_objs->type, rels->length );
                        printk(KERN_EMERG "Int value = %d", out_objs->integer.value  );
                }
                else
                {
                        printk(KERN_EMERG " error %d : ", status);
                }
        }
        else
                printk(KERN_EMERG " get_handle error %d : ", status);


kfree (rels->pointer);
kfree (rels);
kfree (s_b);
}

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-01-28 13:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-21  9:52 ACPI problems mohd.adil
2009-01-27 22:53 ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2009-01-21  9:54 mohd.adil
2009-01-28  9:04 mohd.adil
2009-01-28  9:31 ` Pavel Machek
2009-01-28 13:59 mohd.adil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox