#include "p_apps.h"

#ifdef GUI_WEB

#include "web\web_msg.h"
#include "web\web_const.h"

void _LoadMessage(PCCHAR cHttpMsg, USHORT iLength, UCHAR iSdramLo)
{
	DSHORT i;
	DCHAR j;
	
	for (i = 0, j = 0; i < iLength; i += 256, j ++)
	{
		if ((i + 256) <= iLength)
		{
			p_memcpy_c2x((PXCHAR)Sdram_pDataCache, (PCCHAR)(cHttpMsg+i), (unsigned char)256);
		}
		else 
		{
			p_memcpy_c2x((PXCHAR)Sdram_pDataCache, (PCCHAR)(cHttpMsg+i), (UCHAR)(iLength - i));
		}
		sdram_write(HTTP_SDRAM_HI, (UCHAR)(iSdramLo + j), SRAM_DMA_HALF_DWORD);
	}
}

void HttpLoadMsg()
{
	_LoadMessage(_chttp_page0_msg, HTTP_PAGE0_MSG_LEN, HTTP_PAGE0_SDRAM_LO);
	_LoadMessage(_chttp_page1_msg, HTTP_PAGE1_MSG_LEN, HTTP_PAGE1_SDRAM_LO);
	_LoadMessage(_chttp_page2_msg, HTTP_PAGE2_MSG_LEN, HTTP_PAGE2_SDRAM_LO);
	_LoadMessage(_chttp_page3_msg, HTTP_PAGE3_MSG_LEN, HTTP_PAGE3_SDRAM_LO);
	_LoadMessage(_chttp_page4_msg, HTTP_PAGE4_MSG_LEN, HTTP_PAGE4_SDRAM_LO);
	_LoadMessage(_chttp_page5_msg, HTTP_PAGE5_MSG_LEN, HTTP_PAGE5_SDRAM_LO);
	_LoadMessage(_chttp_page6_msg, HTTP_PAGE6_MSG_LEN, HTTP_PAGE6_SDRAM_LO);
	_LoadMessage(_csettings_head_msg, SETTINGS_HEAD_MSG_LEN, SETTINGS_HEAD_SDRAM_LO);
	_LoadMessage(_csettings_dialplan_msg, SETTINGS_DIALPLAN_MSG_LEN, SETTINGS_DIALPLAN_SDRAM_LO);
	_LoadMessage(_csettings_protocol_msg, SETTINGS_PROTOCOL_MSG_LEN, SETTINGS_PROTOCOL_SDRAM_LO);
	_LoadMessage(_csettings_pa168v_msg, SETTINGS_PA168V_MSG_LEN, SETTINGS_PA168V_SDRAM_LO);
	_LoadMessage(_csettings_phoneonly_msg, SETTINGS_PHONEONLY_MSG_LEN, SETTINGS_PHONEONLY_SDRAM_LO);
	_LoadMessage(_csettings_tail_msg, SETTINGS_TAIL_MSG_LEN, SETTINGS_TAIL_SDRAM_LO);
	_LoadMessage(_cWebImageMsg, WEB_IMAGE_MSG_LEN, WEB_IMAGE_SDRAM_LO);
}

#endif
