~ubuntu-branches/ubuntu/trusty/grub2/trusty

« back to all changes in this revision

Viewing changes to grub-core/commands/acpihalt.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-01-16 15:18:04 UTC
  • mfrom: (17.6.38 experimental)
  • Revision ID: package-import@ubuntu.com-20140116151804-3foouk7fpqcq3sxx
Tags: 2.02~beta2-2
* Convert patch handling to git-dpm.
* Add bi-endian support to ELF parser (Tomohiro B Berry).
* Adjust restore_mkdevicemap.patch to mark get_kfreebsd_version as static,
  to appease "gcc -Werror=missing-prototypes".
* Cherry-pick from upstream:
  - Change grub-macbless' manual page section to 8.
* Install grub-glue-efi, grub-macbless, grub-render-label, and
  grub-syslinux2cfg.
* grub-shell: Pass -no-pad to xorriso when building floppy images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <stdlib.h>
23
23
#include <stdint.h>
24
24
#include <string.h>
 
25
#include <errno.h>
25
26
 
26
27
#define grub_dprintf(cond, args...) printf ( args )
27
28
#define grub_printf printf
184
185
                grub_uint8_t *scope, int scope_len)
185
186
{
186
187
  grub_uint8_t *prev = table;
187
 
  int sleep_type = -2;
188
188
  
189
189
  if (!ptr)
190
190
    ptr = table + sizeof (struct grub_acpi_table_header);
233
233
              switch (*ptr2)
234
234
                {
235
235
                case GRUB_ACPI_OPCODE_ZERO:
236
 
                  sleep_type = 0;
237
 
                  break;
 
236
                  return 0;
238
237
                case GRUB_ACPI_OPCODE_ONE:
239
 
                  sleep_type = 1;
240
 
                  break;
 
238
                  return 1;
241
239
                case GRUB_ACPI_OPCODE_BYTE_CONST:
242
 
                  sleep_type = ptr2[1];
243
 
                  break;
 
240
                  return ptr2[1];
244
241
                default:
245
242
                  grub_printf ("Unknown data type in _S5: 0x%x\n", *ptr2);
246
243
                  return -1;
286
283
        }
287
284
    }
288
285
 
289
 
  grub_dprintf ("acpi", "TYP = %d\n", sleep_type);
290
 
  return sleep_type;
 
286
  return -2;
291
287
}
292
288
 
293
289
#ifdef GRUB_DSDT_TEST
299
295
  unsigned char *buf;
300
296
  if (argc < 2)
301
297
    printf ("Usage: %s FILE\n", argv[0]);
302
 
  f = fopen (argv[1], "rb");
 
298
  f = grub_util_fopen (argv[1], "rb");
303
299
  if (!f)
304
300
    {
305
301
      printf ("Couldn't open file\n");
311
307
  buf = malloc (len);
312
308
  if (!buf)
313
309
    {
314
 
      printf ("Couldn't malloc buffer\n");
 
310
      printf (_("error: %s.\n"), _("out of memory"));
315
311
      fclose (f);
316
312
      return 2;
317
313
    }
318
314
  if (fread (buf, 1, len, f) != len)
319
315
    {
320
 
      printf ("Read failed\n");
 
316
      printf (_("cannot read `%s': %s"), argv[1], strerror (errno));
321
317
      free (buf);
322
318
      fclose (f);
323
319
      return 2;
369
365
          grub_dprintf ("acpi", "PM1a port=%x\n", port);
370
366
 
371
367
          if (grub_memcmp (dsdt->signature, "DSDT",
372
 
                           sizeof (dsdt->signature)) == 0)
 
368
                           sizeof (dsdt->signature)) == 0
 
369
              && sleep_type < 0)
373
370
            sleep_type = get_sleep_type (buf, NULL, buf + dsdt->length,
374
371
                                         NULL, 0);
375
372
        }
376
 
      else if (grub_memcmp ((void *) (grub_addr_t) *entry_ptr, "SSDT", 4) == 0)
 
373
      else if (grub_memcmp ((void *) (grub_addr_t) *entry_ptr, "SSDT", 4) == 0
 
374
               && sleep_type < 0)
377
375
        {
378
376
          struct grub_acpi_table_header *ssdt
379
377
            = (struct grub_acpi_table_header *) (grub_addr_t) *entry_ptr;
385
383
        }
386
384
    }
387
385
 
 
386
  grub_dprintf ("acpi", "SLP_TYP = %d, port = 0x%x\n", sleep_type, port);
388
387
  if (port && sleep_type >= 0 && sleep_type < 8)
389
 
    {
390
 
      grub_dprintf ("acpi", "SLP_TYP = %d, port = 0x%x\n", sleep_type, port);
391
 
 
392
 
      grub_outw (GRUB_ACPI_SLP_EN | (sleep_type << GRUB_ACPI_SLP_TYP_OFFSET),
393
 
                 port & 0xffff);
394
 
    }
 
388
    grub_outw (GRUB_ACPI_SLP_EN | (sleep_type << GRUB_ACPI_SLP_TYP_OFFSET),
 
389
               port & 0xffff);
395
390
 
396
391
  grub_millisleep (1500);
397
392