Esempio n. 1
0
static int __tcpnode_push_and_send(struct nd_tcp_node *node, void *msg_buf, size_t datalen, int is_write_all)
{
	ENTER_FUNC();
	signed int ret =0;
	
	nd_netbuf_t *pbuf = &(node->send_buffer);
	size_t length_in_buff = ndlbuf_datalen(pbuf);

	if (length_in_buff) {
		int flushlen = node->sock_write((nd_handle)node, ndlbuf_data(pbuf), length_in_buff);
		if (flushlen > 0) {
			nd_assert(flushlen <= length_in_buff);
			ndlbuf_sub_data(pbuf, (size_t)flushlen);
		}
		length_in_buff = ndlbuf_datalen(pbuf);

	}
	if (length_in_buff == 0) {
		ret = __tcpnode_send_with_save(node, msg_buf, datalen);
	}
	else {
		size_t space_len = ndlbuf_free_capacity(pbuf);
		if(is_write_all && space_len < datalen) {
			node->myerrno = NDERR_WOULD_BLOCK;
			ret = -1;
		}
		else {
			ret = ndlbuf_write(pbuf, (void*)msg_buf, datalen, EBUF_SPECIFIED);
		}
	}
	LEAVE_FUNC();
	return ret ;
}
Esempio n. 2
0
void foo(void)
{
  ENTER_FUNC();
  static int z = 350;
  int q = 450;

  if (!kitsune_is_updating()) {
    y = 202;
    z = 302;
    q = 402;
  }

  NOTE_AND_MIGRATE_STATIC(y);
  NOTE_AND_MIGRATE_LOCAL_STATIC(foo, z);
  NOTE_AND_MIGRATE_LOCAL(q);

  if (kitsune_is_updating()) {
    assert(y == 207);
    assert(z == 307);
    assert(q == 407);
    printf("Sucesss...\n");
  }

  kitsune_update("test");
  EXIT_FUNC();
  return;
}
Esempio n. 3
0
//send data ,and save the left data
static int __tcpnode_send_with_save(struct nd_tcp_node *node, void *msg_buf, size_t datalen)
{
	ENTER_FUNC() ;
	int ret = node->sock_write((nd_handle)node,msg_buf,datalen) ;
	if(-1==ret ) {
		if(node->sys_error!=ESOCKETTIMEOUT){
			LEAVE_FUNC();
			return -1 ;
		}
		else {
			ret = ndlbuf_write(&(node->send_buffer),(void*)msg_buf,datalen,EBUF_SPECIFIED) ;
			if(ret == datalen) {
				node->myerrno = NDERR_SUCCESS ;
			}
		}
	}
	else if(ret==datalen) {
		LEAVE_FUNC();
		return (int)datalen ;
	}
	else {
		int wlen ;
		char *padd = (char*) msg_buf ;
		padd += ret ;
		wlen = ndlbuf_write(&(node->send_buffer),padd,datalen-ret,EBUF_SPECIFIED) ;
		if (wlen > 0) {
			ret = wlen + ret;
		}
	}
	LEAVE_FUNC();
	return ret ;
}
Esempio n. 4
0
/* install message handle*/
int nd_msgentry_install(nd_netui_handle handle, nd_usermsg_func func, ndmsgid_t maxid, ndmsgid_t minid,int level, const char *name) 
{
	struct nd_msg_entry_node * node ;
	int ret = -1;
	ENTER_FUNC() ;
	
	node = _nd_msgentry_get_node(handle,   maxid,  minid) ;
	if (node) {	
		if (node->is_script && node->entry)	{
			free(node->entry);
		}
		node->entry = func ;
		node->level = level ;
		node->is_script = 0;
#if 1
		if (name && name[0]) {
			int len = (int)ndstrlen(name) + 1;
			if (len > (int) sizeof(node->name)) {
				len = sizeof(node->name);
			}
			ndstrncpy(node->name, name, len);
		}
#endif
		ret = 0 ;
	}
	else {
		nd_object_seterror(handle, NDERR_NOSOURCE) ;
	}
	
	LEAVE_FUNC();	
	return  ret ;

}
static int android_close(URLContext *h)
{
    ENTER_FUNC();
    FFSource* ffs = (FFSource*)h->priv_data;
    delete ffs;
    return 0;
}
Esempio n. 6
0
//connect remote host
int nd_tcpnode_connect(const char *host, int port, struct nd_tcp_node *node, struct nd_proxy_info *proxy)
{
	ENTER_FUNC()
		nd_assert(node);
	nd_assert(host);

	node->sys_error = 0;
	node->last_push = nd_time();
	ndlbuf_reset(&(node->recv_buffer));		/* buffer store data recv from net */
	ndlbuf_reset(&(node->send_buffer));		/* buffer store data send from net */

	if (proxy && proxy->proxy_type != ND_PROXY_NOPROXY) {
		node->fd = nd_proxy_connect(host, port, &(node->remote_addr), proxy, 0);
	}
	else {
		node->fd = nd_socket_tcp_connect(host, (short)port, &(node->remote_addr));
	}

	if (node->fd <= 0) {
		node->myerrno = NDERR_OPENFILE;
		LEAVE_FUNC();
		return -1;
	}
	TCPNODE_SET_OK(node);
	nd_socket_nonblock(node->fd, 1);
	_set_ndtcp_conn_dft_option(node->fd);
	node->start_time = nd_time();
	if (node->remote_addr.sin_family == AF_INET6) {
		node->is_ipv6 = 1;
	}
	LEAVE_FUNC();
	return 0;
}
Esempio n. 7
0
//#include "nd_crypt/nd_crypt.h"
int _sys_socket_write(struct nd_tcp_node *node,void *data , size_t len)
{
	ENTER_FUNC();
	int ret ;
	ret = (int) send(node->fd, data, len, 0) ;
	if(ret > 0) {
		//char md5[33];
		//ndfprintf(stderr, "!!!!!----- send data %d, return length =%d md5 = %s\n", len, ret, MD5Crypt32(data, ret, md5));

		node->send_len += ret;
		node->last_push = nd_time();
	}
	else if(-1==ret)  {
		node->sys_error = nd_socket_last_error() ;
		if (node->sys_error == ESOCKETTIMEOUT) {
			node->myerrno = NDERR_WOULD_BLOCK;
		}
		else {
			node->myerrno = NDERR_IO ;
		}
	}
	else if(ret == 0 ) {
		node->myerrno = NDERR_WOULD_BLOCK;
	}
	LEAVE_FUNC();
	return ret ;
};
int FFMPEGRegisterProtocol()
{
    ENTER_FUNC();
    if(hasRegistered) return 0;
    hasRegistered = 1;

    av_log_set_callback(log_callback);
    ffurl_register_protocol(&ff_android_protocol,sizeof(URLProtocol));
    return 0;
}
Esempio n. 9
0
void Task2(void *arg)
{
	//printf("parameter: %d\n", *(int*)arg);
	int i=50;
	ENTER_FUNC();
	while (i--) {
		printf("This is %s\n", FUNC_NAME);
		SLEEP(2);
	}
	EXIT_FUNC();
}
Esempio n. 10
0
int nd_msgentry_is_handled(nd_handle handle, ndmsgid_t maxid, ndmsgid_t minid)
{
	struct nd_msg_entry_node * node;
	ENTER_FUNC();

	node = _nd_msgentry_get_node(handle, maxid, minid);
	LEAVE_FUNC();
	if (!node)	{
		return 0;
	}
	
	return  node->entry ? 1:0;
}
Esempio n. 11
0
const char * nd_msgentry_get_name(nd_netui_handle handle, ndmsgid_t maxid, ndmsgid_t minid)
{
#if 1
	struct nd_msg_entry_node * node ;
	ENTER_FUNC() ;
	
	node = _nd_msgentry_get_node(handle,   maxid,  minid) ;
	LEAVE_FUNC();
	
	return node ? node->name : NULL;
#else
	return NULL ;
#endif
}
Esempio n. 12
0
nd_usermsg_func nd_msgentry_get_func(nd_netui_handle handle, ndmsgid_t maxid, ndmsgid_t minid)
{
	struct nd_msg_entry_node * node ;
	ENTER_FUNC() ;
	
	node = _nd_msgentry_get_node(handle,   maxid,  minid) ;
	LEAVE_FUNC();
	if (!node)	{
		return NULL;
	}
	if (node->is_script)	{
		return NULL;
	}
	
	return  node->entry ;
}
Esempio n. 13
0
int nd_tcpnode_close(struct nd_tcp_node *node, int force)
{
	ENTER_FUNC()
		//nd_assert(0);
		nd_assert(node);
	node->status = ETS_DEAD;
	if (node->fd == 0) {
		LEAVE_FUNC();
		return 0;
	}
	nd_socket_close(node->fd);
	node->fd = 0;

	LEAVE_FUNC();
	return 0;
}
Esempio n. 14
0
//***********************************************************************************
//	PiceKbdIsr - keyboard isr hook routine.
//	IsrContext - context that we passed to keyboard driver in  internal iocontrol
//	pCurrentInput, pCurrentOutput - not implemented yet
//	StatusByte -  keyboard status register
//	pByte - pointer to the byte read from keyboard data port. can be changed.
//	pContinueProcessing - should keyboard driver continue processing this byte.
//***********************************************************************************
BOOLEAN PiceKbdIsr (
    PVOID                   IsrContext,
    PKEYBOARD_INPUT_DATA    pCurrentInput,
    POUTPUT_PACKET          pCurrentOutput,
    UCHAR                   StatusByte,
    PUCHAR                  pByte,
    PBOOLEAN                pContinueProcessing,
    PKEYBOARD_SCAN_STATE    pScanState
    )
{
	static BOOLEAN bControl = FALSE;
	BOOLEAN bForward=TRUE;              // should we let keyboard driver process this keystroke
	BOOLEAN isDown=!(*pByte & 0x80);
	UCHAR ucKey = *pByte & 0x7f;

    ENTER_FUNC();

	// BUG?? should protect with spinlock since bControl is static.
    DPRINT((0,"PiceKbdIsr(pByte: %x, val: %x,%u)\n",pByte,*pByte,isDown));
    DPRINT((0,"PiceKbdIsr(1): bControl = %u bForward = %u bEnterNow = %u\n",bControl,bForward,bEnterNow));

	if(isDown)
	{
		DPRINT((0,"bControl: %x, ucKey: %x, breakkey: %x\n", bControl, ucKey, AsciiToScan(ucBreakKey)));
		// CTRL pressed
		if(ucKey==0x1d)
		{
			bControl=TRUE;
		}
		else if(bControl==TRUE && ucKey==AsciiToScan(ucBreakKey)) // CTRL-D
		{
            // fake a CTRL-D release call
            bEnterNow=TRUE;
			bControl=FALSE;
        // simulate an initial break
        __asm__("\n\t \
            pushfl\n\t \
            pushl %cs\n\t \
            pushl $returnpoint\n\t \
            pushl $" STR(REASON_CTRLF) "\n\t \
            jmp NewInt31Handler\n\t \
			returnpoint:");
			*pByte =  0x1d | 0x80 | 0x7f;
			bForward=TRUE;
		}
        else if((ucKey == 66|| ucKey == 68) && bStepping)
Esempio n. 15
0
void interp_string(char *str) {
	bsinterp_state state = bsst_none;
	bsinterp_state new_state;
	char c;
	ENTER_FUNC();
	while ((c = *(str++)) != 0) {
		switch (c) {
			case '(':
				new_state = bsst_open_list;
				break;
			case ')':
				new_state = bsst_close_list;
				break;
			case ' ':
			case '\t':
				new_state = bsst_space;
				break;
			case '\n':
				new_state = bsst_new_line;
				break;
			case '0' ... '9':
			case 'A' ... 'Z':
			case 'a' ... 'z':
			case '-':
			case '_':
			case '+':
			case '*':
			case '.':
			case '/':
				new_state = bsst_lexem;
				break;
			default:
				new_state = bsst_none;
				break;
		}
        if (state != new_state) {

        }
	}
	LEAVE_FUNC();
}
Esempio n. 16
0
int nd_msgentry_script_install(nd_handle handle, const char*script, ndmsgid_t maxid, ndmsgid_t minid, int level)
{
	struct nd_msg_entry_node * node;
	int ret = -1;
	ENTER_FUNC();
	node = _nd_msgentry_get_node(handle, maxid, minid);
	if (script && script[0] && node) {
		int len = (int)ndstrlen(script) + 1;
		if (node->is_script && node->entry)	{
			free(node->entry);
		}
		node->entry = (nd_usermsg_func)malloc(len);
		ndstrncpy((char*)node->entry, script, len);
		node->level = level;
		node->is_script = 1;
		ret = 0;
	}
	else {
		nd_object_seterror(handle, NDERR_NOSOURCE);
	}

	LEAVE_FUNC();
	return  ret;
}
Esempio n. 17
0
File: init.c Progetto: GYGit/reactos
//*************************************************************************
// InitPICE()
//
//*************************************************************************
BOOLEAN InitPICE(void)
{
    ULONG ulHandleScancode=0,ulHandleKbdEvent=0;
	ARGS Args;
    KIRQL Dirql;
    KAFFINITY Affinity;
	ULONG ulAddr;

    ENTER_FUNC();

	DPRINT((0,"InitPICE(): trace step 0.5\n"));
    KeyboardIRQL = HalGetInterruptVector(Internal,
				     0,
				     0,
				     KEYBOARD_IRQ,
				     &Dirql,
				     &Affinity);
	DPRINT((0,"KeyboardIRQL: %x\n", KeyboardIRQL));

    DPRINT((0,"InitPICE(): trace step 1\n"));
    // enable monochrome passthrough on BX type chipset
    EnablePassThrough();

    DPRINT((0,"InitPICE(): trace step 2\n"));
    // now load all symbol files described in /etc/pice.conf
    if(!LoadSymbolsFromConfig(FALSE))
    {
        DPRINT((0,"InitPICE: LoadSymbolsFromConfig() failed\n"));
        LEAVE_FUNC();
        return FALSE;
    }

    DPRINT((0,"InitPICE(): trace step 3\n"));
    // init the output console
	// this might be one of the following depending setup
	// a) monochrome card
	// b) serial terminal (TODO)
    if(!ConsoleInit())
    {
        DPRINT((0,"InitPICE: ConsoleInit() failed\n"));
        UnloadSymbols();
        LEAVE_FUNC();
        return FALSE;
    }

    DPRINT((0,"InitPICE(): trace step 4\n"));
    // print the initial screen template
    PrintTemplate();
/*
    DPRINT((0,"InitPICE(): trace step 5\n"));
	// ask the user if he wants to abort the debugger load
    if(!CheckLoadAbort())
	{
		Print(OUTPUT_WINDOW,"pICE: ABORT (abort by user)\n");
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
	}
*/

    DPRINT((0,"InitPICE(): trace step 6\n"));
    // load the file /boot/System.map.
    // !!! It must be consistent with the current kernel at all cost!!!
    if(!LoadExports())
    {
		Print(OUTPUT_WINDOW,"pICE: failed to load exports\n");
        Print(OUTPUT_WINDOW,"press any key to continue...\n");
        while(!GetKeyPolled());
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
    }

    DPRINT((0,"InitPICE(): trace step 7\n"));
	ScanExports("_KernelAddressSpace", &ulAddr);
	my_init_mm = (PMADDRESS_SPACE) ulAddr;
	DPRINT((0,"init_mm %x @ %x\n",&my_init_mm,my_init_mm));
	if(!my_init_mm)
	{
		Print(OUTPUT_WINDOW,"pICE: ABORT (initial memory map not found)\n");
		Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
		DbgPrint("pICE: ABORT (initial memory map not found)\n");
		DbgPrint("pICE: press any key to continue...\n");
        while(!GetKeyPolled());
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
	}

	DPRINT((0,"InitPICE(): trace step 7.1\n"));
	ScanExports("_ModuleListHead",&ulAddr);
	pModuleListHead = (LIST_ENTRY*)ulAddr;
    DPRINT((0,"pModuleListHead @ %X\n",pModuleListHead));
	if(!pModuleListHead)
	{
		Print(OUTPUT_WINDOW,"pICE: ABORT (pModuleListHead not found)\n");
		Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
        while(!GetKeyPolled());
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
	}

	DPRINT((0,"InitPICE(): trace step 7.2\n"));
	ScanExports("_PsProcessListHead",&ulAddr);
	pPsProcessListHead = (LIST_ENTRY*)ulAddr;
    DPRINT((0,"pPsProcessListHead @ %X\n",pPsProcessListHead));
	if(!pPsProcessListHead)
	{
		Print(OUTPUT_WINDOW,"pICE: ABORT (PsProcessListHead not found)\n");
		Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
        while(!GetKeyPolled());
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
	}

    DPRINT((0,"InitPICE(): trace step 8\n"));
    // end of the kernel
	/*
	ScanExports("_end",(PULONG)&kernel_end);
    if(!kernel_end)
	{
		Print(OUTPUT_WINDOW,"pICE: ABORT (kernel size is unknown)\n");
		Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
        while(!GetKeyPolled());
		UnloadExports();
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
	}
	*/

    DPRINT((0,"InitPICE(): trace step 9\n"));

	// the loaded module list
	ScanExports("_NameSpaceRoot", &ulAddr);
	pNameSpaceRoot = (PDIRECTORY_OBJECT *)ulAddr;
	DPRINT((0,"pNameSpaceRoot @ %X\n",pNameSpaceRoot));
    if(!pNameSpaceRoot)
	{
		Print(OUTPUT_WINDOW,"pICE: ABORT (couldn't retreive name space root)\n");
		Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
        while(!GetKeyPolled());
		UnloadExports();
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
	}

    DPRINT((0,"InitPICE(): trace step 10\n"));
    // setup a linked list for use in module parsing routines.
	if(!InitModuleList(&pdebug_module_head, 100))
	{
		Print(OUTPUT_WINDOW,"pICE: ABORT (couldn't initialize kernel module list)\n");
		Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
		FreeModuleList( pdebug_module_head );
        while(!GetKeyPolled());
		UnloadExports();
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
	}
	pdebug_module_tail = pdebug_module_head;

    DPRINT((0,"InitPICE(): trace step 11\n"));
    // do a sanity check on exports
    if(!SanityCheckExports())
    {
		Print(OUTPUT_WINDOW,"pICE: ABORT (exports are conflicting with kernel symbols)\n");
		Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
        while(!GetKeyPolled());
		UnloadExports();
        UnloadSymbols();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
    }

    DPRINT((0,"InitPICE(): trace step 12\n"));


    DPRINT((0,"InitPICE(): trace step 13\n"));
    // patch the keyboard driver

	if(!PatchKeyboardDriver())
	{
		Print(OUTPUT_WINDOW,"pICE: ABORT (couldn't patch keyboard driver)\n");
		Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
        while(!GetKeyPolled());
		UnloadSymbols();
		UnloadExports();
		ConsoleShutdown();
        LEAVE_FUNC();
		return FALSE;
	}

    DPRINT((0,"InitPICE(): trace step 14\n"));
    // partial init of shadow registers
    CurrentCS = GLOBAL_CODE_SEGMENT;
    CurrentEIP = (ULONG)RealIsr;

    CurrentDS = CurrentSS = GLOBAL_DATA_SEGMENT;
    __asm__("\n\t \
            mov %%esp,%%eax\n\t \
            mov %%eax,_CurrentESP\n\t \
            ":::"eax");


    // display version and symbol information
    Ver(NULL);

    // disable HW breakpoints
	__asm__("\n\t \
		xorl %%eax,%%eax\n\t \
		mov %%eax,%%dr6\n\t \
		mov %%eax,%%dr7\n\t \
        mov %%dr0,%%eax\n\t \
        mov %%dr1,%%eax\n\t \
        mov %%dr2,%%eax\n\t \
        mov %%dr3,%%eax"
		:::"eax"
		);

    DPRINT((0,"InitPICE(): trace step 15\n"));
    TakeIdtSnapshot();

    DPRINT((0,"InitPICE(): trace step 16\n"));
    // install all hooks
    InstallTraceHook();
    InstallGlobalKeyboardHook();
    InstallSyscallHook();
    InstallInt3Hook();
    InstallDblFltHook();
    InstallGPFaultHook();
    InstallIntEHook();
    InstallPrintkHook();

    DPRINT((0,"InitPICE(): trace step 16\n"));
    if(ulDoInitialBreak)
    {
        DPRINT((0,"about to do initial break...\n"));

        // simulate an initial break
        __asm__("\n\t \
            pushfl\n\t \
            pushl %cs\n\t \
            pushl $initialreturnpoint\n\t \
            pushl $" STR(REASON_CTRLF) "\n\t \
            jmp NewInt31Handler\n\t \
initialreturnpoint:");
    }
    else
    {
Esempio n. 18
0
static int golden_test_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos)
{
	char *buf = _copy_from_user_for_proc(buffer, count);
	char cmd[64];
	unsigned int addr;
	unsigned int mask;
	unsigned int golden_val;

	ENTER_FUNC(FUNC_LV_BODY);

	// set golden setting (hex mode)
	if (sscanf(buf, "0x%x 0x%x 0x%x", &addr, &mask, &golden_val) == 3)
		_golden_setting_add(&_golden, addr, mask, golden_val);
	// set golden setting (dec mode)
	else if (sscanf(buf, "%d %d %d", &addr, &mask, &golden_val) == 3)
		_golden_setting_add(&_golden, addr, mask, golden_val);
	// set filter (func + line)
	else if (sscanf(buf, "filter %63s %d", _golden.func, &_golden.line) == 2) { // XXX: 63 = sizeof(_golden.func) - 1
	}
	// set filter (func)
	else if (sscanf(buf, "filter %63s", _golden.func) == 1) // XXX: 63 = sizeof(_golden.func) - 1
		_golden.line = 0;
	// set golden setting (mixed mode)
	else if (sscanf(buf, "0x%x 0b%63s", &addr, cmd) == 2) { // XXX: 63 = sizeof(cmd) - 1
		if (!_parse_mask_val(cmd, &mask, &golden_val))
			_golden_setting_add(&_golden, addr, mask, golden_val);
	}
	// set reg value (mask mode)
	else if (sscanf(buf, "set 0x%x 0x%x 0x%x", &addr, &mask, &golden_val) == 3)
		_golden_write_reg(addr, mask, golden_val);
	// set reg value (bit mode)
	else if (sscanf(buf, "set 0x%x %d %d", &addr, &mask, &golden_val) == 3) {
		if (0 <= mask && mask <= 31) { // XXX: mask is bit number (alias)
			golden_val = (golden_val & BIT(0)) << mask;
			mask = BIT(0) << mask;
			_golden_write_reg(addr, mask, golden_val);
		}
	}
	// set reg value (normal mode)
	else if (sscanf(buf, "set 0x%x 0x%x", &addr, &golden_val) == 2)
		_golden_write_reg(addr, 0xFFFFFFFF, golden_val);
	else if (sscanf(buf, "%63s", cmd) == 1) { // XXX: 63 = sizeof(cmd) - 1
		if (!strcmp(cmd, "enable"))
			_golden_setting_enable(&_golden);
		else if (!strcmp(cmd, "disable"))
			_golden_setting_disable(&_golden);
		else if (!strcmp(cmd, "normal"))
			_golden_setting_set_mode(&_golden, MODE_NORMAL);
		else if (!strcmp(cmd, "compare"))
			_golden_setting_set_mode(&_golden, MODE_COMPARE);
		else if (!strcmp(cmd, "apply"))
			_golden_setting_set_mode(&_golden, MODE_APPLY);
		else if (!strcmp(cmd, "color"))
			_golden_setting_set_mode(&_golden, MODE_COLOR);
		else if (!strcmp(cmd, "diff"))
			_golden_setting_set_mode(&_golden, MODE_DIFF);
		else if (!strcmp(cmd, "filter"))
			_golden.func[0] = '\0';
	}

	free_page((size_t)buf);
	EXIT_FUNC(FUNC_LV_BODY);
	return count;
}
Esempio n. 19
0
static int golden_test_proc_show(struct seq_file *m, void *v)
{
	static int buf_golden_setting_idx = 0;
	// static off_t page_len = 0;
	// static off_t used_off = 0;

	// char *start_p;
	// int len = 0;
	int i = 0;

	ENTER_FUNC(FUNC_LV_BODY);

	if (1) { // (0 == off) {
		buf_golden_setting_idx = 0;
		// page_len = 0;
		// used_off = 0;
	}

	if (1) { // (0 == page_len) {
		if (FALSE == _golden.is_golden_log) {
			if (1) { // (0 == off) {
				for (i = 0; i < _golden.nr_golden_setting; i++) {
					seq_printf(m, ""HEX_FMT" "HEX_FMT" "HEX_FMT"\n",
						   _golden.buf_golden_setting[i].addr,
						   _golden.buf_golden_setting[i].mask,
						   _golden.buf_golden_setting[i].golden_val
						  );
				}
			}
		}

		if (0 == _golden.nr_golden_setting) {
			if (1) { // (0 == off) {
				seq_printf(m, "\n********** golden_test help *********\n");
				seq_printf(m, "1.   disable snapshot:                  echo disable > /proc/clkmgr/golden_test\n");
				seq_printf(m, "2.   insert golden setting (tool mode): echo 0x10000000 (addr) 0bxxxx_xxxx_xxxx_xxxx_0001_0100_1001_0100 (mask & golden value) > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(2.) insert golden setting (hex mode):  echo 0x10000000 (addr) 0xFFFF (mask) 0x1494 (golden value) > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(2.) insert golden setting (dec mode):  echo 268435456 (addr) 65535 (mask) 5268 (golden value) > /proc/clkmgr/golden_test\n");
				seq_printf(m, "3.   set filter:                        echo filter func_name [line_num] > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(3.) disable filter:                    echo filter > /proc/clkmgr/golden_test\n");
				seq_printf(m, "4.   enable snapshot:                   echo enable > /proc/clkmgr/golden_test\n");
				seq_printf(m, "5.   set compare mode:                  echo compare > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(5.) set apply mode:                    echo apply > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(5.) set color mode:                    echo color > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(5.) set diff mode:                     echo color > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(5.) disable compare/apply/color mode:  echo normal > /proc/clkmgr/golden_test\n");
				seq_printf(m, "6.   set register value (normal mode):  echo set 0x10000000 (addr) 0x13201494 (reg val) > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(6.) set register value (mask mode):    echo set 0x10000000 (addr) 0xffff (mask) 0x13201494 (reg val) > /proc/clkmgr/golden_test\n");
				seq_printf(m, "(6.) set register value (bit mode):     echo set 0x10000000 (addr) 0 (bit num) 1 (reg val) > /proc/clkmgr/golden_test\n");
			}
		} else {
			static struct snapshot *snapshot;

			if (0 == 0 // off    // buf_golden_setting_idx
			    && !strcmp(_golden.func, __FUNCTION__) && (_golden.line == 0)) {
				snapshot_golden_setting(__FUNCTION__, 0);
			}

			while ((0 != buf_golden_setting_idx) || (NULL != (snapshot = _snapshot_consume(&_golden)))) {
				if (0 == buf_golden_setting_idx) {
					seq_printf(m, "// @ %s():%d\n", snapshot->func, snapshot->line);
					pr_debug("// @ %s():%d\n", snapshot->func, snapshot->line);
				}


				// start_p = p;

				for (i = buf_golden_setting_idx, buf_golden_setting_idx = 0; i < _golden.nr_golden_setting; i++) {
					// start_p = p;

					if (MODE_NORMAL == _golden.mode
					    || ((_golden.buf_golden_setting[i].mask & _golden.buf_golden_setting[i].golden_val)
						!= (_golden.buf_golden_setting[i].mask & snapshot->reg_val[i])
					       )
					   ) {
						if (MODE_COLOR == _golden.mode) {
							seq_printf(m, HEX_FMT"\t"HEX_FMT"\t"HEX_FMT"\t%s\n",
								   _golden.buf_golden_setting[i].addr,
								   _golden.buf_golden_setting[i].mask,
								   snapshot->reg_val[i],
								   _gen_color_str(_golden.buf_golden_setting[i].mask, _golden.buf_golden_setting[i].golden_val, snapshot->reg_val[i])
								  );
							pr_debug(HEX_FMT"\t"HEX_FMT"\t"HEX_FMT"\t%s\n",
								   _golden.buf_golden_setting[i].addr,
								   _golden.buf_golden_setting[i].mask,
								   snapshot->reg_val[i],
								   _gen_color_str(_golden.buf_golden_setting[i].mask, _golden.buf_golden_setting[i].golden_val, snapshot->reg_val[i])
								  );
						} else if (MODE_DIFF == _golden.mode) {
							seq_printf(m, HEX_FMT"\t"HEX_FMT"\t"HEX_FMT"\t%s\n",
								   _golden.buf_golden_setting[i].addr,
								   _golden.buf_golden_setting[i].mask,
								   snapshot->reg_val[i],
								   _gen_mask_str(_golden.buf_golden_setting[i].mask, snapshot->reg_val[i])
								  );
							pr_debug(HEX_FMT"\t"HEX_FMT"\t"HEX_FMT"\t%s\n",
								   _golden.buf_golden_setting[i].addr,
								   _golden.buf_golden_setting[i].mask,
								   snapshot->reg_val[i],
								   _gen_mask_str(_golden.buf_golden_setting[i].mask, snapshot->reg_val[i])
								  );

							seq_printf(m, HEX_FMT"\t"HEX_FMT"\t"HEX_FMT"\t%s\n",
								   _golden.buf_golden_setting[i].addr,
								   _golden.buf_golden_setting[i].mask,
								   _golden.buf_golden_setting[i].golden_val,
								   _gen_diff_str(_golden.buf_golden_setting[i].mask, _golden.buf_golden_setting[i].golden_val, snapshot->reg_val[i])
								  );
							pr_debug(HEX_FMT"\t"HEX_FMT"\t"HEX_FMT"\t%s\n",
								   _golden.buf_golden_setting[i].addr,
								   _golden.buf_golden_setting[i].mask,
								   _golden.buf_golden_setting[i].golden_val,
								   _gen_diff_str(_golden.buf_golden_setting[i].mask, _golden.buf_golden_setting[i].golden_val, snapshot->reg_val[i])
								  );
						} else
							seq_printf(m, HEX_FMT"\t"HEX_FMT"\t"HEX_FMT"\n", _golden.buf_golden_setting[i].addr, _golden.buf_golden_setting[i].mask, snapshot->reg_val[i]);
							pr_debug(HEX_FMT"\t"HEX_FMT"\t"HEX_FMT"\n", _golden.buf_golden_setting[i].addr, _golden.buf_golden_setting[i].mask, snapshot->reg_val[i]);
						}

					if (0) { // ((p - start_p) + (p - page) >= PAGE_SIZE) {
						buf_golden_setting_idx = i + 1;
						break;
					}
				}

				if (0) // ((p - start_p) + (p - page) >= PAGE_SIZE)
					break;
			}
		}

		// page_len = p - page;
	} else {
		// p = page + page_len;
	}

#if 0
	*start = page + (off - used_off);

	len = p - page;

	if (len > (off - used_off))
		len -= (off - used_off);
	else {
		len = 0;
		used_off += page_len;
		page_len = 0;
	}

	*eof = (0 == buf_golden_setting_idx && 0 == len) ? 1 : 0;
#endif
	EXIT_FUNC(FUNC_LV_BODY);

	return 0; // len < count ? len : count;
}
Esempio n. 20
0
//*************************************************************************
// HandleInDebuggerFault()
//
//*************************************************************************
ULONG HandleInDebuggerFault(FRAME* ptr,ULONG address)
{
	PEPROCESS tsk;

    ENTER_FUNC();

	DPRINT((0,"HandleInDebuggerFault(): ###### page fault @ %.8X while inside debugger, eip: %x\n",address, ptr->eip));

	// fault in this page fault handler
	if(bInPageFaultHandler)
	{
    	DPRINT((0,"HandleInDebuggerFault(): ###### page fault @ %.8X while in page fault handler\n",address));

        DPRINT((0,"!!! machine is halted !!!\n"));
        __asm__ __volatile__ ("hlt");

        LEAVE_FUNC();
		return 0;
	}

	bInPageFaultHandler = TRUE;

    // when we come here from DebuggerShell() we live on a different stack
    // so the current task is different as well
    tsk = IoGetCurrentProcess();

    DPRINT((0,"%.8X (%.4X:%.8X %.8X %s %s %s task=%.8X )\n",
        address,
        ptr->cs,
        ptr->eip,
        ptr->eflags,
        (ptr->error_code&1)?"PLP":"NP",
        (ptr->error_code&2)?"WRITE":"READ",
        (ptr->error_code&4)?"USER-MODE":"KERNEL-MODE",
        (ULONG)tsk));

	if(!bInPrintk)
    {
    	DPRINT((0,"HandleInDebuggerFault(): unexpected pagefault in command handler!\n",address));
    }
	else
    {
    	DPRINT((0,"HandleInDebuggerFault(): unexpected pagefault in command handler while in PrintkCallback()!\n",address));
    }

    if(tsk)
    {
	    PULONG pPGD;
	    PULONG pPTE;

        pPGD = ADDR_TO_PDE(address);

        DPRINT((0,"PGD for %.8X @ %.8X = %.8X\n",address,(ULONG)pPGD,(ULONG)(*pPGD) ));

        if(pPGD && (*pPGD)&_PAGE_PRESENT)
        {
            // not large page
            if(!((*pPGD)&_PAGE_4M))
            {
                pPTE = ADDR_TO_PTE(address);
                if(pPTE)
                {
                    DPRINT((0,"PTE for %.8X @ %.8X = %.8X\n",address,(ULONG)pPTE,(ULONG)(*pPTE) ));
                }
            }
        }
    }

    IntelStackWalk(ptr->eip,CurrentEBP,ulRealStackPtr);

    DPRINT((0,"!!! machine is halted !!!\n"));
    __asm__ __volatile__ ("hlt");

    LEAVE_FUNC();

	return 2;
}
static int android_get_handle(URLContext *h)
{
    ENTER_FUNC();
    return (intptr_t)h->priv_data;
}