Browse Source

test psaux

git-svn-id: file:///svn/pmon-all/pmon-all@85 214b0138-1524-0410-9122-e5cb4b5bc56c
master
root 18 years ago
parent
commit
e993119225
  1. 8
      Targets/Bonito2edev/Bonito/mycmd.c
  2. 5
      Targets/Bonito2edev/Bonito/tgt_machdep.c
  3. 2
      Targets/Bonito2edev/conf/Bonito
  4. BIN
      examples/hello/hello
  5. 40
      examples/hello/hello.c
  6. 10
      pmon/arch/mips/machdep.c
  7. 182
      pmon/dev/kbd.c
  8. 2
      zloader/Makefile.2edev

8
Targets/Bonito2edev/Bonito/mycmd.c

@ -4,8 +4,8 @@
//-------------------------------------------PNP------------------------------------------
// MB PnP configuration register
#define PNP_KEY_ADDR (PCI_IO_SPACE_BASE+0x3f0)
#define PNP_DATA_ADDR (PCI_IO_SPACE_BASE+0x3f1)
#define PNP_KEY_ADDR (0xbfd00000+0x3f0)
#define PNP_DATA_ADDR (0xbfd00000+0x3f1)
void PNPSetConfig(char Index, char data);
@ -121,8 +121,8 @@ int count,i;
static const Cmd Cmds[] =
{
{"MyCmds"},
{"pnpr", "LDN index", 0, "pnpr LDN(logic device NO) index", PnpRead, 0, 99, CMD_REPEAT},
{"pnpw", "LDN index value", 0, "pnpw index value", PnpWrite, 0, 99, CMD_REPEAT},
{"pnpr", "index", 0, "pnpr index", PnpRead, 0, 99, CMD_REPEAT},
{"pnpw", "index value", 0, "pnpw index value", PnpWrite, 0, 99, CMD_REPEAT},
{"dumpsis", "", 0, "dump sis registers", dumpsis, 0, 99, CMD_REPEAT},
{"i2cread", "slot offset count", 0, "read i2c info", cmd_i2cread, 0, 99, CMD_REPEAT},
{0, 0}

5
Targets/Bonito2edev/Bonito/tgt_machdep.c

@ -309,6 +309,7 @@ unsigned int addr;
* to output configuration and debug information with printf.
*/
extern void vt82c686_init(void);
int psaux_init(void);
void
tgt_devconfig()
@ -324,11 +325,15 @@ tgt_devconfig()
config_init();
configure();
#if NMOD_VGACON >0
if(getenv("nokbd"))
rc=1;
else
rc=kbd_initialize();
printf("%s\n",kbd_error_msgs[rc]);
if(!rc){
kbd_available=1;
}
psaux_init();
#endif
printf("devconfig done.\n");
}

2
Targets/Bonito2edev/conf/Bonito

@ -154,7 +154,7 @@ wd* at pciide? channel ? drive ? flags 0x0000
#### Pseudo devices
pseudo-device loop 1 # network loopback
#ide_cd* at pciide? channel ? drive ? flags 0x0001
ide_cd* at pciide? channel ? drive ? flags 0x0001
select iso9660
option IDECD
#option HAVE_NB_SERIAL

BIN
examples/hello/hello

Binary file not shown.

40
examples/hello/hello.c

@ -56,16 +56,56 @@ struct callvectors *callvec;
void __gccmain(void);
void __gccmain(void){}
#define linux_outb(val,port) *(volatile unsigned char *)(0xbfd00000+port)=val
#define linux_outb_p(val,port) (*(volatile unsigned char *)0xbfc00000,linux_outb(val,port),*(volatile unsigned char *)0xbfc00000)
void init_8259A(int auto_eoi)
{
linux_outb(0xff, 0x21); /* mask all of 8259A-1 */
linux_outb(0xff, 0xA1); /* mask all of 8259A-2 */
/*
* linux_outb_p - this has to work on a wide range of PC hardware.
*/
linux_outb_p(0x11, 0x20); /* ICW1: select 8259A-1 init */
linux_outb_p(0x00, 0x21); /* ICW2: 8259A-1 IR0-7 mapped to 0x00-0x07 */
linux_outb_p(0x04, 0x21); /* 8259A-1 (the master) has a slave on IR2 */
if (auto_eoi)
linux_outb_p(0x03, 0x21); /* master does Auto EOI */
else
linux_outb_p(0x01, 0x21); /* master expects normal EOI */
linux_outb_p(0x11, 0xA0); /* ICW1: select 8259A-2 init */
linux_outb_p(0x08, 0xA1); /* ICW2: 8259A-2 IR0-7 mapped to 0x08-0x0f */
linux_outb_p(0x02, 0xA1); /* 8259A-2 is a slave on master's IR2 */
linux_outb_p(0x01, 0xA1); /* (slave's support for AEOI in flat mode
is to be investigated) */
}
int
main(int argc, char **argv, char **env, struct callvectors *cv)
{
char str[256];
char **ev;
int i;
unsigned stat;
callvec = cv;
printf("\n\nHello! This is the 'hello' program!\n\n");
init_8259A(0);
// asm("mfc0 $2,$12;\r\nor $2,0xf01;\r\n mtc0 $2,$12\r\n":::"$2");
asm("mfc0 %0,$12;":"=r"(stat));
stat|=0x1|(1<<13);
asm("mtc0 %0,$12;"::"r"(stat));
asm("mfc0 %0,$12;":"=r"(stat));
printf("stat=%x\n",stat);
*(volatile char *)0xbfd00021=0;
*(volatile char *)0xbfd000a1=0;
gets(str);
return 0;
printf("It was invoked with:\n");
for (i = 0; i < argc; i++) {
printf("Arg %2d: %s\n", i, argv[i]);

10
pmon/arch/mips/machdep.c

@ -310,10 +310,19 @@ md_getpc(struct trapframe *tf)
* is to decode the exception and return the exception
* type to the caller for further processing.
*/
#define MYINB(port) *(volatile unsigned char *)(port)
int
md_exc_type(struct trapframe *frame)
{
switch((frame->cause & CR_EXC_CODE) >> CR_EXC_CODE_SHIFT) {
case T_INT:
{
struct trapframe *cpuinfo;
cpuinfo = cpuinfotab[0];
printf("inb(0x20)=%x inb(0x21)=%x inb(0xa0)%x inb(0xa1)=%x\n",MYINB(0xbfd00020),MYINB(0xbfd00021),MYINB(0xbfd000a0),MYINB(0xbfd000a1));
cpuinfo->sr|=1;
_go();
}
case T_BREAK:
case T_TRAP:
return(EXC_BPT);
@ -326,7 +335,6 @@ md_exc_type(struct trapframe *frame)
#ifdef BONITOEL
return(EXC_RES);
#endif
case T_INT:
case T_TLB_MOD:
case T_TLB_LD_MISS:
case T_TLB_ST_MISS:

182
pmon/dev/kbd.c

@ -435,6 +435,7 @@ int kbd_translate(unsigned char scancode, unsigned char *keycode)
return 1;
}
static inline void handle_mouse_event(unsigned char scancode);
/*
* This reads the keyboard status port, and does the
* appropriate action.
@ -460,7 +461,7 @@ static unsigned char handle_kbd_event(void)
#endif
{
if (status & KBD_STAT_MOUSE_OBF)
;//handle_mouse_event(scancode);
handle_mouse_event(scancode);
else
handle_keyboard_event(scancode);
}
@ -665,3 +666,182 @@ void pckbd_leds(unsigned char leds)
}
}
//--------------------------------------mouse-------------------------------
#ifdef CONFIG_PSMOUSE
#endif
static int aux_reconnect = 0;
#define AUX_RECONNECT1 0xaa /* scancode1 when ps2 device is plugged (back) in */
#define AUX_RECONNECT2 0x00 /* scancode2 when ps2 device is plugged (back) in */
static int aux_count;
/* used when we send commands to the mouse that expect an ACK. */
static unsigned char mouse_reply_expected;
#define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT)
#define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT)
#define MAX_RETRIES 60 /* some aux operations take long time*/
static void __aux_write_ack(int val);
static inline void handle_mouse_event(unsigned char scancode)
{
static unsigned char prev_code;
if (mouse_reply_expected) {
if (scancode == AUX_ACK) {
mouse_reply_expected--;
return;
}
mouse_reply_expected = 0;
}
else if(scancode == AUX_RECONNECT2 && prev_code == AUX_RECONNECT1
&& aux_reconnect) {
printf ("PS/2 mouse reconnect detected\n");
__aux_write_ack(AUX_ENABLE_DEV); /* ping the mouse :) */
return;
}
prev_code = scancode;
if (getenv("aux")) {
printf("mouse:%x\n",scancode);
}
}
static void kb_wait(void)
{
unsigned long timeout = KBC_TIMEOUT;
do {
/*
* "handle_kbd_event()" will handle any incoming events
* while we wait - keypresses or mouse movement.
*/
unsigned char status = handle_kbd_event();
if (! (status & KBD_STAT_IBF))
return;
mdelay(1);
timeout--;
} while (timeout);
#ifdef KBD_REPORT_TIMEOUTS
printf("Keyboard timed out[1]\n");
#endif
}
/*
* Check if this is a dual port controller.
*/
static int detect_auxiliary_port(void)
{
unsigned long flags;
int loops = 10;
int retval = 0;
/* Put the value 0x5A in the output buffer using the "Write
* Auxiliary Device Output Buffer" command (0xD3). Poll the
* Status Register for a while to see if the value really
* turns up in the Data Register. If the KBD_STAT_MOUSE_OBF
* bit is also set to 1 in the Status Register, we assume this
* controller has an Auxiliary Port (a.k.a. Mouse Port).
*/
kb_wait();
kbd_write_command(KBD_CCMD_WRITE_AUX_OBUF);
kb_wait();
kbd_write_output(0x5a); /* 0x5a is a random dummy value. */
do {
unsigned char status = kbd_read_status();
if (status & KBD_STAT_OBF) {
(void) kbd_read_input();
if (status & KBD_STAT_MOUSE_OBF) {
printf("Detected PS/2 Mouse Port.\n");
retval = 1;
}
break;
}
mdelay(1);
} while (--loops);
return retval;
}
/*
* Send a byte to the mouse.
*/
static void aux_write_dev(int val)
{
unsigned long flags;
kb_wait();
kbd_write_command(KBD_CCMD_WRITE_MOUSE);
kb_wait();
kbd_write_output(val);
}
/*
* Send a byte to the mouse & handle returned ack
*/
static void __aux_write_ack(int val)
{
kb_wait();
kbd_write_command(KBD_CCMD_WRITE_MOUSE);
kb_wait();
kbd_write_output(val);
/* we expect an ACK in response. */
mouse_reply_expected++;
kb_wait();
}
static void aux_write_ack(int val)
{
unsigned long flags;
__aux_write_ack(val);
}
static void kbd_write_cmd(int cmd)
{
unsigned long flags;
kb_wait();
kbd_write_command(KBD_CCMD_WRITE_MODE);
kb_wait();
kbd_write_output(cmd);
}
int psaux_init(void)
{
int retval;
if (!detect_auxiliary_port())
return -1;
kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable Aux. */
aux_write_ack(AUX_SET_SAMPLE);
aux_write_ack(100); /* 100 samples/sec */
aux_write_ack(AUX_SET_RES);
aux_write_ack(3); /* 8 counts per mm */
aux_write_ack(AUX_SET_SCALE21); /* 2:1 scaling */
kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable aux device. */
kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */
//---------------------------------------
kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the
auxiliary port on
controller. */
aux_write_ack(AUX_ENABLE_DEV); /* Enable aux device */
kbd_write_cmd(AUX_INTS_ON); /* Enable controller ints */
mdelay(2); /* Ensure we follow the kbc access delay rules.. */
send_data(KBD_CMD_ENABLE); /* try to workaround toshiba4030cdt problem */
return 0;
}

2
zloader/Makefile.2edev

@ -1,6 +1,6 @@
TARGET=Bonito2edev
TARGETEL=Bonito
START=start.o
MEMSIZE=128
MEMSIZE=256
include Makefile.inc

Loading…
Cancel
Save