Example #1
0
VOID Cache_DestroyCache(APTR cache)
{
    struct Cache *c = cache;
    ULONG i;

    Cache_Flush(c);

    for(i = 0; i < c->block_count; i++)
        FreeVec(c->blocks[i]);
    FreeVec(c->blocks);
    FreeVec(c->hash_table);
    FreeVec(c);
}
Example #2
0
static void Rulesets_OnChange_ruleset (cvar_t *var, char *value, qbool *cancel)
{
	extern void Cmd_ReInitAllMacro (void);

	if (cls.state != ca_disconnected) {
		Com_Printf ("%s can be changed only in disconneced mode\n", var->name);
		*cancel = true;
		return;
	}

	if (strncasecmp (value, "smackdown", 9) && strncasecmp (value, "mtfl", 4) && strncasecmp (value, "default", 7)) {
		Com_Printf_State (PRINT_INFO, "Unknown ruleset \"%s\"\n", value);
		*cancel = true;
		return;
	}

	// All checks passed  so we can remove old ruleset and set a new one
	switch (rulesetDef.ruleset) {
		case rs_smackdown:
			Rulesets_Smackdown (false);
			break;
		case rs_mtfl:
			Rulesets_MTFL (false);
			break;
		case rs_default:
			break;
		default:
			break;
	}

	// we need to mark custom textures in the memory (like for backpack and eyes) to be reloaded again
	Cache_Flush ();

	if (!strncasecmp (value, "smackdown", 9)) {
		Rulesets_Smackdown (true);
		Com_Printf_State (PRINT_OK, "Ruleset Smackdown initialized\n");
	} else if (!strncasecmp (value, "mtfl", 4)) {
		Rulesets_MTFL (true);
		Com_Printf_State (PRINT_OK, "Ruleset MTFL initialized\n");
	} else if (!strncasecmp (value, "default", 7)) {
		Rulesets_Default ();
		Com_Printf_State (PRINT_OK, "Ruleset default initialized\n");
	} else {
		Sys_Error ("OnChange_ruleset: WTF?\n");
		// this will never happen
		*cancel = true;
		return;
	}

	Cmd_ReInitAllMacro ();
}
Example #3
0
/*********************************************************************************************
* name:		IISClose
* func:		Close IIS circuit
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void IISClose()
{
    rIISCON = 0x0;    			// IIS stop
    Cache_Flush();
	
	/* recover Port B and Port C state */    
    rPDATB = 0x7ff;				// P9-LED1 P10-LED2
	rPCONB = 0x1cf;
	rPDATC = 0xff00;
	rPCONC = 0x0ff0ffff;	
	rPUPC  = 0x30ff;
	
	rINTMSK |= BIT_GLOBAL;		// Mask interrupt
}
Example #4
0
static void
Cache_f(void)
{
    if (Cmd_Argc() == 2) {
	if (!strcmp(Cmd_Argv(1), "print")) {
	    Cache_Print();
	    return;
	}
	if (!strcmp(Cmd_Argv(1), "flush")) {
	    Cache_Flush();
	    return;
	}
    }
    Con_Printf("Usage: cache print|flush\n");
}
Example #5
0
static void set_cache_and_start_app(
    uint32_t drom_addr,
    uint32_t drom_load_addr,
    uint32_t drom_size,
    uint32_t irom_addr,
    uint32_t irom_load_addr,
    uint32_t irom_size,
    uint32_t entry_addr)
{
    ESP_LOGD(TAG, "configure drom and irom and start");
    Cache_Read_Disable( 0 );
    Cache_Flush( 0 );

    /* Clear the MMU entries that are already set up,
       so the new app only has the mappings it creates.
    */
    for (int i = 0; i < DPORT_FLASH_MMU_TABLE_SIZE; i++) {
        DPORT_PRO_FLASH_MMU_TABLE[i] = DPORT_FLASH_MMU_TABLE_INVALID_VAL;
    }

    uint32_t drom_page_count = (drom_size + 64*1024 - 1) / (64*1024); // round up to 64k
    ESP_LOGV(TAG, "d mmu set paddr=%08x vaddr=%08x size=%d n=%d", drom_addr & 0xffff0000, drom_load_addr & 0xffff0000, drom_size, drom_page_count );
    int rc = cache_flash_mmu_set( 0, 0, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count );
    ESP_LOGV(TAG, "rc=%d", rc );
    rc = cache_flash_mmu_set( 1, 0, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count );
    ESP_LOGV(TAG, "rc=%d", rc );
    uint32_t irom_page_count = (irom_size + 64*1024 - 1) / (64*1024); // round up to 64k
    ESP_LOGV(TAG, "i mmu set paddr=%08x vaddr=%08x size=%d n=%d", irom_addr & 0xffff0000, irom_load_addr & 0xffff0000, irom_size, irom_page_count );
    rc = cache_flash_mmu_set( 0, 0, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count );
    ESP_LOGV(TAG, "rc=%d", rc );
    rc = cache_flash_mmu_set( 1, 0, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count );
    ESP_LOGV(TAG, "rc=%d", rc );
    DPORT_REG_CLR_BIT( DPORT_PRO_CACHE_CTRL1_REG, (DPORT_PRO_CACHE_MASK_IRAM0) | (DPORT_PRO_CACHE_MASK_IRAM1 & 0) | (DPORT_PRO_CACHE_MASK_IROM0 & 0) | DPORT_PRO_CACHE_MASK_DROM0 | DPORT_PRO_CACHE_MASK_DRAM1 );
    DPORT_REG_CLR_BIT( DPORT_APP_CACHE_CTRL1_REG, (DPORT_APP_CACHE_MASK_IRAM0) | (DPORT_APP_CACHE_MASK_IRAM1 & 0) | (DPORT_APP_CACHE_MASK_IROM0 & 0) | DPORT_APP_CACHE_MASK_DROM0 | DPORT_APP_CACHE_MASK_DRAM1 );
    Cache_Read_Enable( 0 );

    // Application will need to do Cache_Flush(1) and Cache_Read_Enable(1)

    ESP_LOGD(TAG, "start: 0x%08x", entry_addr);
    typedef void (*entry_t)(void) __attribute__((noreturn));
    entry_t entry = ((entry_t) entry_addr);

    // TODO: we have used quite a bit of stack at this point.
    // use "movsp" instruction to reset stack back to where ROM stack starts.
    (*entry)();
}
Example #6
0
static void VID_Restart_f(void)
{
	extern void GFX_Init(void);
	extern void ReloadPaletteAndColormap(void);
	qbool old_con_suppress;

	if (!host_initialized) { // sanity
		Com_Printf("Can't do %s yet\n", Cmd_Argv(0));
		return;
	}

	VID_Shutdown();

	ReloadPaletteAndColormap();

	// keys can get stuck because SDL2 doesn't send keyup event when the video system is down
	Key_ClearStates();

	VID_Init(host_basepal);

	// force models to reload (just flush, no actual loading code here)
	Cache_Flush();

	// shut up warnings during GFX_Init();
	old_con_suppress = con_suppress;
	con_suppress = (developer.value ? false : true);
	// reload 2D textures, particles textures, some other textures and gfx.wad
	GFX_Init();

	// reload skins
	Skin_Skins_f();

	con_suppress = old_con_suppress;

	// we need done something like for map reloading, for example reload textures for brush models
	R_NewMap(true);

	// force all cached models to be loaded, so no short HDD lag then u walk over level and discover new model
	Mod_TouchModels();

	// window may be re-created, so caption need to be forced to update
	CL_UpdateCaption(true);
}
Example #7
0
static void S_Restart_f (void)
{
	Com_DPrintf("Restarting sound system....\n");
	Cache_Flush();
	S_StopAllSounds (true);

	S_Shutdown();
	Com_DPrintf("sound: Shutdown OK\n");

	if (!S_Startup()) {
		snd_initialized = false;
		return;
	}

	ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav");
	ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav");

	S_StopAllSounds (true);

	if (developer.value)
		S_SoundInfo_f();
}
Example #8
0
APTR Cache_GetBlock(APTR cache, ULONG blockNum, UBYTE **data)
{
    struct Cache *c = cache;
    struct BlockRange *b = NULL, *b2;
    LONG error = 0, data_offset;
    struct MinList *l =
        &c->hash_table[(blockNum >> RANGE_SHIFT) & (c->hash_size - 1)];
    struct MinNode *n;

    /* Change block number to the start block of a range and get byte offset
     * within range */

    data_offset = (blockNum - (blockNum & ~RANGE_MASK)) * c->block_size;
    blockNum &= ~RANGE_MASK;

    /* Check existing valid blocks first */

    ForeachNode(l, b2)
    {
        if(b2->num == blockNum)
            b = b2;
    }

    if(b != NULL)
    {
        /* Block found, so increment its usage count and remove it from the
         * free list */

        if(b->use_count++ == 0)
        {
            if(b->state != BS_DIRTY)
                Remove((struct Node *)&b->node2);
        }
    }
    else
    {
        /* Get a free buffer to read block from disk */

        n = (struct MinNode *)RemHead((struct List *)&c->free_list);
        if(n == NULL)
        {
            /* No free blocks, so flush dirty list to try and free up some
             * more blocks, then try again */

            Cache_Flush(c);

            n = (struct MinNode *)RemHead((struct List *)&c->free_list);
        }

        if(n != NULL)
        {
            b = (struct BlockRange *)NODE2(n);

            /* Read the block from disk */

            if(AccessDisk(FALSE, blockNum, RANGE_SIZE, c->block_size,
                b->data, c->priv) == 0)
            {
                /* Remove block from its old position in the hash */

                if(b->state == BS_VALID)
                    Remove((struct Node *)b);

                /* Add it to the hash at the new location */

                AddHead((struct List *)l, (struct Node *)&b->node1);
                b->num = blockNum;
                b->state = BS_VALID;
                b->use_count = 1;
            }
            else
            {
                /* Read failed, so put the block back on the free list */

                b->state = BS_EMPTY;
                AddHead((struct List *)&c->free_list,
                    (struct Node *)&b->node2);
                b = NULL;
                error = ERROR_UNKNOWN;
            }
        }
        else
            error = ERROR_NO_FREE_STORE;
    }

    /* Set data pointer and error, and return cache block handle */

    *data = b ? (b->data + data_offset) : NULL;
    SetIoErr(error);

    return b;
}
Example #9
0
/*
==================
Host_Game_f
==================
*/
void Host_Game_f (void)
{
	int i;
	unsigned int path_id;
	searchpath_t *search = com_searchpaths;
	pack_t *pak;
	char   pakfile[MAX_OSPATH]; //FIXME: it's confusing to use this string for two different things

	if (Cmd_Argc() > 1)
	{
		if (!registered.value) //disable command for shareware quake
		{
			Con_Printf("You must have the registered version to use modified games\n");
			return;
		}

		if (strstr(Cmd_Argv(1), ".."))
		{
			Con_Printf ("Relative pathnames are not allowed.\n");
			return;
		}

		q_strlcpy (pakfile, va("%s/%s", host_parms->basedir, Cmd_Argv(1)), sizeof(pakfile));
		if (!Q_strcasecmp(pakfile, com_gamedir)) //no change
		{
			Con_Printf("\"game\" is already \"%s\"\n", COM_SkipPath(com_gamedir));
			return;
		}

		com_modified = true;

		//Kill the server
		CL_Disconnect ();
		Host_ShutdownServer(true);

		//Write config file
		Host_WriteConfiguration ();

		//Kill the extra game if it is loaded
		if (NumGames(com_searchpaths) > 1 + com_nummissionpacks)
			KillGameDir(com_searchpaths);

		q_strlcpy (com_gamedir, pakfile, sizeof(com_gamedir));

		if (Q_strcasecmp(Cmd_Argv(1), GAMENAME)) //game is not id1
		{
			// assign a path_id to this game directory
			if (com_searchpaths)
				path_id = com_searchpaths->path_id << 1;
			else	path_id = 1U;
			search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t));
			search->path_id = path_id;
			q_strlcpy (search->filename, pakfile, sizeof(search->filename));
			search->next = com_searchpaths;
			com_searchpaths = search;

			//Load the paks if any are found:
			for (i = 0; ; i++)
			{
				q_snprintf (pakfile, sizeof(pakfile), "%s/pak%i.pak", com_gamedir, i);
				pak = COM_LoadPackFile (pakfile);
				if (!pak)
					break;
				search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t));
				search->path_id = path_id;
				search->pack = pak;
				search->next = com_searchpaths;
				com_searchpaths = search;
			}
		}

		//clear out and reload appropriate data
		Cache_Flush ();
		if (!isDedicated)
		{
			TexMgr_NewGame ();
			Draw_NewGame ();
			R_NewGame ();
		}
		ExtraMaps_NewGame ();
		//Cbuf_InsertText ("exec quake.rc\n");

		Con_Printf("\"game\" changed to \"%s\"\n", COM_SkipPath(com_gamedir));
	}
	else //Diplay the current gamedir
		Con_Printf("\"game\" is \"%s\"\n", COM_SkipPath(com_gamedir));
}