PS/2 cleanup
authorlekernel <sebastien.bourdeauducq@lekernel.net>
Tue, 29 Dec 2009 23:25:08 +0000 (00:25 +0100)
committerlekernel <sebastien.bourdeauducq@lekernel.net>
Tue, 29 Dec 2009 23:25:08 +0000 (00:25 +0100)
12 files changed:
boards/xilinx-ml401/rtl/system.v
cores/ps2/rtl/ps2.v
doc/system.tex
software/demo/Makefile
software/demo/isr.c
software/demo/main.c
software/demo/shell.c
software/include/hal/ps2.h [deleted file]
software/include/hw/interrupts.h
software/include/hw/ps2.h
software/libhal/Makefile
software/libhal/ps2.c [deleted file]

index 8142e11..0f51c04 100644 (file)
@@ -555,13 +555,13 @@ wire ac97dmar_irq;
 wire ac97dmaw_irq;
 wire pfpu_irq;
 wire tmu_irq;
-wire ps2_irq;
+wire keyboard_irq;
 wire mouse_irq;
 
 wire [31:0] cpu_interrupt;
 assign cpu_interrupt = {19'd0,
        mouse_irq,
-       ps2_irq,
+       keyboard_irq,
        tmu_irq,
        pfpu_irq,
        ac97dmaw_irq,
@@ -1012,7 +1012,7 @@ assign fml_tmuw_dw = 64'bx;
 // PS2 Interface
 //---------------------------------------------------------------------------
 `ifdef ENABLE_PS2_KEYBOARD
-ps2 # (
+ps2 #(
        .csr_addr(4'h7),
        .clk_freq(`CLOCK_FREQUENCY)
 ) ps2_keyboard (
@@ -1027,15 +1027,15 @@ ps2 # (
        .ps2_clk(ps2_clk1),
        .ps2_data(ps2_data1),
 
-       .irq(ps2_irq)
+       .irq(keyboard_irq)
 
 );
 `else
 assign csr_dr_ps2 = 32'd0;
-assign ps2_irq = 1'd0;
+assign keyboard_irq = 1'd0;
 `endif
 `ifdef ENABLE_PS2_MOUSE
-ps2 # (
+ps2 #(
        .csr_addr(4'h8),
        .clk_freq(`CLOCK_FREQUENCY)
 ) ps2_mouse (
index c223675..cb6e108 100644 (file)
@@ -186,7 +186,7 @@ always @(posedge sys_clk) begin
                if(csr_selected) begin
                        csr_do <= kcode;
                        if (csr_we) begin
-                               tx_data <= {2'b11,~(^csr_di[7:0]),csr_di[7:0]}; // STOP+PARITY+DATA
+                               tx_data <= {2'b11,~(^csr_di[7:0]), csr_di[7:0]}; // STOP+PARITY+DATA
                                we_reg <= 1'b1;
                        end
                end
@@ -222,4 +222,5 @@ end
 
 assign ps2_clk = ps2_clk_out ? 1'hz : 1'b0;
 assign ps2_data = ps2_data_out1 & ps2_data_out2 ? 1'hz : 1'b0;
+
 endmodule
index d03b5f3..be15776 100644 (file)
@@ -112,7 +112,7 @@ The engine performs texture mapping on a triangle strip. It is a central compone
 It has two FML master interfaces for fetching pixel data, a WISHBONE master to fetch the vertex data, and a CSR slave for control.
 
 \subsection{PS/2 controller}
-Milkymist supports standard PS/2 keyboard/mouse port in read-only mode. This is only implemented on the ML401 board.
+Milkymist supports two standard PS/2 keyboard/mouse port. This is only implemented on the ML401 board.
 
 \section{GPIO map}
 
@@ -218,7 +218,9 @@ Milkymist supports standard PS/2 keyboard/mouse port in read-only mode. This is
 \hline
 \hspace{5mm} 0x80006000 & No & \hspace{5mm} TMU \\
 \hline
-\hspace{5mm} 0x80007000 & No & \hspace{5mm} PS/2 (ML401 only) \\
+\hspace{5mm} 0x80007000 & No & \hspace{5mm} PS/2 keyboard (ML401 only) \\
+\hline
+\hspace{5mm} 0x80008000 & No & \hspace{5mm} PS/2 mouse (ML401 only) \\
 \hline
 0xa0000000 & No & SystemACE (ML401 only) \\
 \hline
index fcd74bd..ea09071 100644 (file)
@@ -68,8 +68,8 @@ isr.o: ../../software/include/uart.h ../../software/include/hal/time.h
 isr.o: ../../software/include/hal/slowout.h ../../software/include/hal/snd.h
 isr.o: ../../software/include/hw/ac97.h ../../software/include/hw/common.h
 isr.o: ../../software/include/hal/pfpu.h ../../software/include/hw/pfpu.h
-isr.o: ../../software/include/hal/tmu.h ../../software/include/hw/tmu.h
-isr.o: ../../software/include/hal/ps2.h ui.h cpustats.h
+isr.o: ../../software/include/hal/tmu.h ../../software/include/hw/tmu.h ui.h
+isr.o: cpustats.h
 line.o: ../../software/include/stdlib.h ../../software/include/math.h color.h
 line.o: line.h
 main.o: ../../software/include/stdio.h ../../software/include/stdlib.h
@@ -82,8 +82,8 @@ main.o: ../../software/include/hal/snd.h ../../software/include/hw/ac97.h
 main.o: ../../software/include/hw/common.h ../../software/include/hal/pfpu.h
 main.o: ../../software/include/hw/pfpu.h ../../software/include/hal/tmu.h
 main.o: ../../software/include/hw/tmu.h ../../software/include/hal/slowout.h
-main.o: ../../software/include/hal/hdlcd.h ../../software/include/hal/ps2.h
-main.o: apipe.h rpipe.h renderer.h ui.h cpustats.h shell.h
+main.o: ../../software/include/hal/hdlcd.h apipe.h rpipe.h renderer.h ui.h
+main.o: cpustats.h shell.h
 parser.o: ../../software/include/stdio.h ../../software/include/stdlib.h
 parser.o: ../../software/include/assert.h ../../software/include/string.h
 parser.o: ../../software/include/malloc.h ../../software/include/math.h ast.h
@@ -122,8 +122,7 @@ shell.o: ../../software/include/hw/interrupts.h
 shell.o: ../../software/include/hal/vga.h ../../software/include/hal/snd.h
 shell.o: ../../software/include/hw/ac97.h ../../software/include/hal/tmu.h
 shell.o: ../../software/include/hal/time.h ../../software/include/hal/brd.h
-shell.o: ../../software/include/hal/ps2.h line.h wave.h rpipe.h cpustats.h
-shell.o: shell.h ui.h
+shell.o: line.h wave.h rpipe.h cpustats.h shell.h ui.h
 tick.o: ../../software/include/hal/time.h rpipe.h
 tick.o: ../../software/include/hal/tmu.h ../../software/include/hw/tmu.h
 tick.o: ../../software/include/hw/common.h cpustats.h ui.h
index 42968a1..2460aca 100644 (file)
@@ -24,7 +24,6 @@
 #include <hal/snd.h>
 #include <hal/pfpu.h>
 #include <hal/tmu.h>
-#include <hal/ps2.h>
 
 #include "ui.h"
 #include "cpustats.h"
@@ -62,9 +61,6 @@ void isr()
        if(irqs & IRQ_TMU)
                tmu_isr();
 
-       if(irqs & IRQ_PS2)
-               ps2_isr();
-
        if(irqs & IRQ_GPIO) {
                irq_ack(IRQ_GPIO);
                ui_isr_key();
index 1f04894..3765b8f 100644 (file)
@@ -32,7 +32,6 @@
 #include <hal/tmu.h>
 #include <hal/slowout.h>
 #include <hal/hdlcd.h>
-#include <hal/ps2.h>
 
 #include "apipe.h"
 #include "rpipe.h"
@@ -72,7 +71,6 @@ int main()
        rpipe_init();
        slowout_init();
        hdlcd_init();
-       ps2_init();
        ui_init();
        shell_init();
        
index 9031a9e..e3c7916 100644 (file)
@@ -38,7 +38,6 @@
 #include <hal/tmu.h>
 #include <hal/time.h>
 #include <hal/brd.h>
-#include <hal/ps2.h>
 
 #include "line.h"
 #include "wave.h"
@@ -383,18 +382,6 @@ static void echo()
        }
 }
 
-static void ps2()
-{
-       int r;
-
-       printf("PS/2 scancode test - send any key on UART to abort\n");
-       while(!readchar_nonblock()) {
-               r = ps2_read();
-               if(r != -1)
-                       printf("%02x\n", r);
-       }
-}
-
 static char *get_token(char **str)
 {
        char *c, *d;
@@ -435,7 +422,6 @@ static void do_command(char *c)
        else if(strcmp(command, "pfputest") == 0) pfputest();
        else if(strcmp(command, "tmutest") == 0) tmutest();
        else if(strcmp(command, "echo") == 0) echo();
-       else if(strcmp(command, "ps2") == 0) ps2();
 
        else if(strcmp(command, "") != 0) printf("Command not found: '%s'\n", command);
 }
diff --git a/software/include/hal/ps2.h b/software/include/hal/ps2.h
deleted file mode 100644 (file)
index b538723..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Milkymist VJ SoC (Software)
- * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __HAL_PS2_H
-#define __HAL_PS2_H
-
-void ps2_init();
-void ps2_isr();
-int ps2_read();
-
-#endif /* __HAL_PS2_H */
index bb387f3..a06a002 100644 (file)
@@ -29,6 +29,7 @@
 #define IRQ_AC97DMAW           (0x00000100)
 #define IRQ_PFPU               (0x00000200)
 #define IRQ_TMU                        (0x00000400)
-#define IRQ_PS2                        (0x00000800)
+#define IRQ_PS2KEYBOARD                (0x00000800)
+#define IRQ_PS2MOUSE           (0x00001000)
 
 #endif /* __INTERRUPTS_H */
index 771bad6..4a2cec6 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <hw/common.h>
 
-#define CSR_PS2_RX     MMPTR(0x80007000)
+#define CSR_PS2_KEYBOARD       MMPTR(0x80007000)
+#define CSR_PS2_MOUSE          MMPTR(0x80008000)
 
 #endif /* __HW_PS2_H */
index 8e9529e..b5911f7 100644 (file)
@@ -1,7 +1,7 @@
 MMDIR=../..
 include $(MMDIR)/software/include.mak
 
-OBJECTS=brd.o hdlcd.o mem.o pfpu.o ps2.o slowout.o snd.o time.o tmu.o vga.o
+OBJECTS=brd.o hdlcd.o mem.o pfpu.o slowout.o snd.o time.o tmu.o vga.o
 
 all: libhal.a
 
@@ -35,10 +35,6 @@ pfpu.o: ../../software/include/stdio.h ../../software/include/stdlib.h
 pfpu.o: ../../software/include/irq.h ../../software/include/hw/interrupts.h
 pfpu.o: ../../software/include/hw/pfpu.h ../../software/include/hw/common.h
 pfpu.o: ../../software/include/hal/pfpu.h
-ps2.o: ../../software/include/stdio.h ../../software/include/stdlib.h
-ps2.o: ../../software/include/irq.h ../../software/include/hw/interrupts.h
-ps2.o: ../../software/include/hw/ps2.h ../../software/include/hw/common.h
-ps2.o: ../../software/include/hal/ps2.h
 slowout.o: ../../software/include/stdio.h ../../software/include/stdlib.h
 slowout.o: ../../software/include/irq.h
 slowout.o: ../../software/include/hw/interrupts.h
diff --git a/software/libhal/ps2.c b/software/libhal/ps2.c
deleted file mode 100644 (file)
index eee3dfc..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Milkymist VJ SoC (Software)
- * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <irq.h>
-#include <hw/interrupts.h>
-#include <hw/ps2.h>
-
-#include <hal/ps2.h>
-
-#define QSIZE 64 /* < must be a power of 2 */
-#define QMASK (QSIZE-1)
-
-static unsigned char queue[QSIZE];
-static unsigned int produce;
-static unsigned int consume;
-static unsigned int level;
-
-void ps2_init()
-{
-       unsigned int mask;
-
-       produce = 0;
-       consume = 0;
-       level = 0;
-
-       irq_ack(IRQ_PS2);
-
-       mask = irq_getmask();
-       mask |= IRQ_PS2;
-       irq_setmask(mask);
-
-       printf("PS2: ready\n");
-}
-
-void ps2_isr()
-{
-       irq_ack(IRQ_PS2);
-       if(level >= QSIZE) {
-               printf("PS2: queue overflow\n");
-               return;
-       }
-
-       queue[produce] = CSR_PS2_RX;
-       produce = (produce + 1) & QMASK;
-       level++;
-}
-
-int ps2_read()
-{
-       unsigned int oldmask;
-       int r;
-
-       oldmask = irq_getmask();
-       irq_setmask(oldmask & (~IRQ_PS2));
-
-       if(level == 0) {
-               irq_setmask(oldmask);
-               return -1;
-       }
-
-       r = queue[consume];
-       consume = (consume + 1) & QMASK;
-       level--;
-
-       irq_setmask(oldmask);
-
-       return r;
-}