--- trunk/src/device.c 2007/10/08 16:19:28 21 +++ trunk/src/device.c 2007/10/08 16:19:37 22 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 Anders Gavare. All rights reserved. + * Copyright (C) 2005-2006 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: device.c,v 1.20 2005/11/22 16:26:35 debug Exp $ + * $Id: device.c,v 1.25 2006/02/18 21:03:11 debug Exp $ * * Device registry framework. */ @@ -142,7 +142,7 @@ * * Return value is a function pointer, or NULL if the name was not found. */ -void (*pci_lookup_initf(char *name))(struct machine *machine, +void (*pci_lookup_initf(const char *name))(struct machine *machine, struct memory *mem, struct pci_device *pd) { int i; @@ -264,6 +264,7 @@ struct devinit devinit; char *s2, *s3; size_t len; + int quoted; memset(&devinit, 0, sizeof(struct devinit)); devinit.machine = machine; @@ -285,6 +286,7 @@ } memcpy(devinit.name, name_and_params, len); devinit.name[len] = '\0'; + devinit.dma_irq_nr = -1; p = device_lookup(devinit.name); if (p == NULL) { @@ -340,19 +342,30 @@ } } else if (strncmp(s2, "irq=", 4) == 0) { devinit.irq_nr = mystrtoull(s3, NULL, 0); + } else if (strncmp(s2, "dma_irq=", 8) == 0) { + devinit.dma_irq_nr = mystrtoull(s3, NULL, 0); } else if (strncmp(s2, "in_use=", 7) == 0) { devinit.in_use = mystrtoull(s3, NULL, 0); } else if (strncmp(s2, "name2=", 6) == 0) { char *h = s2 + 6; size_t len = 0; - while (*h && *h != ' ') + quoted = 0; + while (*h) { + if (*h == '\'') + quoted = !quoted; h++, len++; + if (!quoted && *h == ' ') + break; + } devinit.name2 = malloc(len + 1); if (devinit.name2 == NULL) { fprintf(stderr, "out of memory\n"); exit(1); } - snprintf(devinit.name2, len + 1, s2 + 6); + h = s2 + 6; + if (*h == '\'') + len -= 2, h++; + snprintf(devinit.name2, len + 1, h); } else { fatal("unknown param: %s\n", s2); if (device_exit_on_error) @@ -363,8 +376,13 @@ /* skip to the next param: */ s2 = s3; - while (*s2 != '\0' && *s2 != ' ' && *s2 != ',' && *s2 != ';') + quoted = 0; + while (*s2 != '\0' && (*s2 != ' ' || quoted) && + *s2 != ',' && *s2 != ';') { + if (*s2 == '\'') + quoted = !quoted; s2 ++; + } }