void atari_stram_free( void *addr ) { BLOCK *block; DPRINTK( "atari_stram_free(addr=%p)\n", addr ); if (!(block = find_region( addr ))) { printk( KERN_ERR "Attempt to free non-allocated ST-RAM block at %p " "from %p\n", addr, __builtin_return_address(0) ); return; } DPRINTK( "atari_stram_free: found block (%p): size=%08lx, owner=%s, " "flags=%02x\n", block, block->size, block->owner, block->flags ); if (!(block->flags & BLOCK_GFP)) goto fail; DPRINTK("atari_stram_free: is kmalloced, order_size=%d\n", get_order(block->size)); free_pages((unsigned long)addr, get_order(block->size)); remove_region( block ); return; fail: printk( KERN_ERR "atari_stram_free: cannot free block at %p " "(called from %p)\n", addr, __builtin_return_address(0) ); }
/* * This function is called every turn. * It makes the regions age, if necessary and calls the appropriate * callbacks when needed. */ void run_regions(struct level *lev) { int i, j, k; int f_indx; /* End of life ? */ /* Do it backward because the array will be modified */ for (i = lev->n_regions - 1; i >= 0; i--) { if (lev->regions[i]->ttl == 0) { if ((f_indx = lev->regions[i]->expire_f) == NO_CALLBACK || (*callbacks[f_indx]) (lev->regions[i], 0)) remove_region(lev->regions[i]); } } /* Process remaining lev->regions */ for (i = 0; i < lev->n_regions; i++) { /* Make the region age */ if (lev->regions[i]->ttl > 0) lev->regions[i]->ttl--; /* Check if player is inside region */ f_indx = lev->regions[i]->inside_f; if (f_indx != NO_CALLBACK && hero_inside(lev->regions[i])) (void)(*callbacks[f_indx]) (lev->regions[i], 0); /* Check if any monster is inside region */ if (f_indx != NO_CALLBACK) { for (j = 0; j < lev->regions[i]->n_monst; j++) { struct monst *mtmp = find_mid(lev, lev->regions[i]->monsters[j], FM_FMON); if (!mtmp || DEADMONSTER(mtmp) || (*callbacks[f_indx]) (lev->regions[i], mtmp)) { /* The monster died, remove it from list */ k = (lev->regions[i]->n_monst -= 1); lev->regions[i]->monsters[j] = lev->regions[i]->monsters[k]; lev->regions[i]->monsters[k] = 0; --j; /* current slot has been reused; recheck it next */ } } } } }
void atari_stram_free( void *addr ) { BLOCK *block; DPRINTK( "atari_stram_free(addr=%p)\n", addr ); if (!(block = find_region( addr ))) { printk( KERN_ERR "Attempt to free non-allocated ST-RAM block at %p " "from %p\n", addr, __builtin_return_address(0) ); return; } DPRINTK( "atari_stram_free: found block (%p): size=%08lx, owner=%s, " "flags=%02x\n", block, block->size, block->owner, block->flags ); #ifdef CONFIG_STRAM_SWAP if (!max_swap_size) { #endif if (block->flags & BLOCK_GFP) { DPRINTK( "atari_stram_free: is kmalloced, order_size=%d\n", get_gfp_order(block->size) ); free_pages( (unsigned long)addr, get_gfp_order(block->size) ); } else goto fail; #ifdef CONFIG_STRAM_SWAP } else if (block->flags & (BLOCK_INSWAP|BLOCK_STATIC)) { DPRINTK( "atari_stram_free: is swap-alloced\n" ); free_stram_region( SWAP_NR(block->start), N_PAGES(block->size) ); } else goto fail; #endif remove_region( block ); return; fail: printk( KERN_ERR "atari_stram_free: cannot free block at %p " "(called from %p)\n", addr, __builtin_return_address(0) ); }
static int tolua_region_destroy(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, 0); remove_region(®ions, self); return 0; }
static void _acpi_parse_tables(acpi_t *acpi, void* table_paddr, RegionList_t* regions, int parent) { int this_rec; region_type_t type; if (table_paddr == NULL) { return; } acpi_header_t* header = acpi_parse_table(acpi, table_paddr); if (header == NULL) { /* skip table */ return; } void *table_vaddr = (void *) header; type = acpi_sig_id(header->signature); // optimistic: remove later if the table is bad this_rec = add_region_size(regions, type, table_vaddr, header->length, parent); if (this_rec < 0) { return; /* List full */ } switch (type) { /******************************************* * These tables are completely implemented * *******************************************/ case ACPI_RSDP: { acpi_rsdp_t* rsdp = (acpi_rsdp_t*) table_vaddr; /* * This table does not have a standard acpi header. * Adjust for this earlier assumption */ regions->regions[this_rec].size = rsdp->length; /* parse sub tables */ _acpi_parse_tables(acpi, (void*)rsdp->rsdt_address, regions, this_rec); _acpi_parse_tables(acpi, (void*)(uint32_t)rsdp->xsdt_address, regions, this_rec); break; } case ACPI_RSDT: { acpi_rsdt_t* rsdt = (acpi_rsdt_t*) table_vaddr; uint32_t* subtbl = acpi_rsdt_first(rsdt); while (subtbl != NULL) { _acpi_parse_tables(acpi, (void*)*subtbl, regions, this_rec); subtbl = acpi_rsdt_next(rsdt, subtbl); } break; } /* * XSDT is the same as RSDT but with 64bit addresses * Don't parse this table to avoid duplicate entries * * TODO this could actually contain unique entries, * need to parse and sort out dups. */ case ACPI_XSDT: { fprintf(stderr, "Warning: skipping table ACPI XSDT\n"); // acpi_xsdt_t* xsdt = (acpi_xsdt_t*)table; break; } case ACPI_FADT: { acpi_fadt_t* fadt = (acpi_fadt_t*)table_vaddr; _acpi_parse_tables(acpi, (void*)fadt->facs_address, regions, this_rec); _acpi_parse_tables(acpi, (void*)fadt->dsdt_address, regions, this_rec); break; } /****************************************** * These tables use a standard header and * * have no sub-tables * ******************************************/ case ACPI_HPET: case ACPI_BOOT: case ACPI_SPCR: case ACPI_MCFG: case ACPI_SPMI: case ACPI_SSDT: case ACPI_DSDT: case ACPI_FACS: case ACPI_MADT: case ACPI_ERST: { break; } /********************************************* * These tables use a standard header and * * have no sub-tables but depend on device * * caps that may not be available. It may be * * best to withhold these tables from linux * *********************************************/ case ACPI_ASF : case ACPI_DMAR: { break; } /****************************************** * These tables are partially implemented * ******************************************/ case ACPI_BERT: { // acpi_bert_t* bert = (acpi_bert_t*)table; /* not complemetely implemented so exclude */ fprintf(stderr, "Warning: skipping table ACPI_BERT (unimplemented)"); remove_region(regions, this_rec); break; } case ACPI_EINJ: { // acpi_einj_t* einj = (acpi_einj_t*)table; /* not complemetely implemented so exclude */ fprintf(stderr, "Warning: skipping table ACPI_EINJ (unimplemented)"); remove_region(regions, this_rec); break; } case ACPI_HEST: { // acpi_hest_t* hest = (acpi_hest_t*)table; /* not complemetely implemented so exclude */ fprintf(stderr, "Warning: skipping table ACPI_HEST (unimplemented)"); remove_region(regions, this_rec); break; } /******************************************* * These tables are not implemented at all * *******************************************/ case ACPI_ASPT:/* present on Dogfood machine: unknown table */ case ACPI_MSCT: case ACPI_CPEP: case ACPI_ECDT: case ACPI_SBST: case ACPI_SLIT: case ACPI_SRAT: /* Not implemented */ fprintf(stderr, "Warning: skipping table %s (unimplemented)", header->signature); remove_region(regions, this_rec); break; default: fprintf(stderr, "Warning: skipping table %s (unimplemented)", header->signature); remove_region(regions, this_rec); } return; }