/* Set FSR0, FQ0-FQ9, depending on the interrupt.  */
static void
set_fp_exception_registers (
  SIM_CPU *current_cpu, struct frv_interrupt_queue_element *item
)
{
  int fq_index;
  SI fq;
  SI insn;
  SI fsr0;
  IADDR pc;
  struct frv_fp_exception_info *fp_info;
  SIM_DESC sd = CPU_STATE (current_cpu);

  /* No FQ registers on fr550 */
  if (STATE_ARCHITECTURE (sd)->mach == bfd_mach_fr550)
    {
      /* Update the fsr.  */
      fp_info = & item->u.fp_info;
      fsr0 = GET_FSR (0);
      SET_FSR_FTT (fsr0, fp_info->ftt);
      SET_FSR (0, fsr0);
      return;
    }

  /* Select an FQ and update it with the exception information.  */
  fq_index = fq_for_exception (current_cpu, item);
  if (fq_index == -1)
    return;

  fp_info = & item->u.fp_info;
  fq = GET_FQ (fq_index);
  SET_FQ_MIV (fq, MIV_FLOAT);
  SET_FQ_SIE (fq, SIE_NIL);
  SET_FQ_FTT (fq, fp_info->ftt);
  SET_FQ_CEXC (fq, fp_info->fsr_mask);
  SET_FQ_VALID (fq);
  SET_FQ (fq_index, fq);

  /* Write the failing insn into FQx.OPC.  */
  pc = item->vpc;
  insn = GETMEMSI (current_cpu, pc, pc);
  SET_FQ_OPC (fq_index, insn);

  /* Update the fsr.  */
  fsr0 = GET_FSR (0);
  SET_FSR_QNE (fsr0); /* FQ not empty */
  SET_FSR_FTT (fsr0, fp_info->ftt);
  SET_FSR (0, fsr0);
}
Пример #2
0
void accessor_module(void)
{
	bd_t ipacket, opacket;
	static uid_t uid;
	static WORD label_cache;

	if (mail_reciev(MYSELF, &ipacket)) {

		if (bcp_buffer(ipacket)->status == BD_TIMEOUT)
			process_tout_buffer(ipacket);
		else if (bcp_buffer(ipacket)->status == BD_OBTAINED)
			process_host_buffer(ipacket);
	}

	switch (state) {
	case WAIT_UID:
		if (readers_get_uid(&uid)) {
        	memset((void *)LCDText, ' ', LCD_SIZE);
        	LCDText[LCD_SIZE] = '\0';
        	LCDUpdate();
			state = CHECK_SM;
		}

		break;
	case CHECK_SM:
		if(sm_is_ready()) {
			event_send(MODULE_SRVMACHINE, EVT_SM_PREPARE);
		} else {
			strcpy(LCD_STRING_0, AppConfig.acc_busy_msg);
			LCD_decode(LCD_ALL);
			LCDUpdate();
			LCD_set_tout(TICK_SECOND * 5);

			state = WAIT_UID;
			break;
		}

		/* It's OK, send to host */
		opacket = bcp_obtain_buffer(MYSELF);
		

		if (opacket < 0) {

			TRACE("\n\rACS: can't obtaine buffer (QAC_AR_REQUEST)");
			
			break;
		}
		{
			bcp_header_t * hdr = (bcp_header_t *) bcp_buffer(opacket)->buf;
			ar_req *request = (ar_req *) &hdr->raw[RAW_DATA];
			TRACE("\n\rACS: buffer obtained (QAC_AR_REQUEST)");
			
			hdr->hdr_s.type = TYPE_NPDL;
			SET_FQ(hdr->hdr_s.type);
			hdr->hdr_s.packtype_u.npdl.qac = QAC_AR_REQUEST;
			hdr->hdr_s.packtype_u.npdl.len = (sizeof(ar_req) - MAX_UID_SIZE)
					+ strlen(uid.uid) + CRC16_BYTES;

			request->retries = AppConfig.acc_retry_cnt;
			request->reader_n = uid.gate;
			request->req_label = label_cache = (WORD) TickGet();
			strcpy(request->uid, uid.uid);

			bcp_send_buffer(opacket);
			state = WAIT_HOST_ANSWER;
		}
		break;
	case WAIT_HOST_ANSWER:

		break;
	case WAIT_SM:
		if(event_recieve(MYSELF, &event)) {

			opacket = bcp_obtain_buffer(MYSELF);
			if (opacket < 0) {
				break;
			}

			if(event & EVT_AC_DONE) {

				bcp_header_t * hdr = (bcp_header_t *) bcp_buffer(opacket)->buf;
				eos_req *request = (eos_req *) &hdr->raw[RAW_DATA];

				TRACE("\n\rACS: buffer obtained (QAC_SERV_DONE)");

				hdr->hdr_s.type = TYPE_NPDL;
				SET_FQ(hdr->hdr_s.type);
				hdr->hdr_s.packtype_u.npdl.qac = QAC_SERV_DONE;
				hdr->hdr_s.packtype_u.npdl.len = sizeof(eos_req) + CRC16_BYTES;

				request->retries = AppConfig.acc_retry_cnt;
				request->reader_n = uid.gate;
				request->req_label = label_cache;

				bcp_send_buffer(opacket);

				state = WAIT_UID;
				readers_reset_state();

			} else if (event & EVT_AC_TOUT) {

				bcp_header_t * hdr = (bcp_header_t *) bcp_buffer(opacket)->buf;
				eos_req *request = (eos_req *) &hdr->raw[RAW_DATA];

				TRACE("\n\rACS: buffer obtained (QAC_SERV_REJECT)");

				hdr->hdr_s.type = TYPE_NPDL;
				SET_FQ(hdr->hdr_s.type);
				hdr->hdr_s.packtype_u.npdl.qac = QAC_SERV_REJECT;
				hdr->hdr_s.packtype_u.npdl.len = sizeof(eos_req) + CRC16_BYTES;

				request->retries = AppConfig.acc_retry_cnt;
				request->reader_n = uid.gate;
				request->req_label = label_cache;

				bcp_send_buffer(opacket);

				state = WAIT_UID;
				readers_reset_state();

			} else {
				bcp_release_buffer(opacket);
			}
		}

		break;
	}

}