Exemplo n.º 1
0
int vfprintf(FILE *fp,const char *format,va_list list)
{
	int ocnt=0;
	char buf[0x200];
	size_t prog;
	size_t needed;
	while(1)
	{
		prog=format_helper(buf,0x200,&needed,&format,list);
		if(prog>0)
		{
			fwrite(buf,1,prog,fp);
			ocnt+=prog;
			if(format[0]==(char)0)//format end
				break;
			continue;
		}
		if(needed==0)break;
		char *buf2=(char*)malloc(needed);
		size_t prog2=format_helper(buf2,needed,(size_t*)0,&format,list);
		//assert(prog2==needed);
		fwrite(buf2,1,prog2,fp);
		ocnt+=prog2;
	}
	return ocnt;
}
Exemplo n.º 2
0
void JVMState::format(PhaseRegAlloc *regalloc, const Node *n) const {
    tty->print("        #");
    if( _method ) {
        _method->print_short_name();
        tty->print(" @ bci:%d ",_bci);
    } else {
        tty->print_cr(" runtime stub ");
        return;
    }
    MachNode *mach = ((Node *)n)->is_Mach();
    MachSafePointNode *mcall = mach->is_MachSafePoint();
    if (mcall) {
        uint i;
        // Print locals
        for( i = 0; i < (uint)loc_size(); i++ )
            format_helper( regalloc, mcall->local(this, i), "L", i );
        // Print stack
        for (i = 0; i < (uint)stk_size(); i++) {
            if ((uint)(_stkoff + i) >= mcall->len())
                tty->print(" oob ");
            else
                format_helper( regalloc, mcall->stack(this, i), "STK", i );
        }
        for (i = 0; (int)i < nof_monitors(); i++) {
            Node *box = mcall->monitor_box(this, i);
            Node *obj = mcall->monitor_obj(this, i);
            if ( regalloc->get_reg_lo(box) != OptoReg::Bad ) {
                while( !box->is_BoxLock() )  box = box->in(1);
                format_helper( regalloc, box, "MON-BOX", i );
            } else {
                OptoReg::Name box_reg = BoxLockNode::stack_slot(box);
                tty->print(" MON-BOX%d=%s+%d",i,SharedInfo::regName[SharedInfo::c_frame_pointer],regalloc->reg2offset(box_reg));
            }
            format_helper( regalloc, obj, "MON-OBJ", i );
        }
    }
    tty->print_cr("");
    if (caller() != NULL)  caller()->format(regalloc, n);
}
Exemplo n.º 3
0
_format_hw_dn(char *buf, size_t size, const_efidp dp)
{
    efi_guid_t edd10_guid = EDD10_HARDWARE_VENDOR_PATH_GUID;
    off_t off = 0;
    switch (dp->subtype) {
    case EFIDP_HW_PCI:
        off += format(buf, size, off, "Pci(0x%"PRIx32",0x%"PRIx32")",
                      dp->pci.device, dp->pci.function);
        break;
    case EFIDP_HW_PCCARD:
        off += format(buf, size, off, "PcCard(0x%"PRIx32")",
                      dp->pccard.function);
        break;
    case EFIDP_HW_MMIO:
        off += format(buf, size, off,
                      "MemoryMapped(%"PRIu32",0x%"PRIx64",0x%"PRIx64")",
                      dp->mmio.memory_type, dp->mmio.starting_address,
                      dp->mmio.ending_address);
        break;
    case EFIDP_HW_VENDOR:
        if (!efi_guid_cmp(&dp->hw_vendor.vendor_guid, &edd10_guid)) {
            off += format_helper(format_edd10_guid, buf, size,
                                 off, dp);
        } else {
            off += format_vendor(buf, size, off, "VenHw", dp);
        }
        break;
    case EFIDP_HW_CONTROLLER:
        off += format(buf, size, off, "Ctrl(0x%"PRIx32")",
                      dp->controller.controller);
        break;
    case EFIDP_HW_BMC:
        off += format(buf, size, off, "BMC(%d,0x%"PRIx64")",
                      dp->bmc.interface_type, dp->bmc.base_addr);
        break;
    default:
        off += format(buf, size, off, "HardwarePath(%d,", dp->subtype);
        off += format_hex(buf, size, off, (uint8_t *)dp+4,
                          efidp_node_size(dp)-4);
        off += format(buf,size,off,")");
        break;
    }
    return off;
}
Exemplo n.º 4
0
_format_message_dn(char *buf, size_t size, const_efidp dp)
{
	ssize_t off = 0;
	ssize_t sz;
	switch (dp->subtype) {
	case EFIDP_MSG_ATAPI:
		off += format(buf, size, off, "Ata(%d,%d,%d)",
			      dp->atapi.primary, dp->atapi.slave,
			      dp->atapi.lun);
		break;
	case EFIDP_MSG_SCSI:
		off += format(buf, size, off, "SCSI(%d,%d)",
			      dp->scsi.target, dp->scsi.lun);
		break;
	case EFIDP_MSG_FIBRECHANNEL:
		off += format(buf, size, off, "Fibre(%"PRIx64",%"PRIx64")",
			      le64_to_cpu(dp->fc.wwn),
			      le64_to_cpu(dp->fc.lun));
		break;
	case EFIDP_MSG_FIBRECHANNELEX:
		off += format(buf, size, off, "Fibre(%"PRIx64",%"PRIx64")",
			      be64_to_cpu(dp->fc.wwn),
			      be64_to_cpu(dp->fc.lun));
		break;
	case EFIDP_MSG_1394:
		off += format(buf, size, off, "I1394(0x%"PRIx64")",
			      dp->firewire.guid);
		break;
	case EFIDP_MSG_USB:
		off += format(buf, size, off, "USB(%d,%d)",
			      dp->usb.parent_port, dp->usb.interface);
		break;
	case EFIDP_MSG_I2O:
		off += format(buf, size, off, "I2O(%d)", dp->i2o.target);
		break;
	case EFIDP_MSG_INFINIBAND:
		if (dp->infiniband.resource_flags &
				EFIDP_INFINIBAND_RESOURCE_IOC_SERVICE) {
			off += format(buf, size, off,
				      "Infiniband(%08x,%"PRIx64"%"PRIx64",%"PRIx64",%"PRIu64",%"PRIu64")",
				      dp->infiniband.resource_flags,
				      dp->infiniband.port_gid[1],
				      dp->infiniband.port_gid[0],
				      dp->infiniband.service_id,
				      dp->infiniband.target_port_id,
				      dp->infiniband.device_id);
		} else {
			off += format(buf, size, off,
				      "Infiniband(%08x,%"PRIx64"%"PRIx64",",
				      dp->infiniband.resource_flags,
				      dp->infiniband.port_gid[1],
				      dp->infiniband.port_gid[0]);
			off += format_guid(buf, size, off, (efi_guid_t *)
					   &dp->infiniband.ioc_guid);
			off += format(buf, size, off, ",%"PRIu64",%"PRIu64")",
				      dp->infiniband.target_port_id,
				      dp->infiniband.device_id);
		}
		break;
	case EFIDP_MSG_MAC_ADDR:
		off += format(buf, size, off, "MAC(");
		off += format_hex(buf, size, off, dp->mac_addr.mac_addr,
				  dp->mac_addr.if_type < 2 ? 6
					: sizeof(dp->mac_addr.mac_addr));
		off += format(buf, size, off, ",%d)", dp->mac_addr.if_type);
		break;
	case EFIDP_MSG_IPv4: {
		efidp_ipv4_addr const *a = &dp->ipv4_addr;
		off += format(buf, size, off,
			      "IPv4(%hhu.%hhu.%hhu.%hhu:%hu<->%hhu.%hhu.%hhu.%hhu:%hu,%hx,%hhx)",
			      a->local_ipv4_addr[0], a->local_ipv4_addr[1],
			      a->local_ipv4_addr[2], a->local_ipv4_addr[3],
			      a->local_port, a->remote_ipv4_addr[0],
			      a->remote_ipv4_addr[1], a->remote_ipv4_addr[2],
			      a->remote_ipv4_addr[3], a->remote_port,
			      a->protocol, a->static_ip_addr);
		break;
			     }
	case EFIDP_MSG_VENDOR: {
		struct {
			efi_guid_t guid;
			char label[40];
			ssize_t (*formatter)(char *buf, size_t size,
					     const_efidp dp);
		} subtypes[] = {
			{ EFIDP_PC_ANSI_GUID, "VenPcAnsi" },
			{ EFIDP_VT_100_GUID, "VenVt100" },
			{ EFIDP_VT_100_PLUS_GUID, "VenVt100Plus" },
			{ EFIDP_VT_UTF8_GUID, "VenUtf8" },
			{ EFIDP_MSG_DEBUGPORT_GUID, "DebugPort" },
			{ EFIDP_MSG_UART_GUID, "", format_uart },
			{ EFIDP_MSG_SAS_GUID, "", format_sas },
			{ efi_guid_empty, "" }
		};
		char *label = NULL;
		ssize_t (*formatter)(char *buf, size_t size,
				     const_efidp dp) = NULL;

		for (int i = 0; !efi_guid_is_zero(&subtypes[i].guid); i++) {
			if (efi_guid_cmp(&subtypes[i].guid,
					  &dp->msg_vendor.vendor_guid))
				continue;

			label = subtypes[i].label;
			formatter = subtypes[i].formatter;
			break;
		}

		if (!label && !formatter) {
			off += format_vendor(buf, size, off, "VenMsg", dp);
			break;
		} else if (formatter) {
			off += format_helper(formatter, buf, size, off, dp);
			break;
		}

		off += format(buf, size, off, "%s(", label);
		if (efidp_node_size(dp) >
				(ssize_t)(sizeof (efidp_header)
					  + sizeof (efi_guid_t))) {
			off += format_hex(buf, size, off,
					  dp->msg_vendor.vendor_data,
					  efidp_node_size(dp)
						- sizeof (efidp_header)
						- sizeof (efi_guid_t));
		}
		break;
			       }
	case EFIDP_MSG_IPv6: {
		efidp_ipv6_addr const *a = &dp->ipv6_addr;
		char *addr0 = NULL;
		char *addr1 = NULL;

		sz = format_ipv6_port(addr0, 0, 0, a->local_ipv6_addr,
				      a->local_port);
		if (sz < 0)
			return sz;

		addr0 = alloca(sz+1);
		sz = format_ipv6_port(addr0, sz, 0, a->local_ipv6_addr,
				      a->local_port);
		if (sz < 0)
			return sz;

		sz = format_ipv6_port(addr1, 0, 0, a->remote_ipv6_addr,
				      a->remote_port);
		if (sz < 0)
			return sz;
		addr1 = alloca(sz+1);
		sz = format_ipv6_port(addr1, sz, 0, a->remote_ipv6_addr,
				      a->remote_port);
		if (sz < 0)
			return sz;

		off += format(buf, size, off, "IPv6(%s<->%s,%hx,%hhx)",
			     addr0, addr1, a->protocol, a->ip_addr_origin);
		break;
			     }
	case EFIDP_MSG_UART: {
		int parity = dp->uart.parity;
		char parity_label[] = "DNEOMS";
		int stop_bits = dp->uart.stop_bits;
		char *sb_label[] = {"D", "1", "1.5", "2"};

		off += format(buf, size, off, "Uart(%"PRIu64",%d,",
			     dp->uart.baud_rate ? dp->uart.baud_rate : 115200,
			     dp->uart.data_bits ? dp->uart.data_bits : 8);
		off += format(buf, size, off,
			     parity > 5 ? "%d," : "%c,",
			     parity > 5 ? parity : parity_label[parity]);
		if (stop_bits > 3)
			off += format(buf, size, off, "%d)", stop_bits);
		else
			off += format(buf, size, off, "%s)",
				     sb_label[stop_bits]);
		break;
			     }
	case EFIDP_MSG_USB_CLASS:
		off += format_helper(format_usb_class, buf, size, off, dp);
		break;
	case EFIDP_MSG_USB_WWID:
		off += format(buf, size, off,
			      "UsbWwid(%"PRIx16",%"PRIx16",%d,",
			      dp->usb_wwid.vendor_id, dp->usb_wwid.product_id,
			      dp->usb_wwid.interface);
		off += format_ucs2(buf, size, off, dp->usb_wwid.serial_number,
				   (efidp_node_size(dp)
				    - offsetof(efidp_usb_wwid, serial_number))
				   / 2 + 1);
		off += format(buf, size, off, ")");
		break;
	case EFIDP_MSG_LUN:
		off += format(buf, size, off, "Unit(%d)", dp->lun.lun);
		break;
	case EFIDP_MSG_SATA:
		off += format(buf, size, off, "Sata(%d,%d,%d)",
			     dp->sata.hba_port, dp->sata.port_multiplier_port,
			     dp->sata.lun);
		break;
	case EFIDP_MSG_ISCSI: {
		size_t sz = efidp_node_size(dp)
			    - offsetof(efidp_iscsi, target_name);
		if (sz > EFIDP_ISCSI_MAX_TARGET_NAME_LEN)
			sz = EFIDP_ISCSI_MAX_TARGET_NAME_LEN;
		char target_name[sz + 1];
		memcpy(target_name, dp->iscsi.target_name, sz);
		target_name[sz] = '\0';
		uint64_t lun;

		memcpy(&lun, dp->iscsi.lun, sizeof (lun));

		off += format(buf, size, off,
			      "iSCSI(%s,%d,0x%"PRIx64",%s,%s,%s,%s)",
			      target_name, dp->iscsi.tpgt,
			      be64_to_cpu(lun),
			      (dp->iscsi.options >> EFIDP_ISCSI_HEADER_DIGEST_SHIFT) & EFIDP_ISCSI_HEADER_CRC32 ? "CRC32" : "None",
			      (dp->iscsi.options >> EFIDP_ISCSI_DATA_DIGEST_SHIFT) & EFIDP_ISCSI_DATA_CRC32 ? "CRC32" : "None",
			      (dp->iscsi.options >> EFIDP_ISCSI_AUTH_SHIFT) & EFIDP_ISCSI_AUTH_NONE ? "None" : \
				      (dp->iscsi.options >> EFIDP_ISCSI_CHAP_SHIFT) & EFIDP_ISCSI_CHAP_UNI ? "CHAP_UNI" : "CHAP_BI",
			      dp->iscsi.protocol == 0 ? "TCP" : "Unknown");
		break;
			      }
	case EFIDP_MSG_VLAN:
		off += format(buf, size, off, "Vlan(%d)", dp->vlan.vlan_id);
		break;
	case EFIDP_MSG_SAS_EX:
		off += format_sas(buf, size, dp);
		break;
	case EFIDP_MSG_NVME:
		off += format(buf, size, off, "NVMe(0x%"PRIx32","
			      "%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X)",
			      dp->nvme.namespace_id, dp->nvme.ieee_eui_64[0],
			      dp->nvme.ieee_eui_64[1], dp->nvme.ieee_eui_64[2],
			      dp->nvme.ieee_eui_64[3], dp->nvme.ieee_eui_64[4],
			      dp->nvme.ieee_eui_64[5], dp->nvme.ieee_eui_64[6],
			      dp->nvme.ieee_eui_64[7]);
		break;
	case EFIDP_MSG_URI: {
		size_t sz = efidp_node_size(dp) - offsetof(efidp_uri, uri);
		char uri[sz + 1];
		memcpy(uri, dp->uri.uri, sz);
		uri[sz] = '\0';
		off += format(buf, size, off, "Uri(%s)", uri);
		break;
			    }
	case EFIDP_MSG_UFS:
		off += format(buf, size, off, "UFS(%d,0x%02x)",
			      dp->ufs.target_id, dp->ufs.lun);
		break;
	case EFIDP_MSG_SD:
		off += format(buf, size, off, "SD(%d)", dp->sd.slot_number);
		break;
	default:
		off += format(buf, size, off, "Msg(%d,", dp->subtype);
		off += format_hex(buf, size, off, (uint8_t *)dp+4,
				  efidp_node_size(dp)-4);
		off += format(buf,size,off,")");
		break;
	}
	return off;
}