示例#1
0
void cancel_call(struct cancellation *c)
{
    struct exception_frame *frame;
    uint32_t *new_frame;

    /* Bail if the cancellable context is inactive/cancelled. */
    if (c->sp == NULL)
        return;

    /* Switch to exception context if we are not there already. */
    if (!in_exception()) {
        exc_cancel = c;
        sv_call(0);
        ASSERT(0); /* unreachable */
    }

    /* Modify return frame: Jump to exit of call_cancellable_fn() with
     * return code -1 and clean xPSR. */
    frame = (struct exception_frame *)read_special(psp);
    frame->r0 = -1;
    frame->pc = (uint32_t)do_cancel;
    frame->psr &= 1u<<24; /* Preserve Thumb mode; clear everything else */

    /* Find new frame address, set STKALIGN if misaligned. */
    new_frame = c->sp - 8;
    if ((uint32_t)new_frame & 4) {
        new_frame--;
        frame->psr |= 1u<<9;
    }

    /* Copy the stack frame and update Process SP. */
    memmove(new_frame, frame, 32);
    write_special(psp, new_frame);

    /* Do this work at most once per invocation of call_cancellable_fn. */
    c->sp = NULL;
}
示例#2
0
int
main (int argc, char **argv)
{
  FILE *fp;
  char line[LINESIZE];
  int lnr = 0;
  const char *fname, *s;
  char *p1, *p2;
  const char *config_h;

  if (argc)
    {
      argc--; argv++;
    }

  if (argc != 6)
    {
      fputs ("usage: " PGM
             " host_os host_triplet template.h config.h"
             " version version_number\n",
             stderr);
      return 1;
    }
  host_os = argv[0];
  host_triplet = argv[1];
  fname = argv[2];
  config_h = argv[3];
  hdr_version = argv[4];
  hdr_version_number = argv[5];

  srcdir = malloc (strlen (fname) + 2 + 1);
  if (!srcdir)
    {
      fputs (PGM ": out of core\n", stderr);
      return 1;
    }
  strcpy (srcdir, fname);
  p1 = strrchr (srcdir, '/');
  if (p1)
    p1[1] = 0;
  else
    strcpy (srcdir, "./");

  if (parse_config_h (config_h))
    return 1;

  fp = fopen (fname, "r");
  if (!fp)
    {
      fprintf (stderr, "%s:%d: can't open file: %s",
               fname, lnr, strerror (errno));
      return 1;
    }

  while (fgets (line, LINESIZE, fp))
    {
      size_t n = strlen (line);

      lnr++;
      if (!n || line[n-1] != '\n')
        {
          fprintf (stderr,
                   "%s:%d: trailing linefeed missing, line too long or "
                   "embedded nul character\n", fname, lnr);
          break;
        }
      line[--n] = 0;

      p1 = strchr (line, '@');
      p2 = p1? strchr (p1+1, '@') : NULL;
      if (!p1 || !p2 || p2-p1 == 1)
        {
          puts (line);
          continue;
        }
      *p1++ = 0;
      *p2++ = 0;
      fputs (line, stdout);

      if (!strcmp (p1, "configure_input"))
        {
          s = strrchr (fname, '/');
          printf ("Do not edit.  Generated from %s for %s.",
                  s? s+1 : fname, host_triplet);
          fputs (p2, stdout);
        }
      else if (!write_special (fname, lnr, p1))
        {
          putchar ('@');
          fputs (p1, stdout);
          putchar ('@');
          fputs (p2, stdout);
        }
      else if (p2 && *p2)
        {
          fputs (p2, stdout);
        }
      putchar ('\n');
    }

  if (ferror (fp))
    {
      fprintf (stderr, "%s:%d: error reading file: %s\n",
               fname, lnr, strerror (errno));
      return 1;
    }

  fputs ("/*\n"
         "Loc" "al Variables:\n"
         "buffer-read-only: t\n"
         "End:\n"
         "*/\n", stdout);

  if (ferror (stdout))
    {
      fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno));
      return 1;
    }

  fclose (fp);

  return 0;
}
void __hyp_text __banked_restore_state(struct kvm_cpu_context *ctxt)
{
	write_special(ctxt->gp_regs.usr_regs.ARM_sp,	SP_usr);
	write_special(ctxt->gp_regs.usr_regs.ARM_pc,	ELR_hyp);
	write_special(ctxt->gp_regs.usr_regs.ARM_cpsr,	SPSR_cxsf);
	write_special(ctxt->gp_regs.KVM_ARM_SVC_sp,	SP_svc);
	write_special(ctxt->gp_regs.KVM_ARM_SVC_lr,	LR_svc);
	write_special(ctxt->gp_regs.KVM_ARM_SVC_spsr,	SPSR_svc);
	write_special(ctxt->gp_regs.KVM_ARM_ABT_sp,	SP_abt);
	write_special(ctxt->gp_regs.KVM_ARM_ABT_lr,	LR_abt);
	write_special(ctxt->gp_regs.KVM_ARM_ABT_spsr,	SPSR_abt);
	write_special(ctxt->gp_regs.KVM_ARM_UND_sp,	SP_und);
	write_special(ctxt->gp_regs.KVM_ARM_UND_lr,	LR_und);
	write_special(ctxt->gp_regs.KVM_ARM_UND_spsr,	SPSR_und);
	write_special(ctxt->gp_regs.KVM_ARM_IRQ_sp,	SP_irq);
	write_special(ctxt->gp_regs.KVM_ARM_IRQ_lr,	LR_irq);
	write_special(ctxt->gp_regs.KVM_ARM_IRQ_spsr,	SPSR_irq);
	write_special(ctxt->gp_regs.KVM_ARM_FIQ_r8,	R8_fiq);
	write_special(ctxt->gp_regs.KVM_ARM_FIQ_r9,	R9_fiq);
	write_special(ctxt->gp_regs.KVM_ARM_FIQ_r10,	R10_fiq);
	write_special(ctxt->gp_regs.KVM_ARM_FIQ_fp,	R11_fiq);
	write_special(ctxt->gp_regs.KVM_ARM_FIQ_ip,	R12_fiq);
	write_special(ctxt->gp_regs.KVM_ARM_FIQ_sp,	SP_fiq);
	write_special(ctxt->gp_regs.KVM_ARM_FIQ_lr,	LR_fiq);
	write_special(ctxt->gp_regs.KVM_ARM_FIQ_spsr,	SPSR_fiq);
}