resource *resource_manager::read_font_arg(const char **ptr) { string arg; if (!read_text_arg(ptr, arg)) return 0; return lookup_resource(RESOURCE_FONT, arg); }
resource *resource_manager::read_resource_arg(const char **ptr) { while (white_space(**ptr)) *ptr += 1; const char *name = *ptr; while (**ptr != '\0' && !white_space(**ptr)) *ptr += 1; if (name == *ptr) { error("missing resource type"); return 0; } int ri; for (ri = 0; ri < NRESOURCES; ri++) if (strlen(resource_table[ri]) == size_t(*ptr - name) && memcmp(resource_table[ri], name, *ptr - name) == 0) break; if (ri >= NRESOURCES) { error("unknown resource type"); return 0; } if (ri == RESOURCE_PROCSET) return read_procset_arg(ptr); string arg; if (!read_text_arg(ptr, arg)) return 0; return lookup_resource(resource_type(ri), arg); }
void resource_manager::import_file(const char *filename, ps_output &out) { out.end_line(); string name(filename); resource *r = lookup_resource(RESOURCE_FILE, name); supply_resource(r, -1, out.get_file(), 1); }
resource *resource_manager::read_procset_arg(const char **ptr) { string arg; if (!read_text_arg(ptr, arg)) return 0; string version; if (!read_text_arg(ptr, version)) return 0; unsigned revision; if (!read_uint_arg(ptr, &revision)) return 0; return lookup_resource(RESOURCE_PROCSET, arg, version, revision); }
resource_manager::resource_manager() : extensions(0), language_level(0), resource_list(0) { read_download_file(); string procset_name("grops"); extern const char *version_string; extern const char *revision_string; unsigned revision_uint; if (!read_uint_arg(&revision_string, &revision_uint)) revision_uint = 0; string procset_version(version_string); procset_resource = lookup_resource(RESOURCE_PROCSET, procset_name, procset_version, revision_uint); procset_resource->flags |= resource::SUPPLIED; }
void atari_stram_free(void *addr) { unsigned long start = (unsigned long)addr; struct resource *res; unsigned long size; res = lookup_resource(&stram_pool, start); if (!res) { pr_err("atari_stram_free: trying to free nonexistent region " "at %p\n", addr); return; } size = resource_size(res); pr_debug("atari_stram_free: free %lu bytes at %p\n", size, addr); release_resource(res); kfree(res); }
void amiga_chip_free(void *ptr) { unsigned long start = ZTWO_PADDR(ptr); struct resource *res; unsigned long size; res = lookup_resource(&chipram_res, start); if (!res) { pr_err("amiga_chip_free: trying to free nonexistent region at " "%p\n", ptr); return; } size = resource_size(res); pr_debug("amiga_chip_free: free %lu bytes at %p\n", size, ptr); atomic_add(size, &chipavail); release_resource(res); kfree(res); }
void __iomem *ltq_remap_resource(struct resource *res) { __iomem void *ret = NULL; struct resource *lookup = lookup_resource(&iomem_resource, res->start); if (lookup && strcmp(lookup->name, res->name)) { panic("conflicting memory range %s\n", res->name); return NULL; } if (!lookup) { if (insert_resource(&iomem_resource, res) < 0) { panic("Failed to insert %s memory\n", res->name); return NULL; } } if (request_mem_region(res->start, resource_size(res), res->name) < 0) { panic("Failed to request %s memory\n", res->name); goto err_res; } ret = ioremap_nocache(res->start, resource_size(res)); if (!ret) goto err_mem; pr_debug("remap: 0x%08X-0x%08X : \"%s\"\n", res->start, res->end, res->name); return ret; err_mem: panic("Failed to remap %s memory\n", res->name); release_mem_region(res->start, resource_size(res)); err_res: release_resource(res); return NULL; }