Ejemplo n.º 1
0
Archivo: pinfo.c Proyecto: ftnapps/FTNd
/*
 * Product information screen
 */
void cr(void)
{
    char    *temp;

    temp       = calloc(81, sizeof(char));

    if (utf8)
	chartran_init((char *)"CP437", (char *)"UTF-8", 'B');

    strncpy(pstr, clear_str(), 255);
    strncat(pstr, colour_str(DARKGRAY, BLACK), 255);

    /* Print top row */
    strncat(pstr, (char *)"\xDA", 255);
    strncat(pstr, hLine_str(76), 255);
    strncat(pstr, (char *)"\xBF\r\n", 255);
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    snprintf(temp, 80, "FTND Bulletin Board System %s (%s-%s)", VERSION, OsName(), OsCPU());
    strncat(pstr, pout_str(YELLOW, BLACK, padleft(temp, 76, ' ')), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    snprintf(temp, 81, "%s", COPYRIGHT);
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, padleft(temp, 76, ' ')), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    snprintf(temp, 81, "Compiled on %s at %s", __DATE__, __TIME__);
    strncat(pstr, pout_str(LIGHTRED, BLACK, padleft(temp, 76, ' ')), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"FTNd and ftnbbs was originally derived from MBSE BBS."), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"MBSE was written and designed by Michiel Broek. Many others gave "), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"valuable time in the form of new ideas and suggestions on how to make MBSE  "), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"BBS a better BBS, which has also extended to the FTNd development         "), 255);
    rs();
    PUTSTR(chartran(pstr));
    
    wl();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(WHITE, BLACK, (char *)"Available from https://ftn.rocasa.net or 1:120/544                             "), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)"JAM(mbp) - Copyright 1993 Joaquim Homrighausen, Andrew Milner,              "),
 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)"                          Mats Birch, Mats Wallin.                          "), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)"                          ALL RIGHTS RESERVED.                              "), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTBLUE, BLACK,  (char *)"This is free software; released under the terms of the GNU General Public   "), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTBLUE, BLACK,  (char *)"License as published by the Free Software Foundation.                       "), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    strcpy(pstr, (char *)"\xC0");
    strncat(pstr, hLine_str(76), 255);
    strncat(pstr, (char *)"\xD9\r\n", 255);
    PUTSTR(chartran(pstr));

    free(temp);
    chartran_close();
    Enter(1);
    Pause();
}
Ejemplo n.º 2
0
int
mpt_directdownload(mpt_adap_t *adap)
{
	U16						 deviceId = adap->device_id;
	U32						 mask = adap->diagmem_size - 1;
	MpiFwHeader_t			*fwHeader;
	U32						*image;
	U32						 addr;
	U32						 size;
	U32						 data;
	int						 t;

	wl(WRITE_SEQUENCE, MPI_WRSEQ_KEY_VALUE_MASK);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_1ST_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_2ND_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_3RD_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_4TH_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_5TH_KEY_VALUE);

	wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM);
	DELAY(100);

	/*  If FlashBadSig is set, the download doesn't seem to work if we reset
	 *  the chip here.
	 *
	 *  If FlashBadSig isn't set, the download doesn't seem to work if we
	 *  don't reset the chip here.
	 */
	data = rl(DIAGNOSTIC);
	if (!(data & MPI_DIAG_FLASH_BAD_SIG))
	{
		wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM | MPI_DIAG_RESET_ADAPTER);
		DELAY(100);

		wl(WRITE_SEQUENCE, MPI_WRSEQ_KEY_VALUE_MASK);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_1ST_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_2ND_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_3RD_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_4TH_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_5TH_KEY_VALUE);
	}

	wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM | MPI_DIAG_MEM_ENABLE);

	addr = 0x50004;
	rldiag(addr, data);
	data &= ~0x80000000;
	wldiag(addr, data);

	if (deviceId == MPI_MANUFACTPAGE_DEVICEID_FC929)
	{
		addr = 0x51004;
		rldiag(addr, data);
		data &= ~0x80000000;
		wldiag(addr, data);
	}

	if (rl(DIAGNOSTIC) & MPI_DIAG_FLASH_BAD_SIG)
	{
		addr = 0x40000;
		rldiag(addr, data);
		data |= 0x40000000;
		wldiag(addr, data);
	}

	fwHeader = (MpiFwHeader_t *)adap->fw_image;

	image = (U32 *)fwHeader;

	addr = fwHeader->LoadStartAddress;
	size = fwHeader->ImageSize;

	while (size)
	{
		data = *image++;

		wldiag(addr, data);

		addr += 4;
		size -= 4;
	}

	addr = fwHeader->IopResetRegAddr;
	data = fwHeader->IopResetVectorValue;

	wldiag(addr, data);

	addr = 0x40000;
	rldiag(addr, data);
	data |= 0x40000000;
	wldiag(addr, data);

	wl(DIAGNOSTIC, 0);
	DELAY(100);

	t = mpt_wait_for_ready(adap);

	if (wFlag)
		fprintf(logFile, "%s:  Firmware Direct Download:  %s\n",
				adap->name, t ? "PASS" : "FAIL");

	if (t)
		return 1;

	printf("\n%s: DirectDownload failed!\n", adap->name);
	return 0;
}
Ejemplo n.º 3
0
/*
 * mpt_stop - stop the IOC (reset it).
 */
int
mpt_stop(mpt_adap_t *adap, int wait)
{
	time_t	 limit = time(NULL) + 10;

//	printf("mpt_stop called\n");

#if EFI
	if (adap->disconnected == FALSE && wait == TRUE)
	{
		EFI_PCI_IO_PROTOCOL		*pci_io;

		if (adap->loaddevice == TRUE)
		{
			printf("This chip controls the device that this utility was loaded from.\n");
			printf("After this command, the load device cannot be accessed again\n");
			printf("to open files, until this utility has been exited and restarted.\n\n");
		}

		if (!EFI_ERROR(BS->DisconnectController(adap->handle, NULL, NULL)))
		{
			adap->disconnected = TRUE;
			pci_io = adap->pci_io;
			pci_io->Attributes(pci_io, EfiPciIoAttributeOperationEnable,
							   EFI_PCI_IO_ATTRIBUTE_IO |
							   EFI_PCI_IO_ATTRIBUTE_MEMORY |
							   EFI_PCI_IO_ATTRIBUTE_BUS_MASTER |
							   EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE, NULL);
		}

		if (adap->partner_adap)
		{
			if (!EFI_ERROR(BS->DisconnectController(adap->partner_adap->handle, NULL, NULL)))
			{
				adap->partner_adap->disconnected = TRUE;
				pci_io = adap->partner_adap->pci_io;
				pci_io->Attributes(pci_io, EfiPciIoAttributeOperationEnable,
								   EFI_PCI_IO_ATTRIBUTE_IO |
								   EFI_PCI_IO_ATTRIBUTE_MEMORY |
								   EFI_PCI_IO_ATTRIBUTE_BUS_MASTER |
								   EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE, NULL);
			}
		}
	}
#endif

	adap->interrupt_mask = MPI_HIM_RIM | MPI_HIM_DIM;
	wl(HOST_INTERRUPT_MASK, adap->interrupt_mask);

	/*
	 * Reset the chip.
	 */
	if (adap->device_id == MPI_MANUFACTPAGE_DEVICEID_FC909)
	{
		rl(FC909_BUG);    /* work around FC909 bug */
	}

	if (!(rl(DIAGNOSTIC) & MPI_DIAG_DRWE))
	{
		wl(WRITE_SEQUENCE, MPI_WRSEQ_KEY_VALUE_MASK);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_1ST_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_2ND_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_3RD_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_4TH_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_5TH_KEY_VALUE);
	}

	if (!(rl(DIAGNOSTIC) & MPI_DIAG_RESET_HISTORY) ||
		((rl(DOORBELL) & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_RESET &&
		 (rl(DOORBELL) & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_READY))
	{
		if (adap->device_id == MPI_MANUFACTPAGE_DEVID_SAS1078)
		{
			wl(SAS1078_RESET, 0x7);
		}
		else
		{
			wl(DIAGNOSTIC, MPI_DIAG_RESET_ADAPTER);
		}
		DELAY(1000);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_KEY_VALUE_MASK);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_1ST_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_2ND_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_3RD_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_4TH_KEY_VALUE);
		wl(WRITE_SEQUENCE, MPI_WRSEQ_5TH_KEY_VALUE);
	}

	wl(DIAGNOSTIC, 0);

	if (wait == FALSE)
	{
		while (time(NULL) < limit)
		{
			if (rl(DOORBELL) & MPI_IOC_STATE_MASK)
				break;
			if (rl(DIAGNOSTIC) & MPI_DIAG_DISABLE_ARM)
				break;
			DELAY(100);
		}

		return 1;
	}

	if (rl(DIAGNOSTIC) & MPI_DIAG_RESET_ADAPTER)
	{
		printf("\n%s: Failed to clear RESET ADAPTER\n", adap->name);
		if (wFlag)
			fprintf(logFile, "%s:  Failed to clear RESET ADAPTER\n",
					adap->name);
		adap->restart_needed = TRUE;
		return 0;
	}

	adap->bootloader = FALSE;

	if (mpt_wait_for_ready(adap))
		return 1;

	if (mpt_fwdownloadboot(adap))
		return 1;

	if ((rl(DOORBELL) & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_RESET)
	{
		adap->restart_needed = FALSE;

		printf("\n%s: Failed to leave the RESET state\n", adap->name);
		if (wFlag)
			fprintf(logFile, "%s:  Failed to leave the RESET state\n",
					adap->name);
	}
	else
	{
		adap->restart_needed = TRUE;

		printf("\n%s: Failed to reset properly\n", adap->name);
		if (wFlag)
			fprintf(logFile, "%s:  Failed to reset properly\n",
					adap->name);
	}

	return 0;
}
Ejemplo n.º 4
0
int
mpt_handle_reply(mpt_adap_t *adap, MPIDefaultReply_t *reply, U32 reply_ba)
{
	U32							 context;
	EventNotificationReply_t	*event;
	EventDataScsi_t				*ed_scsi;
	EventAckReply_t				*event_ack;
	int							 targ;
	int							 repost;

	repost = 1;
	context = get32(reply->MsgContext);

	if (get16(reply->IOCStatus) & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)
	{
		printf("%s: Function = %02x, IOCStatus = %04x, IOCLogInfo = %08x\n",
			   adap->name, reply->Function, get16(reply->IOCStatus),
			   get32(reply->IOCLogInfo));
	}

	if (get32(reply->MsgContext) == PASS_THRU_CONTEXT)
	{
		if (adap->command_active == TRUE)
		{
			adap->command_active = FALSE;
			bcopy(reply, adap->shared->data, reply->MsgLength * 4);
		}
		return repost;
	}

	switch (reply->Function)
	{
	case MPI_FUNCTION_CONFIG:
		if (adap->config_active == TRUE)
		{
			adap->config_active = FALSE;
			bcopy(reply, adap->shared->data, reply->MsgLength * 4);
		}
		break;
	case MPI_FUNCTION_EVENT_NOTIFICATION:
		logMptCommandRep(adap->port, NULL, 0, reply, sizeof(*reply), 1);
		event = (EventNotificationReply_t *)reply;
		switch (get32(event->Event))
		{
		case MPI_EVENT_NONE:
			break;
		case MPI_EVENT_STATE_CHANGE:
			adap->restart_needed = TRUE;
			break;
		case MPI_EVENT_ON_BUS_TIMER_EXPIRED:
			ed_scsi = (EventDataScsi_t *)event->Data;
			targ = ed_scsi->TargetID;
			printf("%s: ON BUS TIMER EXPIRED for SCSI target %d\n", adap->name, targ);
			adap->bus_reset_needed = TRUE;
			break;
		}
		if (event->AckRequired)
		{
			int			 t1;
			int			 t2;
			EventAck_t	*event_ack;

			t1 = event->Event;
			t2 = event->EventContext;
			/*
			 * Use the EventNotify reply as the EventAck command.
			 */
			event_ack = (EventAck_t *)event;
			bzero(event_ack, sizeof(*event_ack));
			event_ack->Function = MPI_FUNCTION_EVENT_ACK;
			event_ack->MsgContext = set32(reply_ba);
			event_ack->Event = t1;
			event_ack->EventContext = t2;
			wl(REQUEST_QUEUE, get32(event_ack->MsgContext));
			/*
			 * Signal that the reply should not be given back to
			 * the IOC yet, since it's being used as the EventAck
			 * command right now.
			 */
			repost = 0;
		}
		break;
	case MPI_FUNCTION_EVENT_ACK:
		event_ack = (EventAckReply_t *)reply;
		wl(REPLY_QUEUE, get32(event_ack->MsgContext));
		break;
	default:
		printf("%s: Invalid reply, Function = %02x, IOCStatus = %04x\n",
			   adap->name, reply->Function, get16(reply->IOCStatus));
#if 1
{
		int	 i;
		U32	*p = (U32 *)reply;

		for (i = 0; i < reply->MsgLength; i++)
			printf("reply[%02x] = %08x\n", i*4, get32(p[i]));
}
#endif
		break;
	}

	return repost;
}
Ejemplo n.º 5
0
int mpt_fwdownloadboot(mpt_adap_t *adap)
{
	U16						 deviceId = adap->device_id;
	MpiFwHeader_t			*fwHeader;
	MpiExtImageHeader_t		*extImageHeader;
	U32						*image;
	U8						*nextImage;
	U32						 addr;
	U32						 size;
	U32						 next;
	U32						 data;
	U32						 resetAddr;
	U32						 resetData;
	int						 t;

	if (adap->fw_image == NULL)
	{
		char	 name[256];
		int		 n;

		if (adap->fw_image_asked == TRUE)
			return 0;

		adap->fw_image_asked = TRUE;

		printf("\nThe firmware on this %s appears broken!\n", adap->port->chipNameRev);
		printf("A valid firmware image is required to make this chip operational...\n\n");

		n = getFileName(name, sizeof name, stdin, "firmware", 99);
		if (n > 0)
		{
			if (readFile(name, &adap->fw_image, &adap->fw_image_size) != 1)
			{
				printf("\nThe firmware image could not be read\n");
				return 0;
			}
		}
		else
		{
			printf("\nThe chip cannot be made operational\n");
			return 0;
		}
	}

	if (deviceId == MPI_MANUFACTPAGE_DEVICEID_FC909 ||
		deviceId == MPI_MANUFACTPAGE_DEVICEID_FC919 ||
		deviceId == MPI_MANUFACTPAGE_DEVICEID_FC929)
	{
		return mpt_directdownload(adap);
	}

	wl(WRITE_SEQUENCE, MPI_WRSEQ_KEY_VALUE_MASK);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_1ST_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_2ND_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_3RD_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_4TH_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_5TH_KEY_VALUE);

	wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM      |
				   MPI_DIAG_PREVENT_IOC_BOOT |
				   MPI_DIAG_CLEAR_FLASH_BAD_SIG);
	DELAY(100);

	if (deviceId == MPI_MANUFACTPAGE_DEVICEID_FC949E)
	{
		wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM         |
					   MPI_DIAG_PREVENT_IOC_BOOT    |
					   MPI_DIAG_CLEAR_FLASH_BAD_SIG |
					   MPI_DIAG_RW_ENABLE);

		wlio(DIAG_RW_ADDRESS, 0x40100064);
		data = rlio(DIAG_RW_DATA);

		wlio(DIAG_RW_ADDRESS, 0x40100064);
		wlio(DIAG_RW_DATA, data | 0x20000);

		DELAY(100);
	}

	wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM      |
				   MPI_DIAG_PREVENT_IOC_BOOT |
				   MPI_DIAG_RESET_ADAPTER);
	DELAY(100);

	wl(WRITE_SEQUENCE, MPI_WRSEQ_KEY_VALUE_MASK);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_1ST_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_2ND_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_3RD_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_4TH_KEY_VALUE);
	wl(WRITE_SEQUENCE, MPI_WRSEQ_5TH_KEY_VALUE);

	wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM         |
				   MPI_DIAG_PREVENT_IOC_BOOT    |
				   MPI_DIAG_CLEAR_FLASH_BAD_SIG |
				   MPI_DIAG_RW_ENABLE);

	if (deviceId == MPI_MANUFACTPAGE_DEVICEID_FC949E)
	{
		wlio(DIAG_RW_ADDRESS, 0x40100064);
		wlio(DIAG_RW_DATA, data);
	}

	fwHeader = (MpiFwHeader_t *)adap->fw_image;

	image = (U32 *)fwHeader;

	addr = fwHeader->LoadStartAddress;
	size = fwHeader->ImageSize;

	next = fwHeader->NextImageHeaderOffset;

	resetAddr = fwHeader->IopResetRegAddr;
	resetData = fwHeader->IopResetVectorValue;

	while (next != 0)
	{
		nextImage = (U8 *)fwHeader + next;

		extImageHeader = (MpiExtImageHeader_t *)nextImage;

		if (extImageHeader->ImageType == MPI_EXT_IMAGE_TYPE_BOOTLOADER)
		{
			printf("Found a BootLoader, using only that part of the image!\n");

			adap->bootloader = TRUE;

			image = (U32 *)extImageHeader;

			addr = extImageHeader->LoadStartAddress;
			size = extImageHeader->ImageSize;

			next = 0;

			resetData = addr + sizeof(MpiExtImageHeader_t);

			break;
		}

		next = extImageHeader->NextImageHeaderOffset;
	}

	if (addr == fwHeader->LoadStartAddress && size == fwHeader->ImageSize)
	{
		next = fwHeader->NextImageHeaderOffset;
	}

	while (1)
	{
		wlio(DIAG_RW_ADDRESS, addr);

		while (size)
		{
			data = *image++;

			wlio(DIAG_RW_DATA, data);

			size -= 4;
		}

		if (next == 0)
		{
			break;
		}

		nextImage = (U8 *)fwHeader + next;

		extImageHeader = (MpiExtImageHeader_t *)nextImage;

		image = (U32 *)extImageHeader;

		addr = extImageHeader->LoadStartAddress;
		size = extImageHeader->ImageSize;

		next = extImageHeader->NextImageHeaderOffset;
	}

	wlio(DIAG_RW_ADDRESS, resetAddr);
	wlio(DIAG_RW_DATA, resetData);

	if (deviceId == MPI_MANUFACTPAGE_DEVID_53C1030)
	{
		wlio(DIAG_RW_ADDRESS, 0x3f000000);
		data = rlio(DIAG_RW_DATA);

		data |= 0x40000000;

		wlio(DIAG_RW_ADDRESS, 0x3f000000);
		wlio(DIAG_RW_DATA, data);
	}

	if (deviceId == MPI_MANUFACTPAGE_DEVICEID_FC919X ||
		deviceId == MPI_MANUFACTPAGE_DEVICEID_FC929X)
	{
		wlio(DIAG_RW_ADDRESS, 0x3e000000);
		data = rlio(DIAG_RW_DATA);
	}

	if (deviceId == MPI_MANUFACTPAGE_DEVICEID_FC939X ||
		deviceId == MPI_MANUFACTPAGE_DEVICEID_FC949X ||
		deviceId == MPI_MANUFACTPAGE_DEVICEID_FC949E)
	{
		wlio(DIAG_RW_ADDRESS, 0x3d000000);
		data = rlio(DIAG_RW_DATA);
	}

	if (adap->bootloader)
	{
		wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM |
					   MPI_DIAG_CLEAR_FLASH_BAD_SIG);
		DELAY(100);

		wl(DIAGNOSTIC, 0);
		DELAY(100);

		sleep(1);
	}

	wl(DIAGNOSTIC, MPI_DIAG_DISABLE_ARM |
				   MPI_DIAG_CLEAR_FLASH_BAD_SIG);
	DELAY(100);

	wl(DIAGNOSTIC, 0);
	DELAY(100);

	t = mpt_wait_for_ready(adap);

	if (wFlag)
		fprintf(logFile, "%s:  Firmware Download Boot:  %s\n",
				adap->name, t ? "PASS" : "FAIL");

	if (t)
		return 1;

	printf("\n%s: FWDownloadBoot failed!\n", adap->name);
	return 0;
}
Ejemplo n.º 6
0
Json::Value ChromeCast::send(const std::string& namespace_, const Json::Value& payload)
{
	Json::FastWriter fw;
	fw.omitEndingLineFeed();

	extensions::core_api::cast_channel::CastMessage msg;
	msg.set_payload_type(msg.STRING);
	msg.set_protocol_version(msg.CASTV2_1_0);
	msg.set_namespace_(namespace_);
	msg.set_source_id(m_source_id);
	msg.set_destination_id(m_destination_id);
	msg.set_payload_utf8(fw.write(payload));

	std::string data, foo;
	char pktlen[4];
	unsigned int len = htonl(msg.ByteSize());
	memcpy(&pktlen, &len, sizeof len);
	foo.append(pktlen, sizeof pktlen);
	msg.SerializeToString(&data);
	foo += data;

	std::condition_variable f;
	bool wait = false;
	unsigned int requestId;
	if (payload.isMember("requestId"))
	{
		requestId = payload["requestId"].asUInt();
		m_mutex.lock();
		m_wait[requestId] = std::make_pair(&f, std::string());
		wait = true;
		m_mutex.unlock();
	}

	syslog(LOG_DEBUG, "%s -> %s (%s): %s",
			msg.source_id().c_str(),
			msg.destination_id().c_str(),
			msg.namespace_().c_str(),
			msg.payload_utf8().c_str()
		  );

	int w;
	m_ssl_mutex.lock();
	if (m_ssl) {
		w = SSL_write(m_ssl, foo.c_str(), foo.size());
		if (w == -1) {
			syslog(LOG_DEBUG, "SSL_write error");
			disconnect();
		}
	} else
		w = -1;
	m_ssl_mutex.unlock();

	if (wait && w == -1)
	{
		m_mutex.lock();
		m_wait.erase(requestId);
		m_mutex.unlock();
		wait = false;
	}

	Json::Value ret;
	if (wait) {
		std::unique_lock<std::mutex> wl(m_mutex);
		f.wait(wl);
		ret = m_wait[requestId].second;
		m_wait.erase(requestId);
		m_mutex.unlock();
	}

	return ret;
}
Ejemplo n.º 7
0
void
EffectNode::resetVisitState( void )
{
    QWriteLocker wl( &m_rwl );
    m_visited = false;
}
Ejemplo n.º 8
0
void AMSettings::setPublicDatabaseFilename(QString publicDatabaseFilename)
{
	QWriteLocker wl(&mutex_);
	publicDatabaseFilename_ = publicDatabaseFilename;
}
Ejemplo n.º 9
0
void AMSettings::setFileLoaderPluginsFolder(QString fileLoaderPluginsFolder)
{
	QWriteLocker wl(&mutex_);
	fileLoaderPluginsFolder_ = fileLoaderPluginsFolder;
}
Ejemplo n.º 10
0
 // add a writer (called by thread itself), return thread index....
 int addWriter (void)
 {
   ScopedLock wl(wlock);
   m_done.push_back(true);
   return m_done.size()-1;
 }
Ejemplo n.º 11
0
void AMSettings::setPublicDataFolder(QString publicDataFolder)
{
	QWriteLocker wl(&mutex_);
	publicDataFolder_ = publicDataFolder;
}
Ejemplo n.º 12
0
 // clear bits (declare box ready...)
 void undo()
 {
   ScopedLock wl(wlock);
   writing = m_done.size();
   std::fill(m_done.begin(),m_done.end(),false);
 }
Ejemplo n.º 13
0
const CellValue &SessionInfoProcessor::getValue()
{
	IdentifierType requestedMessagePart = getKey()[1];
	// switch must be identical to SystemDatabase::SESSION_PROPERTIES_ITEMS
//	{"User",	Element::STRING},
//	{"Jobs",	Element::NUMERIC},
//	{"Login Time",	Element::STRING},
//	{"Expiration Time", Element::STRING},
//	{"Time",	Element::NUMERIC},
//	{"Active Jobs", Element::STRING}
//	{"License",	Element::NUMERIC},
//	{"Address",	Element::STRING},
//	{"Command",	Element::STRING},
//	{"Description",	Element::STRING},
//	{"MachineId", Element::STRING}
	switch (requestedMessagePart) {
	case 0:	// 	{"User",     Element::STRING},
	{
		try {
			PUser user = sessionIt->second->getUser();
			if (user) {
				value = user->getName();
			} else if (sessionIt->second->isWorker()) {
				value = "<SupervisionServer>";
			} else {
				value = "<FAKE>";
			}
		} catch (ParameterException&) {
			value = "<UNKNOWN USER>"; // deleted user
		}
		break;
	}
	case 1:	// {"Jobs",	Element::NUMERIC},
		value = double(sessionIt->second->requestCounter);
		break;
	case 2:	// {"Login Time", Element::STRING},
		value = StringUtils::convertTimeToString(sessionIt->second->getLoginTime());
		break;
	case 3:	// {"Expiration Time", Element::STRING},
	{
		time_t ttl = sessionIt->second->getTtl();
		value = StringUtils::convertTimeToString(ttl);
		break;
	}
	case 4:	// {"Time", Element::NUMERIC},
		{
			double totalTime = sessionIt->second->totalTime;
			WriteLocker wl(&sessionIt->second->thisLock);
			for (set<const PaloJob *>::iterator jit = sessionIt->second->activeJobs.begin(); jit != sessionIt->second->activeJobs.end(); ++jit) {
				if (*jit) {
					totalTime += (*jit)->getDuration();
				}
			}
			value = totalTime;
		}
		break;
	case 5:	// {"Active Jobs", Element::STRING}
	{
		WriteLocker wl(&sessionIt->second->thisLock);
		string jobsNames;
		Context *context = Context::getContext();
		for (set<const PaloJob *>::iterator jit = sessionIt->second->activeJobs.begin(); jit != sessionIt->second->activeJobs.end(); ++jit) {
			if (*jit && (*jit)->getContext() != context) {
				if (!jobsNames.empty()) {
					jobsNames += ", ";
				}
				jobsNames += StringUtils::convertToString((*jit)->getId());
			}
		}
		value = jobsNames;
		break;
	}
	case 6:	// {"License",  Element::STRING},
		value = Context::getContext()->getServer()->getSessionLicense(sessionIt->second);
		break;
	case 7:	// {"Address",  Element::STRING},
		value = sessionIt->second->peerName;
		break;
	case 8:	// {"Command",	Element::STRING}
		value = sessionIt->second->command;
		break;
	case 9:	// {"Description",	Element::STRING}
		value = sessionIt->second->description;
		break;
	case 10:	// {"MachineId", Element::STRING}
		value = sessionIt->second->machineId;
		break;
	case 11:	// {"CurrentSession", Element::NUMERIC}
		value = CellValue();
		if (context && context->getSession() == sessionIt->second) {
			value = 1.0;
		}
		break;
	default:
		value = CellValue();
		break;
	}
	return value;
}
Ejemplo n.º 14
0
bool
EffectNode::deleteRootNode( const QString & rootNodeName )
{
    QWriteLocker                        wl( &s_srwl );
    return EffectNode::s_renf.deleteEffectNodeInstance( rootNodeName );
}
Ejemplo n.º 15
0
bool AMDbObjectSupport::registerDatabase(AMDatabase* db) {

	QWriteLocker wl(&registryMutex_);

	// is it already registered? return true.
	if(registeredDatabases_.contains(db)) {
		AMErrorMon::report(AMErrorReport(0, AMErrorReport::Debug, AMDBOBJECTSUPPORT_DATABASE_ALREADY_REGISTERED, QString("Database Support: The database '%1' has already been registered in the system. Skipping duplicate registration.").arg(db->connectionName())));
		return true;
	}


	// ensure type-metaInfo table
	if( db->ensureTable(	typeTableName(),
							QString("AMDbObjectType,tableName,description,version").split(','),
							QString("TEXT,TEXT,TEXT,INTEGER").split(','),
				false) && db->ensureColumn(typeTableName(), QString("inheritance")))
		db->createIndex(typeTableName(), "AMDbObjectType");

	// ensure supporting type tables: (These map types to column names: an entry for each type / field-name combintion)
	if( db->ensureTable(	allColumnsTableName(),
							QString("typeId,columnName").split(','),
							QString("INTEGER,TEXT").split(','),
							false) )
		db->createIndex(allColumnsTableName(), "typeId");

	if( db->ensureTable(	visibleColumnsTableName(),
							QString("typeId,columnName").split(','),
							QString("INTEGER,TEXT").split(','),
							false) )
		db->createIndex(visibleColumnsTableName(), "typeId");

	if( db->ensureTable(loadColumnsTableName(),
						QString("typeId,columnName").split(','),
						QString("INTEGER,TEXT").split(','),
						false) )
		db->createIndex(loadColumnsTableName(), "typeId");

	// This table stores thumbnails for all these object types.  It should not reuse ids, so that a set of thumbnails added will always have sequential ids.
	db->ensureTable(thumbnailTableName(), QString("objectId,objectTableName,number,type,title,subtitle,thumbnail").split(','), QString("INTEGER,TEXT,INTEGER,TEXT,TEXT,TEXT,BLOB").split(','), false);
	db->createIndex(thumbnailTableName(), "objectId,objectTableName");

	// This table stores database upgrade information for all these object types.
	db->ensureTable(upgradesTableName(),
			   QString("description,upgradeTag,necessaryUpgrade,upgradeDate,duringCreation").split(','),
			   QString("TEXT,TEXT,TEXT,TEXT,TEXT").split(','),
			   false);

	// temporary... this should all be cleaned up and moved and handled generically
	////////////////////////////
	db->ensureTable(elementTableName(), QString("AMDbObjectType,thumbnailCount,thumbnailFirstId,symbol,name,atomicNumber").split(','), QString("TEXT,INTEGER,INTEGER,TEXT,TEXT,INTEGER").split(','));


	// These tables provide links between experiments and user-data objects, and samples and elements.
	db->ensureTable(experimentEntriesTableName(), QString("objectId,experimentId").split(','), QString("INTEGER,INTEGER").split(','));
	db->createIndex(experimentEntriesTableName(), "objectId,experimentId");
	db->createIndex(experimentEntriesTableName(), "experimentId,objectId");

	db->ensureTable(sampleElementEntriesTableName(), QString("sampleId,elementId").split(','), QString("INTEGER,INTEGER").split(','));
	db->createIndex(sampleElementEntriesTableName(), "sampleId,elementId");
	db->createIndex(sampleElementEntriesTableName(), "elementId,sampleId");

	// This table provides optimized storage for the individual control fields in a control set
	db->ensureTable(controlSetEntriesTableName(), QString("csiId,name,ctrlValue,minimum,maximum,units,number").split(','), QString("INTEGER,TEXT,REAL,REAL,REAL,TEXT,INTEGER").split(','));
	db->createIndex(controlSetEntriesTableName(), "csiId");
	/////////////////////////////////

	/// \todo error checking on creating these previous tables.


	// Retro-actively add all previously registered classes.
	bool success = true;
	foreach(const AMDbObjectInfo& dbo, registeredClassesInOrder_) {
		success = success && getDatabaseReadyForClass(db, dbo);
	}
Ejemplo n.º 16
0
void AMSettings::setAnalysisBlockPluginsFolder(QString analysisBlockPluginsFolder)
{
	QWriteLocker wl(&mutex_);
	analysisBlockPluginsFolder_ = analysisBlockPluginsFolder;
}
Ejemplo n.º 17
0
void EventMonitorEntry::slotUpdate() {
  // possible deadlock?  bad idea.  updates should only happen in update thread
  KstWriteLocker wl(this);
  update();
}
Ejemplo n.º 18
0
void
mpt_interrupt(mpt_adap_t *adap)
{
	U32					 context;
	U32					 reply_ba;
	MPIDefaultReply_t	*reply;
	U32					 doorbell;
	int					 state;

//	printf("mpt_interrupt called\n");

	if (adap->hrsm_capable)
	{
		if (adap->hrsm_value == adap->shared->hrsm_value)
			return;
		adap->hrsm_value = adap->shared->hrsm_value;
	}

	doorbell = rl(DOORBELL);
	state = doorbell & MPI_IOC_STATE_MASK;
	if (state != MPI_IOC_STATE_OPERATIONAL)
	{
		if (state == MPI_IOC_STATE_FAULT)
		{
			printf("%s: MPT Firmware Fault, code %04x\n",
				   adap->name, doorbell & MPI_DOORBELL_DATA_MASK);
			if (wFlag)
				fprintf(logFile, "%s:  MPT Firmware Fault, code %04x\n",
						adap->name, doorbell & MPI_DOORBELL_DATA_MASK);
		}
		adap->restart_needed = TRUE;
	}

	while ((context = rl(REPLY_QUEUE)) != 0xffffffff)
	{
		if (context & MPI_CONTEXT_REPLY_A_BIT)
		{
			reply_ba = context << 1;
			reply = (MPIDefaultReply_t *)((U8 *)adap->shared + reply_ba - (U32)adap->shared_ba);
			if (mpt_handle_reply(adap, reply, reply_ba))
				wl(REPLY_QUEUE, reply_ba);
			continue;
		}
		if (context == PASS_THRU_CONTEXT)
		{
			if (adap->command_active == TRUE)
			{
				SCSIIORequest_t		*scsiReq = (SCSIIORequest_t *)adap->shared->message;
				SCSIIOReply_t		*scsiRep = (SCSIIOReply_t *)adap->shared->data;

				adap->command_active = FALSE;
				bzero(scsiRep, sizeof(*scsiRep));

				scsiRep->Function		= scsiReq->Function;
				scsiRep->MsgLength		= sizeof *scsiRep / 4;
				scsiRep->Bus			= scsiReq->Bus;
				scsiRep->TargetID		= scsiReq->TargetID;
				scsiRep->CDBLength		= scsiReq->CDBLength;
				scsiRep->IOCStatus		= MPI_IOCSTATUS_SUCCESS;
				scsiRep->SCSIStatus		= MPI_SCSI_STATUS_SUCCESS;
				scsiRep->TransferCount	= scsiReq->DataLength;
			}
			continue;
		}
		printf("%s: Invalid reply, Context = %08x\n", adap->name, reply);
	}
}
Ejemplo n.º 19
0
void BandwidthGroup::i_release()
{
    AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
    m->bd.backup();
    m->bd->cReferences--;
}
Ejemplo n.º 20
0
void
EffectNode::setVisited( void )
{
    QWriteLocker wl( &m_rwl );
    m_visited = true;
}