📄 isr_as.c
字号:
/*
** Kenobi2 version 1.3
**
** ** This code has been made to check/learn the 1161 functionalities **
** ** Release 25-Feb-2002 **
**
** OKANO, Akifumi
**
** Computing Segment, Semisonductors Div, Philips Japan Ltd.
** akifumi.okano@philips.com
** +81-3-3740-4668
*/
// _MiniKit conditional compilation added 31-Oct-2001 Okano
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include "stdio.h"
#include "isr.h"
#include "isr_as.h"
#include "hc_comm.h"
#include "hw_acces.h"
#include "data_tr.h"
#include "ui.h"
#include "dev_ep.h"
#include "general.h"
#include "beep.h"
void isr_flag_handler( void );
device_instance *device_at_root_hub[ NUMBER_OF_ROOT_HUB_PORT ] = {
NULL,
NULL
};
void isr_flag_routine_dspatch( void )
{
// isr_flag_monitor(); /* in debug.c */
isr_flag_handler();
}
void isr_flag_handler( void )
{
unsigned short flag_mask; /* this mask shold be set to */
flag_mask = SOFITInt | ATLInt | AllEOTInterrupt;
if ( !(g_isr_flag & ~flag_mask) )
return;
if ( g_isr_flag & RHSC )
{
g_isr_flag &= ~RHSC;
rh_event_handler();
}
}
unsigned short HcRhPortStatusComm[2] = {
Com32_HcRhPortStatus1,
Com32_HcRhPortStatus2
};
void rh_event_handler( void )
{
static unsigned long rh_prev_status[ NUMBER_OF_ROOT_HUB_PORT ] = {
0x00000000,
0x00000000
};
unsigned long rh_status;
unsigned long rh_status_delta;
int i,
j;
#ifdef _MiniKit
if( reset_static(0)==1 )
{
rh_prev_status[0]=0;
rh_prev_status[1]=0;
reset_static(2);
}
#endif
for ( i = 0; i < 2; i++ )
{
rh_status = read_register32( HcRhPortStatusComm[ i ] );
rh_status_delta = rh_status ^ rh_prev_status[ i ]; // Which bit is updated?
if ( !rh_status_delta )
continue;
if ( rh_status & rh_status_delta & 0x00000001 ) // Device connected!
{
wait_ms( 100 ); // Need to wait before reset to handle bounce
write_register32( HcRhPortStatusComm[ i ], 0x00000010 ); // Set port reset
mprintf( LIGHTGRAY, CONTINUE, "\r\ndetected a connection @ port%d\r\n", i + 1 );
while ( read_register32( HcRhPortStatusComm[ i ]) & 0x00000010 ) // Polling port reset status (waiting for finishing port reset)
;
wait_ms( 100 ); // Reset recovery time
if ( NULL == (device_at_root_hub[ i ] = create_device( (rh_status >> 9) )) ) // Do enumeration
mprintf( YELLOW, CONTINUE, "\r\nWarning : device on port%d may have problem @ enum. process\r\n", i + 1 );
else
{
#ifndef NoBEEP
if ( check_interface_class_ID( device_at_root_hub[ i ], AUDIO_CLASS_INTERFACE ) )
beep( 886.00, 1.20, DECAY, POLY );
else
beep( 443.00, 1.00, DECAY, POLY );
#endif
mprintf( WHITE, CONTINUE, "\r\n" );
for ( j = 0; j < 5; j++ )
{
// mprintf( (j & 0x1) ? BLACK : WHITE, CONTINUE, "device enumerated (address=%d) [%p] @ port%d\r", device_at_root_hub[ i ]->address, device_at_root_hub[ i ], i + 1 );
mprintf( (j & 0x1) ? BLACK : WHITE, CONTINUE, "device enumerated (address=%d) @ port%d\r", device_at_root_hub[ i ]->address, i + 1 );
wait_ms( 350 );
}
mprintf( WHITE, CONTINUE, "\r\n" );
show_device_string_descriptors( device_at_root_hub[ i ] );
// device_infomation_viewer( device_at_root_hub[ i ] );
}
}
else if ( ~rh_status & rh_status_delta & 0x00000001 )
{
mprintf( LIGHTGRAY, CONTINUE, "\r\ndetected a disconnecttion @ port%d\r\n", i + 1 );
// mprintf( RED, CONTINUE, "device (address=%d) disposed [%p]\r\n", dvi_ptr->address, dvi_ptr );
if ( device_at_root_hub[ i ] == NULL )
{
mprintf( LIGHTGRAY, CONTINUE, "un-enumerated device removed from port%d\r\n", i + 1 );
}
else
{
mprintf( WHITE, CONTINUE, "device (address=%d) disposed\r\n", device_at_root_hub[ i ]->address );
dispose_device( device_at_root_hub[ i ] );
}
device_at_root_hub[ i ] = NULL;
#ifndef NoBEEP
beep( 660, 0.30, DECAY, POLY );
#endif
}
rh_prev_status[ i ] = rh_status;
}
}
device_instance *device_on_port( unsigned char port_num )
{
return ( device_at_root_hub[ port_num - 1 ] );
}
#ifdef _MiniKit
int reset_static(int mode)
{
static my_mode=0;
if(mode==1) {my_mode=1;} // reset
if(mode==2) {my_mode=0;} // do not reset
return(my_mode);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -