Ejemplo n.º 1
0
Archivo: heap.c Proyecto: dholroyd/pup
static void pup_heap_thread_destroy(struct PupHeap *heap)
{
	struct PupHeapRegion *local_region = get_thread_info(heap)->local_region;
	if (local_region) {
		free_region(local_region);
	}
}
Ejemplo n.º 2
0
void free_regions(void)
{
    memset(uidhash, 0, sizeof(uidhash));
    while (deleted_regions) {
        region *r = deleted_regions;
        deleted_regions = r->next;
        free_region(r);
    }
    while (regions) {
        region *r = regions;
        regions = r->next;
        runhash(r);
        free_region(r);
    }
    max_index = 0;
    last = NULL;
}
Ejemplo n.º 3
0
Archivo: heap.c Proyecto: dholroyd/pup
static void destroy_global_heap(struct PupHeap *heap)
{
	struct PupHeapRegion *tail = global_heap_head(heap);
	while (tail) {
		struct PupHeapRegion *tmp = tail;
		tail = region_next(tail);
		free_region(tmp);
	}
}
Ejemplo n.º 4
0
int
yescrypt_init_shared(yescrypt_shared_t * shared,
    const uint8_t * param, size_t paramlen,
    uint64_t N, uint32_t r, uint32_t p,
    yescrypt_init_shared_flags_t flags,
    uint8_t * buf, size_t buflen)
{
	yescrypt_shared_t half1, half2;
	uint8_t salt[32];

	if (flags & YESCRYPT_SHARED_PREALLOCATED) {
		if (!shared->aligned || !shared->aligned_size)
			return -1;
	} else {
		init_region(shared);
	}
	if (!param && !paramlen && !N && !r && !p && !buf && !buflen)
		return 0;

	if (yescrypt_kdf(NULL, shared,
	    param, paramlen, NULL, 0, N, r, p, 0, 0,
	    YESCRYPT_RW | __YESCRYPT_INIT_SHARED_1,
	    salt, sizeof(salt)))
		goto out;

	half1 = half2 = *shared;
	half1.aligned_size /= 2;
	half2.aligned += half1.aligned_size;
	half2.aligned_size = half1.aligned_size;
	N /= 2;

	if (p > 1 && yescrypt_kdf(&half1, &half2,
	    param, paramlen, salt, sizeof(salt), N, r, p, 0, 0,
	    YESCRYPT_RW | __YESCRYPT_INIT_SHARED_2,
	    salt, sizeof(salt)))
		goto out;

	if (yescrypt_kdf(&half2, &half1,
	    param, paramlen, salt, sizeof(salt), N, r, p, 0, 0,
	    YESCRYPT_RW | __YESCRYPT_INIT_SHARED_1,
	    salt, sizeof(salt)))
		goto out;

	if (yescrypt_kdf(&half1, &half2,
	    param, paramlen, salt, sizeof(salt), N, r, p, 0, 0,
	    YESCRYPT_RW | __YESCRYPT_INIT_SHARED_1,
	    buf, buflen))
		goto out;

	return 0;

out:
	if (!(flags & YESCRYPT_SHARED_PREALLOCATED))
		free_region(shared);
	return -1;
}
Ejemplo n.º 5
0
static int
checksum_match(struct pcmcia_socket *s, unsigned long base, unsigned long size)
{
	struct resource *res1, *res2;
	int a = -1, b = -1;

	res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe");
	res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM, "cs memory probe");

	if (res1 && res2) {
		a = checksum(s, res1);
		b = checksum(s, res2);
	}

	free_region(res2);
	free_region(res1);

	return (a == b) && (a >= 0);
}
Ejemplo n.º 6
0
static int
cis_readable(struct pcmcia_socket *s, unsigned long base, unsigned long size)
{
	struct resource *res1, *res2;
	cisinfo_t info1, info2;
	int ret = 0;

	res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe");
	res2 = claim_region(s, base + size/2, size/2, IORESOURCE_MEM, "cs memory probe");

	if (res1 && res2) {
		ret = readable(s, res1, &info1);
		ret += readable(s, res2, &info2);
	}

	free_region(res2);
	free_region(res1);

	return (ret == 2) && (info1.Chains == info2.Chains);
}
Ejemplo n.º 7
0
Archivo: heap.c Proyecto: dholroyd/pup
static void collect_unmarked_objects(struct PupHeap *heap)
{
	struct PupHeapRegion *region;
	while ((region = steal_heap_region(heap))) {
		collect_unmarked_objects_in_region(heap, region);
		// reset the allocation for this region so that no object
		// freeing will occur,
		region->allocated = region->region;
		// release this region's memory,
		free_region(region);
	}
}
Ejemplo n.º 8
0
/* Remove all regions and clear all related data. */
void
free_regions(struct level *lev)
{
    int i;

    for (i = 0; i < lev->n_regions; i++)
        free_region(lev->regions[i]);
    lev->n_regions = 0;
    if (lev->max_regions > 0)
        free(lev->regions);
    lev->max_regions = 0;
    lev->regions = NULL;
}
void vc_region_delete (VC_REGION_T *region) {
   VC_REGION_RECT_T *rect;

   // Free all the substructure (cutouts and bands) first.
   while (region->rects) {
      rect = region->rects;
      region->rects = region->rects->next;
      free_region_rect(rect);
   }

   delete_bands(region);

   free_region(region);
}
Ejemplo n.º 10
0
/* compute the exclusive or of two regions into dst, which can be one of the source regions */
struct region *xor_region( struct region *dst, const struct region *src1,
                           const struct region *src2 )
{
    struct region *tmp = create_empty_region();

    if (!tmp) return NULL;

    if (!subtract_region( tmp, src1, src2 ) ||
        !subtract_region( dst, src2, src1 ) ||
        !union_region( dst, dst, tmp ))
        dst = NULL;

    free_region( tmp );
    return dst;
}
Ejemplo n.º 11
0
Archivo: free.c Proyecto: akabab/malloc
void		free_exec(void *ptr)
{
	t_block		*b;
	t_region	*r;

	if (!ptr)
		return ;
	if ((r = get_valid_region(ptr)) != NULL)
	{
		b = get_block(ptr);
		b->is_free = TRUE;
		if (b->prev && b->prev->is_free)
			b = fusion_block(b->prev);
		if (b->next && b->next->is_free)
			fusion_block(b);
		if (!b->next && !b->prev)
		{
			if (r->type == LARGE || (r->prev || r->next))
				free_region(r);
		}
	}
}
Ejemplo n.º 12
0
/*
 * Remove a region from the list & free it.
 */
void
remove_region(struct region *reg)
{
    int i, x, y;
    struct level *lev = reg->lev;

    for (i = 0; i < reg->lev->n_regions; i++)
        if (reg->lev->regions[i] == reg)
            break;
    if (i == reg->lev->n_regions)
        return;

    /* Update screen if necessary */
    if (reg->visible && level == lev)
        for (x = reg->bounding_box.lx; x <= reg->bounding_box.hx; x++)
            for (y = reg->bounding_box.ly; y <= reg->bounding_box.hy; y++)
                if (isok(x, y) && inside_region(reg, x, y) && cansee(x, y))
                    newsym(x, y);

    free_region(reg);
    lev->regions[i] = lev->regions[lev->n_regions - 1];
    lev->regions[lev->n_regions - 1] = NULL;
    lev->n_regions--;
}
Ejemplo n.º 13
0
regionfile* open_regionfile(char* filename) {
    FILE* f = NULL;
    regionfile* region = NULL;
    struct stat st;
    if (stat(filename, &st) != 0) {
        f = fopen(filename, "a");
        if (!f)
            return NULL;
        fclose(f);
        f = NULL;
        region = malloc(sizeof(regionfile));
        bzero(region, sizeof(regionfile));
        region->filename = strdup(filename);
        if (__region_write_offsets(region) != 0 || __region_write_timestamps(region) != 0) {
            free_region(region);
            return NULL;
        }
        {
            char* fn = filename;
            while (sscanf(fn, "r.%d.%d.mca", &region->x, &region->z) != 2) {
                if (*++fn == 0x00)
                    goto error;
            }
        }
        region->freeSectors = malloc(sizeof(unsigned char)*(2+1));
        memset(region->freeSectors, 0x01, 2);
        region->freeSectors[2] = 0x00;
        region->freeSectors[0] = 0x02;
        region->freeSectors[1] = 0x02;
        return region;
    }
    size_t filesize = st.st_size;
    if (filesize & 0xFFF) {
        filesize = (filesize | 0xFFF) + 1;
        if (truncate(filename, filesize) != 0)
            return NULL;
    }
    if (filesize == 0) {
        filesize = SECTOR_BYTES * 2;
        if (truncate(filename, filesize) != 0)
            return NULL;
    }
    f = fopen(filename, "rb");
    if (f) {
        region = malloc(sizeof(regionfile));
        bzero(region, sizeof(regionfile));
        {
            char* fn = filename;
            while (sscanf(fn, "r.%d.%d.mca", &region->x, &region->z) != 2) {
                if (*++fn == 0x00)
                    goto error;
            }
        }
        if (fread(region->offsets, 4, SECTOR_INTS, f) != SECTOR_INTS)
            goto error;
        size_t i;
        for (i = 0; i < SECTOR_INTS; i++)
            region->offsets[i] = be32toh(region->offsets[i]);
        if (fread(region->timestamps, 4, SECTOR_INTS, f) != SECTOR_INTS)
            goto error;
        for (i = 0; i < SECTOR_INTS; i++)
            region->timestamps[i] = be32toh(region->timestamps[i]);
        uint32_t freeSectorsLength = filesize/SECTOR_BYTES;
        region->freeSectors = malloc(sizeof(unsigned char)*(freeSectorsLength+1));
        memset(region->freeSectors, 0x01, freeSectorsLength);
        region->freeSectors[freeSectorsLength] = 0x00;
        region->freeSectors[0] = 0x02; /* The first 2 sectors are the offsets and timestamps so are never free! */
        region->freeSectors[1] = 0x02;
        for (i = 0; i < SECTOR_INTS; i++) {
            uint32_t sector = region->offsets[i] >> 8;
            uint32_t count = region->offsets[i] & 0xFF;
            uint32_t j;
            for (j = sector; j < (sector + count); j++) {
                if (j >= freeSectorsLength) {
                    /* If we reach this we should actually call a repair like function which we don't have yet. */
                    break;
                }
                region->freeSectors[j] = 0x02;
            };
        };
        region->filename = strdup(filename);
        fclose(f);
        return region;
error:
        free_region(region);
        fclose(f);
    }
    return NULL;
};
Ejemplo n.º 14
0
int
yescrypt_free_local(yescrypt_local_t * local)
{
    return free_region(local);
}
Ejemplo n.º 15
0
int
yescrypt_free_shared(yescrypt_shared_t * shared)
{
    return free_region(&shared->shared1);
}
Ejemplo n.º 16
0
int
yescrypt_init_shared(yescrypt_shared_t * shared,
                     const uint8_t * param, size_t paramlen,
                     uint64_t N, uint32_t r, uint32_t p,
                     yescrypt_init_shared_flags_t flags, uint32_t mask,
                     uint8_t * buf, size_t buflen)
{
    yescrypt_shared1_t * shared1 = &shared->shared1;
    yescrypt_shared_t dummy, half1, half2;
    uint8_t salt[32];

    if (flags & YESCRYPT_SHARED_PREALLOCATED) {
        if (!shared1->aligned || !shared1->aligned_size)
            return -1;
    } else {
        init_region(shared1);
    }
    shared->mask1 = 1;
    if (!param && !paramlen && !N && !r && !p && !buf && !buflen)
        return 0;

    init_region(&dummy.shared1);
    dummy.mask1 = 1;
    if (yescrypt_kdf(&dummy, shared1,
                     param, paramlen, NULL, 0, N, r, p, 0,
                     YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1,
                     salt, sizeof(salt)))
        goto out;

    half1 = half2 = *shared;
    half1.shared1.aligned_size /= 2;
    half2.shared1.aligned += half1.shared1.aligned_size;
    half2.shared1.aligned_size = half1.shared1.aligned_size;
    N /= 2;

    if (p > 1 && yescrypt_kdf(&half1, &half2.shared1,
                              param, paramlen, salt, sizeof(salt), N, r, p, 0,
                              YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_2,
                              salt, sizeof(salt)))
        goto out;

    if (yescrypt_kdf(&half2, &half1.shared1,
                     param, paramlen, salt, sizeof(salt), N, r, p, 0,
                     YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1,
                     salt, sizeof(salt)))
        goto out;

    if (yescrypt_kdf(&half1, &half2.shared1,
                     param, paramlen, salt, sizeof(salt), N, r, p, 0,
                     YESCRYPT_RW | YESCRYPT_PARALLEL_SMIX | __YESCRYPT_INIT_SHARED_1,
                     buf, buflen))
        goto out;

    shared->mask1 = mask;

    return 0;

out:
    if (!(flags & YESCRYPT_SHARED_PREALLOCATED))
        free_region(shared1);
    return -1;
}
Ejemplo n.º 17
0
int main(int argc, char** argv) {
  int32_t chunkx = 0, chunkz = 0;
  char* rfile = NULL;
  int arg, optindex;
  while ((arg = getopt_long(argc, argv, "hr:x:z:", g_LongOpts, &optindex)) != -1) {
    switch (arg) {
    case 'h':
      return usage(argv[0]);
    case 'r':
      rfile = optarg;
      break;
    case 'x':
      chunkx = atoi(optarg);
      break;
    case 'z':
      chunkz = atoi(optarg);
      break;
    }
  }
  if (!rfile)
    return usage(argv[0]);
  regionfile* region = open_regionfile(rfile);
  if (!region_contains_chunk(region, chunkx, chunkz)) {
    fprintf(stderr, "This region file doesn't contain chunk x:%d, z:%d\n", chunkx, chunkz);
    char buf[BUFSIZ];
    if (determine_region_file(buf, sizeof(buf), chunkx, chunkz) > 0)
      fprintf(stderr, "I suggest you look in \"%s\" instead.\n", buf);
    free_region(region);
    return 1;
  }
  fprintf(stderr, "Chunk %d, %d consists of %d internal sectors.\n", chunkx, chunkz, region_chunk_sector_count(region, chunkx, chunkz));
  chunk* c = get_chunk(region, chunkx, chunkz, 0);
  if (c) {
    uint64_t analyze[256][16];
    bzero(analyze, sizeof(analyze));
    uint8_t analyze_biomes[256];
    bzero(analyze_biomes, sizeof(analyze_biomes));
    uint8_t x, z, y;
    for (x = 0; x < 16; x++) {
      for (z = 0; z < 16; z++) {
        analyze_biomes[c->biomes[z][x]]++;
        for (y = 0; y < 255; y++)
          analyze[c->blocks[y][z][x]][c->data[y][z][x]]++;
      }
    }
    free_chunk(c);
    initblockdb();
    size_t i;
    for (i = 0; i < 256; i++) {
      size_t j;
      for (j = 0; j < 16; j++) {
        if (analyze[i][j] > 0)
          fprintf(stderr, "%s %lu\n", get_block_name(i, j), analyze[i][j]);
      }
    }
    initbiomedb();
    for (i = 0; i < 256; i++) {
      if (analyze_biomes[i] > 0)
        fprintf(stderr, "%s %hhu\n", get_biome_name(i), analyze_biomes[i]);
    }
  } else {
    fprintf(stderr, "%s\n", nbt_error_to_string(errno));
  }
  free_region(region);
  return 0;
};
Ejemplo n.º 18
0
/**
 * @brief Esta rutina inicializa el mapa de bits de memoria,
 * a partir de la informacion obtenida del GRUB.
 * para esto limpia el mapa de bits, es decir coloca todos los
 * bits en 0.
 * luego se asigna la minima direccion de memoria que se puede liberar
 * (la direccion lineal donde termina el kernel). Se verifica si los campos
 * mmap_length y mmap_addr son validos (si flags[6] = 1).
 * inmediatamente verifica si la rgion de memoria son validas y extrae
 * la region de memoria mas grande disponible siempre y cuando su direccion
 * base sea mayor o igual a la posicion del kernel.
 * se establece esta memoria como disponible para liberar memoria.
 */
void setup_memory(void){

	extern multiboot_header_t multiboot_header;
	extern unsigned int multiboot_info_location;

	/* Variables temporales para hallar la region de memoria disponible */
	unsigned int tmp_start;
	unsigned int tmp_length;
	unsigned int tmp_end;
	int mod_count;
	multiboot_info_t * info = (multiboot_info_t *)multiboot_info_location;

	int i;

	unsigned int mods_end; /* Almacena la dirección de memoria final
	del ultimo modulo cargado, o 0 si no se cargaron modulos. */

	/*printf("Bitmap array size: %d\n", memory_bitmap_length);*/

	for(i=0; i<memory_bitmap_length; i++){
		memory_bitmap[i] = 0;
	}

	/*
	printf("Inicio del kernel: %x\n", multiboot_header.kernel_start);
	printf("Fin del segmento de datos: %x\n", multiboot_header.data_end);
	printf("Fin del segmento BSS: %x\n", multiboot_header.bss_end);
	printf("Punto de entrada del kernel: %x\n", multiboot_header.entry_point);
	*/

	/* si flags[3] = 1, se especificaron módulos que deben ser cargados junto
	 * con el kernel*/

	mods_end = 0;

	if (test_bit(info->flags, 3)) {
		mod_info_t * mod_info;
		/*
		printf("Modules available!. Start: %u Count: %u\n", info->mods_addr,
				info->mods_count);
		*/
		for (mod_info = (mod_info_t*)info->mods_addr, mod_count=0;
				mod_count <info->mods_count;
				mod_count++, mod_info++) {
			/*
			printf("[%d] start: %u end: %u cmdline: %s \n", mod_count,
					mod_info->mod_start, mod_info->mod_end,
					mod_info->string);*/
			if (mod_info->mod_end > mods_end) {
				/* Los modulos se redondean a limites de 4 KB, redondear
				 * la dirección final del modulo a un limite de 4096 */
				mods_end = mod_info->mod_end + (mod_info->mod_end % 4096);
			}
		}
	}

	//printf("Mods end: %u\n", mods_end);

	/* si flags[6] = 1, los campos mmap_length y mmap_addr son validos */

	/* Revisar las regiones de memoria, y extraer la region de memoria
	 * de mayor tamano, maracada como disponible, cuya dirección base sea
	* mayor o igual a la posicion del kernel en memoria.
	*/

	memory_start = 0;
	memory_length = 0;

	free_units = 0;

	/**@brief inicio pemitido para liberar
	 * Suponer que el inicio de la memoria disponible se encuentra
	 * al finalizar el kernel
	 * allowed_free_start me dice cual es la direccion lineal en donde termina el kernel
	 */
	allowed_free_start = round_up_to_memory_unit(multiboot_header.bss_end);

	/** Existe un mapa de memoria válido creado por GRUB? */
	if (test_bit(info->flags, 6)) {
		memory_map_t *mmap;/**si el bit 6 esta en 1 se crea un mapa valido de memoria*/

		/*printf ("mmap_addr = 0x%x, mmap_length = 0x%x\n",
			   (unsigned) info->mmap_addr, (unsigned) info->mmap_length);*/
		for (mmap = (memory_map_t *) info->mmap_addr;
			(unsigned int) mmap < info->mmap_addr + info->mmap_length;
			mmap = (memory_map_t *) ((unsigned int) mmap
									 + mmap->entry_size
									 + sizeof (mmap->entry_size))) {
		 printf (" size = 0x%x, base_addr = 0x%x%x,"
				 " length = 0x%x%x, type = 0x%x\n",
				  mmap->entry_size,
				  mmap->base_addr_high,
				  mmap->base_addr_low,
				  mmap->length_high,
				  mmap->length_low,
				  mmap->type);

	  /** Verificar si la región de memoria cumple con las condiciones
	   * para ser considerada "memoria disponible".
	   *
	   * Importante: Si se supone un procesador de 32 bits, los valores
	   * de la parte alta de base y length (base_addr_high y
	   * length_high) son cero. Por esta razon se pueden ignorar y solo
	   * se usan los 32 bits menos significativos de base y length.
	   *
	   * Para que una region de memoria sea considerada "memoria
	   * disponible", debe cumplir con las siguientes condiciones:
	   *
	   * - Estar ubicada en una posicion de memoria mayor o igual que
	   * 	1 MB.
	   * - Tener su atributo 'type' en 1 = memoria disponible.
	   * */
		 /* La region esta marcada como disponible y su dirección base
		  * esta por encima de la posicion del kernel en memoria ?*/
		 if (mmap->type == 1 &&
			 mmap->base_addr_low >= multiboot_header.kernel_start) {
			 tmp_start = mmap->base_addr_low;
			 tmp_length = mmap->length_low;

			 /* Verificar si el kernel se encuentra en esta region */
			 if (multiboot_header.bss_end >= tmp_start &&
					 multiboot_header.bss_end <= tmp_start + tmp_length) {
				 //printf("Kernel is on this region!. Base: %u\n", tmp_start);
				 /* El kernel se encuentra en esta region. Tomar el inicio
				  * de la memoria disponible en la posicion en la cual
				  * finaliza el kernel
				 */
				 tmp_start = multiboot_header.bss_end;

				 /* Ahora verificar si ser cargaron modulos junto con el
				  * kernel. Estos modulos se cargan en regiones continuas
				  * al kernel.
				  * Si es asi, la nueva posicion inicial de la memoria
				  * disponible es la posicion en la cual terminan los modulos
				  * */
				 if (mods_end > 0 &&
						 mods_end >= tmp_start &&
						 mods_end <= tmp_start + tmp_length) {
						//printf("Adding module space...\n");
						tmp_start = mods_end;
				 }
				 /* Restar al espacio disponible.*/
				 tmp_length -= tmp_start - mmap->base_addr_low;
				 if (tmp_length > memory_length) {
					 memory_start = tmp_start;
					 memory_length = tmp_length; /* Tomar el espacio */
				 }
			 }else {
				 /* El kernel no se encuentra en esta region, verificar si
				  * su tamano es mayor que la region mas grande encontrada
				  * hasta ahora
				  */
				 if (tmp_length > memory_length) {
					 memory_start = tmp_start;
					 memory_length = tmp_length; /* Tomar el espacio */
				 }
			 }
		 }
		} //endfor
	}

	/* Existe una región de memoria disponible? */
	if (memory_start > 0 && memory_length > 0) {
		/* Antes de retornar, establecer la minima dirección de memoria
		 * permitida para liberar*/

		//printf("Free units before setting up memory: %d\n", free_units);


		tmp_start = memory_start;
		/* Calcular la dirección en la cual finaliza la memoria disponible */
		tmp_end = tmp_start + tmp_length;

		/* Redondear el inicio y el fin de la región de memoria disponible a
		 * unidades de memoria */
		tmp_end = round_down_to_memory_unit(tmp_end);
		tmp_start = round_up_to_memory_unit(tmp_start);

		/* Calcular el tamaño de la región de memoria disponible, redondeada
		 * a límites de unidades de memoria */
		tmp_length = tmp_end - tmp_start;

		/* Actualizar las variables globales del kernel */
		memory_start = tmp_start;
		memory_length = tmp_length;

		/* Marcar la región de memoria como disponible */
		free_region((char*)memory_start, memory_length);

		/* Establecer la dirección de memoria a partir
		 * de la cual se puede liberar memoria */
		allowed_free_start = memory_start;
		next_free_unit = allowed_free_start / MEMORY_UNIT_SIZE;

		total_units = free_units;
		base_unit = next_free_unit;

		/* printf("Available memory at: 0x%x units: %d Total memory: %d\n",
				memory_start, total_units, memory_length);*/
	}
 }
Ejemplo n.º 19
0
int
yescrypt_free_shared(yescrypt_shared_t * shared)
{
	return free_region(shared);
}
Ejemplo n.º 20
0
static void do_io_probe(struct pcmcia_socket *s, kio_addr_t base, kio_addr_t num)
{
    struct resource *res;
    struct socket_data *s_data = s->resource_data;
    kio_addr_t i, j, bad;
    int any;
    u_char *b, hole, most;

    printk(KERN_INFO "cs: IO port probe %#lx-%#lx:",
	   base, base+num-1);

    /* First, what does a floating port look like? */
    b = kmalloc(256, GFP_KERNEL);
    if (!b) {
            printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes");
            return;
    }
    memset(b, 0, 256);
    for (i = base, most = 0; i < base+num; i += 8) {
	res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe");
	if (!res)
	    continue;
	hole = inb(i);
	for (j = 1; j < 8; j++)
	    if (inb(i+j) != hole) break;
	free_region(res);
	if ((j == 8) && (++b[hole] > b[most]))
	    most = hole;
	if (b[most] == 127) break;
    }
    kfree(b);

    bad = any = 0;
    for (i = base; i < base+num; i += 8) {
	res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe");
	if (!res)
	    continue;
	for (j = 0; j < 8; j++)
	    if (inb(i+j) != most) break;
	free_region(res);
	if (j < 8) {
	    if (!any)
		printk(" excluding");
	    if (!bad)
		bad = any = i;
	} else {
	    if (bad) {
		sub_interval(&s_data->io_db, bad, i-bad);
		printk(" %#lx-%#lx", bad, i-1);
		bad = 0;
	    }
	}
    }
    if (bad) {
	if ((num > 16) && (bad == base) && (i == base+num)) {
	    printk(" nothing: probe failed.\n");
	    return;
	} else {
	    sub_interval(&s_data->io_db, bad, i-bad);
	    printk(" %#lx-%#lx", bad, i-1);
	}
    }

    printk(any ? "\n" : " clean.\n");
}