C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 1 C51 COMPILER V7.06, COMPILATION OF MODULE X1 OBJECT MODULE PLACED IN X1.OBJ COMPILER INVOKED BY: d:\Keil777\C51\BIN\C51.EXE X1.C BROWSE DEBUG OBJECTEXTEND stmt level source 1 2 #include 3 #include *** WARNING C318 IN LINE 3 OF X1.C: can't open file 'conio.h' 4 #include *** WARNING C318 IN LINE 4 OF X1.C: can't open file 'dos.h' 5 #include 6 #include *** WARNING C318 IN LINE 6 OF X1.C: can't open file 'bios.h' 7 #include *** WARNING C318 IN LINE 7 OF X1.C: can't open file 'mem.h' 8 #include *** WARNING C318 IN LINE 8 OF X1.C: can't open file 'graphics.h' 9 #include 10 #include *** WARNING C318 IN LINE 10 OF X1.C: can't open file 'io.h' 11 #include *** WARNING C318 IN LINE 11 OF X1.C: can't open file 'fcntl.h' 12 13 #include "isp1362.h" 14 #include "isa290.h" 15 #include "reg.h" 16 #include "cheeyu.h" 17 18 #define version 1.18 19 // 1.18 Release Version 20 21 #define TRUE 1 22 #define FALSE 0 23 24 unsigned int temp; 25 unsigned int hc_data; 26 unsigned int hc_com; 27 unsigned int dc_data; 28 unsigned int dc_com; 29 unsigned int g_ISA_base_address; 30 unsigned int g_1161_command_address; 31 unsigned int g_1161_data_address; 32 unsigned char g_host_IRQ_num; 33 unsigned char g_is_PCI; 34 35 #ifdef __cplusplus #define __CPPARGS ... #else 38 #define __CPPARGS 39 #endif 40 41 #define PIC1_base 0x20 // Master Interrupt Controller 42 #define PIC1_mask 0x21 43 #define PIC2_base 0xA0 // Slave Interrupt Controller 44 #define PIC2_mask 0xA1 45 #define EOI 0x20 // Non-specific End Of Interrupt 46 47 void open_interrupt(void); 48 void close_interrupt(void); C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 2 49 void end_interrupt(void); 50 void interrupt far intserv(__CPPARGS); *** ERROR C141 IN LINE 50 OF X1.C: syntax error near 'interrupt' *** ERROR C129 IN LINE 50 OF X1.C: missing ';' before 'intserv' 51 void interrupt far(*oldfunc)(__CPPARGS); 52 int get_int_num( int irq_num ); 53 void get_PIC_masks( int *m_lower , int *m_higher, int irq_num ); 54 55 int x=0; 56 int global_upint=0; 57 long global_intstatus=0; 58 int int_q=0; 59 60 void interrupt far intserv(__CPPARGS) 61 { 62 disable(); 63 end_interrupt(); 64 65 x++; 66 if(int_q==0) 67 { 68 global_upint=r16(HcUpInt); 69 global_intstatus=r32(HcIntStatus); 70 int_q++; 71 } 72 73 w16(HcUpInt, 0xFFFF); 74 w32(HcIntStatus, 0xFFFFFFFF); 75 w16(HcUpInt, 0xFFFF); 76 w32(HcIntStatus, 0xFFFFFFFF); 77 78 enable(); 79 } 80 81 int get_int_num( int irq_num ) 82 { 83 #define LowerINTOffset 0x08 84 #define HigherINTOffset 0x68 85 86 return ( ( irq_num < 8 ) ? irq_num + LowerINTOffset : irq_num + HigherINTOffset ); 87 } 88 89 90 void get_PIC_masks( int *m_lower , int *m_higher, int irq_num ) 91 { 92 if ( irq_num < 8 ) 93 { 94 *m_lower = 0x01 << irq_num; 95 *m_higher = 0x00; 96 } 97 else 98 { 99 *m_lower = 0x04; /* for cascaded IRQ(IRQ2) */ 100 *m_higher = 0x01 << (irq_num - 8); 101 } 102 } 103 104 void open_interrupt(void) 105 { 106 unsigned int temp; 107 int mask1, mask2; 108 int int_num, irq_num; C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 3 109 int PIC_mask1, PIC_mask2; 110 111 disable(); // Disable all ints 112 outportb(PIC2_base,EOI); // Reset PIC2 113 outportb(PIC1_base,EOI); // Reset PIC1 114 115 irq_num = g_host_IRQ_num; 116 int_num = get_int_num( irq_num ); 117 get_PIC_masks( &PIC_mask1, &PIC_mask2, irq_num ); 118 119 oldfunc=getvect(int_num); // Save old interrupt vector 120 setvect(int_num, intserv); // intserv is new ISR 121 122 mask1=inportb(PIC1_mask); 123 outportb(PIC1_mask, mask1&~PIC_mask1); // Clear bit 2(IRQ2) - Enable Master IRQ2 124 mask2= inportb(PIC2_mask); 125 outportb(PIC2_mask, mask2&~PIC_mask2); // Clear bit 2(IRQ10) (Enable IRQ10) 126 127 end_interrupt(); 128 enable(); 129 } 130 131 void close_interrupt() 132 { 133 int mask, irq_num, int_num; 134 int PIC_mask1, PIC_mask2; 135 disable(); 136 137 irq_num = g_host_IRQ_num; 138 int_num = get_int_num( irq_num ); 139 get_PIC_masks( &PIC_mask1, &PIC_mask2, irq_num ); 140 141 142 setvect(int_num, oldfunc); // Set back to old vector address 143 outportb( 0x21, inportb( 0x21 ) | PIC_mask1 ); 144 outportb( 0xA1, inportb( 0xA1 ) | PIC_mask2 ); 145 enable(); 146 } 147 148 void end_interrupt(void) 149 { 150 outportb(PIC2_base,EOI); // Send EOI to PIC2 151 outportb(PIC1_base,EOI); // Send EOI to PIC1 152 } 153 154 155 void decode_dev(unsigned int *reply,char mode,char startx) 156 { 157 int starty; 158 159 starty=5; 160 161 if(mode==1) 162 { 163 gotoxy(startx,starty + 1); 164 printf("DescriptorType :0x%8X " ,(reply[0]&0xFF00)>>8); 165 gotoxy(startx,starty + 2); 166 printf("DescriptorSize : %8d " ,reply[0]&0x00FF); 167 gotoxy(startx,starty + 3); 168 printf("USB DeviceType : %2X.%2X ",(reply[1]&0xFF00)>>8,reply[1]&0x00FF); 169 gotoxy(startx,starty + 4); 170 printf("Class :0x%8X " ,reply[2]&0x00FF); C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 4 171 gotoxy(startx,starty + 5); 172 printf("SubClass :0x%8X " ,(reply[2]&0xFF00)>>8); 173 gotoxy(startx,starty + 6); 174 printf("bDeviceProtocol:0x%8X " ,reply[3]&0x00FF); 175 gotoxy(startx,starty + 7); 176 printf("bMaxPacSize 0 :0x%8X " ,(reply[3]&0xFF00)>>8); 177 gotoxy(startx,starty + 8); 178 printf("VendorID :0x%8X " ,reply[4]); 179 gotoxy(startx,starty + 9); 180 printf("ProductID :0x%8X " ,reply[5]); 181 gotoxy(startx,starty +10); 182 printf("BCD Device :0x%8X " ,reply[6]); 183 gotoxy(startx,starty +11); 184 printf("iManufacturer :0x%8X " ,(reply[7]&0x00FF) ); 185 gotoxy(startx,starty +12); 186 printf("iProduct :0x%8X " ,(reply[7]&0xFF00)>>8); 187 gotoxy(startx,starty +13); 188 printf("SerialNumber :0x%8X " ,(reply[8]&0x00FF)); 189 gotoxy(startx,starty +14); 190 printf("No of Config :0x%8X " ,(reply[8]&0xFF00)>>8); 191 } 192 } 193 194 void enu(void) 195 { 196 unsigned int cbuf[128]; 197 unsigned int rbuf[128]; 198 199 unsigned char udn[64]; 200 201 //atl parameters 202 unsigned long atl_skip=0xFFFFFFFE; 203 unsigned long atl_last=0x00000001; 204 205 unsigned int atl_blk_size=64; 206 unsigned int atl_cnt=1; 207 unsigned int atl_timeout=200; 208 unsigned int mycode; 209 unsigned int cnt,name_length; 210 unsigned int iManufacturer,iProduct; 211 unsigned long rhp1,rhp2; 212 unsigned int user_in=0; 213 214 clrscr(); 215 set_operational(); 216 enable_port(); 217 delay(300); 218 219 reset_usb(); 220 erase_all(); 221 set_operational(); 222 enable_port(); 223 delay(300); 224 225 226 w16(HcBufStatus,0x00); 227 228 //Setup ATL Parameters 229 w32(HcATLSkip,atl_skip); 230 w32(HcATLLast,atl_last); 231 w16(HcATLBlkSize,atl_blk_size); 232 w16(HcATLThrsCnt,atl_cnt); C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 5 233 w16(HcATLTimeOut,atl_timeout); 234 w16(HcUpIntEnable,0x100); 235 236 mycode=assign_address(1,2,0); 237 238 if((mycode&(0xF0F0))!=0) 239 { 240 printf("\nError in assigning address to USB devices, MyCode:%04X",mycode); 241 getch(); 242 clrscr(); 243 return 0; 244 } 245 246 mycode=get_control(rbuf,1,'D',0,1); 247 gotoxy(1,2); 248 printf("GetDesc 1:%4X",mycode); 249 if(mycode==0x0300) 250 { 251 decode_dev(rbuf,1,1); 252 iManufacturer = rbuf[7]&0xFF; 253 iProduct = (rbuf[7]&0xFF00)>>8; 254 255 addr_info(1,'W','O',iManufacturer); 256 addr_info(1,'W','P',iProduct); 257 } 258 259 mycode=get_control(rbuf,2,'D',0,2); 260 gotoxy(41,2); 261 printf("GetDesc 2:%4X",mycode); 262 if(mycode==0x0300) 263 { 264 decode_dev(rbuf,1,41); 265 iManufacturer = rbuf[7]&0xFF; 266 iProduct = (rbuf[7]&0xFF00)>>8; 267 268 addr_info(2,'W','O',iManufacturer); 269 addr_info(2,'W','P',iProduct); 270 } 271 272 mycode=get_control(rbuf,1,'S',addr_info(1,'R','O',0),1); 273 274 if(mycode==0x0300) 275 { 276 convert_string(udn,rbuf); 277 gotoxy(1,3); 278 printf("Manufr : %s ",udn); 279 } 280 281 mycode=get_control(rbuf,1,'S',addr_info(1,'R','P',0),1); 282 283 if(mycode==0x0300) 284 { 285 convert_string(udn,rbuf); 286 gotoxy(1,4); 287 printf("Product : %s ",udn); 288 } 289 290 mycode=get_control(rbuf,2,'S',addr_info(2,'R','O',0),2); 291 292 if(mycode==0x0300) 293 { 294 convert_string(udn,rbuf); C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 6 295 gotoxy(41,3); 296 printf("Manufr : %s ",udn); 297 } 298 299 mycode=get_control(rbuf,2,'S',addr_info(2,'R','P',0),2); 300 301 if(mycode==0x0300) 302 { 303 convert_string(udn,rbuf); 304 gotoxy(41,4); 305 printf("Product T: %s ",udn); 306 } 307 308 gotoxy(1,20); 309 addr_info(0,'D',0,0); 310 311 do 312 { 313 gotoxy(1,25); 314 printf("Frame Number = %8lX Press '1' to go back to main menu",r32(HcFmNo)); 315 316 user_in=read_key(0); 317 } 318 while(user_in!='1'); 319 } 320 321 322 323 void bmat(void) 324 { 325 int user_in; 326 int basey=370; 327 int line_space=10; 328 329 gui(); 330 331 clrscr(); 332 cleardevice(); 333 334 mem_init_mem(); 335 mem_map(); 336 337 do 338 { 339 e_box(320,418,638,110); 340 341 outtextxy(10,basey ,"Press 1 to reset memory using ABSOLUTE address"); 342 outtextxy(10,basey+line_space ,"Press 2 to run TortureTest on 1362"); 343 344 outtextxy(10,basey+(line_space*3),"Press 4 to display memory content details"); 345 outtextxy(10,basey+(line_space*4),"Press 5 to write sequential values"); 346 outtextxy(10,basey+(line_space*5),"Press 6 to perform randomised Write/Read"); 347 outtextxy(10,basey+(line_space*6),"Press 7 to refresh memory snapshot"); 348 outtextxy(10,basey+(line_space*7),""); 349 350 outtextxy(10,basey+(line_space*9),"Press 9 to exit submenu"); 351 352 do 353 { 354 delay(1); 355 user_in=read_key(0); 356 } C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 7 357 while(user_in==0); 358 359 switch(user_in) 360 { 361 case '1': erase_all(); mem_map(); break; 362 case '2': torture_test(); break; 363 364 case '4': see_buf(); break; 365 case '5': set_all(); mem_map(); break; 366 case '6': r_test(); break; 367 case '7': mem_map(); break; 368 case '8': break; 369 370 case '9': break; 371 372 } 373 } 374 while(user_in!='9'); 375 376 close_gui(); 377 } 378 379 void chip_reset(void) 380 { 381 w16(HcReset,0x00F6); 382 } 383 384 void suspend(void) 385 { 386 unsigned int mode; 387 unsigned int otgcontrol; 388 unsigned int user_in; 389 390 clrscr(); 391 392 gotoxy(35,12); 393 printf("\nSuspend"); 394 395 396 if (g_is_PCI == FALSE) w16(HcHWCfg , 0x002D ); 397 else w16(HcHWCfg , 0x0029 ); 398 w32(HcFmItv , 0x25002EDF); 399 w32(HcControl , 0x00000680); 400 w32(HcControl , 0x000006C0); 401 402 do 403 { 404 delay(10); 405 406 gotoxy(1,1); 407 printf("HcIntStatus = %8lX",r32(HcIntStatus) ); 408 409 delay(2); 410 gotoxy(1,1); 411 printf("HcIntStatus = %8lX",r32(HcIntStatus) ); 412 413 user_in=read_key(0); 414 } 415 while(user_in!='1'); 416 417 getch(); 418 } C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 8 419 420 void main(void) 421 { 422 unsigned int cnt; 423 unsigned int user_in; 424 unsigned int chip_id; 425 unsigned int hw_cfg; 426 unsigned int temp; 427 428 clrscr(); 429 430 if ( 0 != (findPCIdev(0x00068000, &g_ISA_base_address, &g_host_IRQ_num))) //jason add PnP 431 { 432 g_is_PCI = TRUE; 433 hc_data = g_ISA_base_address; 434 hc_com = g_ISA_base_address + 2; 435 dc_data = g_ISA_base_address + 4; 436 dc_com = g_ISA_base_address + 6; 437 set_pci_bridge(); 438 } 439 else 440 { 441 g_is_PCI = FALSE; 442 hc_data=0x290; 443 hc_com=0x292; 444 dc_data=0x294; 445 dc_com=0x296; 446 g_ISA_base_address=hc_data; 447 g_host_IRQ_num=0xa; 448 } 449 450 delay(100); 451 452 w16(HcATLLen,0x100); 453 w16(HcPTLLen,0x1840); 454 w16(HcINTLen,0x100); 455 456 _setcursortype(_NOCURSOR); 457 458 do 459 { 460 clrscr(); 461 printf("\nISP1362 %s HOST Controller - X2 Release Version %.2f",g_is_PCI ? "PCI" : "ISA",version); 462 printf("\n====================================================="); 463 printf("\n0 Chip Reset"); 464 printf("\n2 Port Monitor"); 465 printf("\n3 Enumeration"); 466 printf("\n4 Read HC Registers"); 467 printf("\n5 Mouse"); 468 printf("\n6 Register Read/Write Test"); 469 printf("\n7 BMAT Bitmapped Memory Analysis Tool"); 470 471 printf("\n\n9 Exit"); 472 chip_reset(); 473 printf("\n\n HcChipID : 0x%4X",r16(HcChipID)); 474 475 printf("\n\n HC base address: 0x%4X",g_ISA_base_address); 476 printf("\n HC IRQ used: 0x%X",g_host_IRQ_num); 477 478 user_in=read_key(1); 479 480 if(user_in=='0') {chip_reset();} C51 COMPILER V7.06 X1 08/02/2005 13:29:58 PAGE 9 481 482 if(user_in=='2') {port_monitor();} 483 if(user_in=='3') {enu();} 484 if(user_in=='4') {load_def(); gui(); read_registers(); close_gui();} 485 if(user_in=='5') {mouse();} 486 if(user_in=='6') {load_def(); gui(); wr_reg(); close_gui();} 487 if(user_in=='7') {bmat();} 488 } 489 while(user_in!='9'); 490 } C51 COMPILATION COMPLETE. 7 WARNING(S), 2 ERROR(S)