xbox.cpp: more usb, now nearly ends enumeration (nw)

This commit is contained in:
yz70s 2016-02-17 20:55:16 +01:00
parent f99431e5c8
commit ea9ec26cad
3 changed files with 78 additions and 16 deletions

View File

@ -188,6 +188,29 @@ enum USBDescriptorType {
ENDPOINT=5
};
enum USBRequestType
{
StandardType=0,
ClassType,
VendorType,
ReservedType
};
enum USBRequestRecipient
{
DeviceRecipient=0,
InterfaceRecipient,
EndpointRecipient,
OtherRecipient
};
enum USBDeviceState
{
DefaultState,
AddressState,
ConfiguredState
};
class ohci_function_device {
public:
ohci_function_device(running_machine &machine);
@ -198,11 +221,14 @@ private:
void add_configuration_descriptor(USBStandardConfigurationDescriptor &descriptor);
void add_interface_descriptor(USBStandardInterfaceDescriptor &descriptor);
void add_endpoint_descriptor(USBStandardEndpointDescriptor &descriptor);
int handle_nonstandard_request(USBSetupPacket *setup);
int state;
int address;
int newaddress;
int controldirection;
int controltype;
int controlrecipient;
int configurationvalue;
bool settingaddress;
int remain;
UINT8 *position;

View File

@ -841,6 +841,7 @@ static USBStandardEndpointDescriptor enddesc02 = {7,5,0x02,3,0x20,4};
ohci_function_device::ohci_function_device(running_machine &machine)
{
state = DefaultState;
descriptors = auto_alloc_array(machine, UINT8, 1024);
descriptors_pos = 0;
address = 0;
@ -848,6 +849,7 @@ ohci_function_device::ohci_function_device(running_machine &machine)
controldirection = 0;
controltype = 0;
controlrecipient = 0;
configurationvalue = 0;
remain = 0;
position = nullptr;
settingaddress = false;
@ -861,25 +863,25 @@ ohci_function_device::ohci_function_device(running_machine &machine)
void ohci_function_device::add_device_descriptor(USBStandardDeviceDescriptor &descriptor)
{
memcpy(descriptors + descriptors_pos, &descriptor, sizeof(descriptor));
descriptors_pos += sizeof(descriptor);
descriptors_pos += descriptor.bLength;
}
void ohci_function_device::add_configuration_descriptor(USBStandardConfigurationDescriptor &descriptor)
{
memcpy(descriptors + descriptors_pos, &descriptor, sizeof(descriptor));
descriptors_pos += sizeof(descriptor);
descriptors_pos += descriptor.bLength;
}
void ohci_function_device::add_interface_descriptor(USBStandardInterfaceDescriptor &descriptor)
{
memcpy(descriptors + descriptors_pos, &descriptor, sizeof(descriptor));
descriptors_pos += sizeof(descriptor);
descriptors_pos += descriptor.bLength;
}
void ohci_function_device::add_endpoint_descriptor(USBStandardEndpointDescriptor &descriptor)
{
memcpy(descriptors + descriptors_pos, &descriptor, sizeof(descriptor));
descriptors_pos += sizeof(descriptor);
descriptors_pos += descriptor.bLength;
}
void ohci_function_device::execute_reset()
@ -890,9 +892,11 @@ void ohci_function_device::execute_reset()
int ohci_function_device::execute_transfer(int address, int endpoint, int pid, UINT8 *buffer, int size)
{
int descriptortype;// descriptorindex;
if (endpoint == 0) {
if (pid == SetupPid) {
struct USBSetupPacket *p=(struct USBSetupPacket *)buffer;
USBSetupPacket *p=(struct USBSetupPacket *)buffer;
// define direction 0:host->device 1:device->host
controldirection = (p->bmRequestType & 128) >> 7;
// case ==1, IN data stage and OUT status stage
@ -901,9 +905,10 @@ int ohci_function_device::execute_transfer(int address, int endpoint, int pid, U
controltype = (p->bmRequestType & 0x60) >> 5;
controlrecipient = p->bmRequestType & 0x1f;
position = nullptr;
// number of byte to transfer in data stage (0 no data stage)
remain = p->wLength;
// if standard
if (controltype == 0) {
// if standard device request
if ((controltype == StandardType) && (controlrecipient == DeviceRecipient)) {
switch (p->bRequest) {
case GET_STATUS:
case CLEAR_FEATURE:
@ -914,29 +919,39 @@ int ohci_function_device::execute_transfer(int address, int endpoint, int pid, U
settingaddress = true;
break;
case GET_DESCRIPTOR:
if ((p->wValue >> 8) == DEVICE) { // device descriptor
//p->wValue & 255;
descriptortype = p->wValue >> 8;
//descriptorindex = p->wValue & 255;
if (descriptortype == DEVICE) { // device descriptor
position = descriptors;
remain = descriptors[0];
}
else if ((p->wValue >> 8) == CONFIGURATION) { // configuration descriptor
else if (descriptortype == CONFIGURATION) { // configuration descriptor
position = descriptors + 18;
remain = descriptors[18+2];
}
else if ((p->wValue >> 8) == INTERFACE) { // interface descriptor
else if (descriptortype == INTERFACE) { // interface descriptor
position = descriptors + 18 + 9;
remain = descriptors[18 + 9];
}
else if ((p->wValue >> 8) == ENDPOINT) { // endpoint descriptor
else if (descriptortype == ENDPOINT) { // endpoint descriptor
position = descriptors + 18 + 9 + 9;
remain = descriptors[18 + 9 + 9];
}
else
remain = 0;
if (remain > p->wLength)
remain = p->wLength;
break;
case SET_CONFIGURATION:
if (p->wValue == 0)
state = AddressState;
else {
configurationvalue = p->wValue;
state = ConfiguredState;
}
break;
case SET_DESCRIPTOR:
case GET_CONFIGURATION:
case SET_CONFIGURATION:
case GET_INTERFACE:
case SET_INTERFACE:
case SYNCH_FRAME:
@ -944,18 +959,21 @@ int ohci_function_device::execute_transfer(int address, int endpoint, int pid, U
break;
}
}
else
return handle_nonstandard_request(p);
size = 0;
}
else if (pid == InPid) {
// if no data has been transferred (except for the setup stage)
// and the lenght of this IN transaction is 0
// assume this is the status stage
if (size == 0) {
if ((size == 0) && (remain == 0)) {
if (settingaddress == true)
{
// set of address is active at end of status stage
address = newaddress;
settingaddress = false;
state = AddressState;
}
return 0;
}
@ -987,9 +1005,27 @@ int ohci_function_device::execute_transfer(int address, int endpoint, int pid, U
}
}
}
else
return -1;
return size;
}
int ohci_function_device::handle_nonstandard_request(USBSetupPacket *setup)
{
if ((controltype == VendorType) && (controlrecipient == InterfaceRecipient))
{
if (setup->bRequest == GET_DESCRIPTOR)
{
if (setup->wValue == 0x4200)
{
position = nullptr;
remain = 0;
}
}
}
return 0;
}
void xbox_base_state::usb_ohci_interrupts()
{
if (((ohcist.hc_regs[HcInterruptStatus] & ohcist.hc_regs[HcInterruptEnable]) != 0) && ((ohcist.hc_regs[HcInterruptEnable] & MasterInterruptEnable) != 0))

View File

@ -2593,12 +2593,12 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN
printf("A:%08X MTHD:%08X D:%08X\n\r",address,maddress,data);
#endif
if (maddress == 0x17fc) {
#if 1 // useful while debugging to see what coordinates have been used
#if 0 // useful while debugging to see what coordinates have been used
static int debugvc = 0;
if (debugvc)
if (data == 0)
{
//printf("%d %d\n\r", primitive_type, vertex_first);
printf("%d %d\n\r", (int)primitive_type, vertex_first);
for (int n = 0; n < vertex_first; n++)
printf("%d X:%f Y:%f Z:%f W:%f x:%f y:%f\n\r", n, vertex_software[n].attribute[0].fv[0], vertex_software[n].attribute[0].fv[1], vertex_software[n].attribute[0].fv[2], vertex_software[n].attribute[0].fv[3], vertex_xy[n].x, vertex_xy[n].y);
}