예제 #1
0
파일: main.c 프로젝트: effection/ps2rd
static err_t SMapIFInit ( NetIF* pNetIF ) {

 SIF.pNetIF = pNetIF;
 pNetIF -> state      = &NIF;
 pNetIF -> name[ 0 ]  = IFNAME0;
 pNetIF -> name[ 1 ]  = IFNAME1;
 pNetIF -> output     = SMapOutput;
 pNetIF -> linkoutput = SMapLowLevelOutput;
 pNetIF -> hwaddr_len = 6;
 pNetIF -> mtu        = 1500;

 memcpy (  pNetIF -> hwaddr, SMap_GetMACAddress (), 6  );

 SMap_Start ();

 return ERR_OK;

}  /* end SMapIFInit */
예제 #2
0
/*
 * private functions
 */
static void *
_rpc_cmd_handler(u32 command, void *buffer, int size)

{
	u32 *buf = (u32 *)buffer;
	int ret = 0;

	switch (command) {
		case SMAP_CMD_SET_BUFFER: {
			unsigned int offset;

			ee_buffer_size = 0; /* Disable use of ee_buffer in case an interrupt occurs. */
			ee_buffer = buf[0];
			if (buf[1] > 0) {
				/* Align memory offset. */
				offset = DMA_TRANSFER_SIZE - (ee_buffer & (DMA_TRANSFER_SIZE - 1));
				if (offset == DMA_TRANSFER_SIZE) {
					offset = 0;
				}
				ee_buffer = ee_buffer + offset;
				ee_buffer_pos = 0;
				ee_buffer_size = buf[1] - offset;
			}
			buf[1] = (u32)(&soft_regs);
			break;
		}

		case SMAP_CMD_GET_MAC_ADDR: {
			memcpy(&buf[1], SMap_GetMACAddress(), 6);
			break;
		}

		case SMAP_CMD_SET_MAC_ADDR: {
			SMap_SetMacAddress((const char *)buffer);
			break;
		}

		case SMAP_CMD_MDIO_READ: {
			ret = smap_mdio_read(&SMap0, buf[0], buf[1]);
			break;
		}

		case SMAP_CMD_MDIO_WRITE: {
			ret = smap_mdio_write(&SMap0, buf[0], buf[1], buf[2]);
			break;
		}

		case SMAP_CMD_SET_LNK: {
			SMap_SetLink(&SMap0, buf[0], buf[1], buf[2]);
			break;
		}

		default:
			M_ERROR("unknown cmd %lu\n", command);
			ret = -1;
			break;
	}

	buf[0] = ret;

	return buffer;
}