--- trunk/src/devices/dev_mp.c 2007/10/08 16:19:28 21 +++ trunk/src/devices/dev_mp.c 2007/10/08 16:19:37 22 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2005 Anders Gavare. All rights reserved. + * Copyright (C) 2003-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: dev_mp.c,v 1.30 2005/11/13 00:14:09 debug Exp $ + * $Id: dev_mp.c,v 1.34 2006/02/09 20:02:59 debug Exp $ * * This is a fake multiprocessor (MP) device. It can be useful for * theoretical experiments, but probably bares no resemblance to any @@ -63,8 +63,7 @@ /* * dev_mp_access(): */ -int dev_mp_access(struct cpu *cpu, struct memory *mem, uint64_t relative_addr, - unsigned char *data, size_t len, int writeflag, void *extra) +DEVICE_ACCESS(mp) { struct mp_data *d = extra; int i, which_cpu; @@ -125,16 +124,16 @@ which_cpu = idata; for (i=0; imachine->ncpus; i++) - if (i!=which_cpu) + if (i != which_cpu) d->cpus[i]->running = 0; break; case DEV_MP_UNPAUSE_CPU: - /* Unpause all cpus except our selves: */ + /* Unpause a specific CPU: */ which_cpu = idata; - for (i=0; imachine->ncpus; i++) - if (i!=which_cpu) - d->cpus[i]->running = 1; + + if (which_cpu >= 0 && which_cpu machine->ncpus) + d->cpus[which_cpu]->running = 1; break; case DEV_MP_STARTUPSTACK: @@ -144,7 +143,12 @@ break; case DEV_MP_HARDWARE_RANDOM: - /* Return (up to) 64 bits of "hardware random": */ + /* + * Return (up to) 64 bits of "hardware random": + * + * NOTE: Remember that random() is (usually) 31 bits of + * random data, _NOT_ 32, hence this construction. + */ odata = random(); odata = (odata << 31) ^ random(); odata = (odata << 31) ^ random(); @@ -243,10 +247,7 @@ } -/* - * devinit_mp(): - */ -int devinit_mp(struct devinit *devinit) +DEVINIT(mp) { struct mp_data *d; int n;