OpenCores
URL https://opencores.org/ocsvn/zet86/zet86/trunk

Subversion Repositories zet86

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 42 to Rev 43
    Reverse comparison

Rev 42 → Rev 43

/trunk/rtl-model/util/div_uu.v
34,10 → 34,10
 
// CVS Log
//
// $Id: div_uu.v,v 1.6 2009-01-26 02:37:36 zeus Exp $
// $Id: div_uu.v,v 1.7 2009-02-06 03:48:26 zeus Exp $
//
// $Date: 2009-01-26 02:37:36 $
// $Revision: 1.6 $
// $Date: 2009-02-06 03:48:26 $
// $Revision: 1.7 $
// $Author: zeus $
// $Locker: $
// $State: Exp $
/trunk/rtl-model/util/div_su.v
35,10 → 35,10
 
// CVS Log
//
// $Id: div_su.v,v 1.6 2009-01-26 02:37:36 zeus Exp $
// $Id: div_su.v,v 1.7 2009-02-06 03:48:26 zeus Exp $
//
// $Date: 2009-01-26 02:37:36 $
// $Revision: 1.6 $
// $Date: 2009-02-06 03:48:26 $
// $Revision: 1.7 $
// $Author: zeus $
// $Locker: $
// $State: Exp $
/trunk/impl/virtex4-ml403ep/syn/kotku.v
47,7 → 47,8
output sram_adv_ld_n_,
output flash_ce2_,
 
input but2_
inout ps2_clk_,
inout ps2_data_
);
 
// Net declarations
63,6 → 64,10
wire [15:0] io_dat_i;
wire [ 1:0] sel;
wire cyc;
wire [ 7:0] keyb_dat_o;
wire keyb_io_arena;
wire keyb_arena;
 
wire [15:0] vdu_dat_o;
wire vdu_ack_o;
wire vdu_mem_arena;
83,6 → 88,7
wire sram_we_n_;
wire intr;
wire inta;
wire clk_100M;
 
`ifdef DEBUG
wire [35:0] control0;
90,7 → 96,6
wire [ 2:0] state, next_state;
wire [15:0] x, y;
wire [15:0] imm;
wire clk_100M;
wire [63:0] f1, f2;
wire [15:0] m1, m2;
wire [19:0] pc;
111,9 → 116,7
 
// Module instantiations
clock c0 (
`ifdef DEBUG
.clk_100M (clk_100M),
`endif
.sys_clk_in_ (sys_clk_in_),
.clk (clk),
.vdu_clk (tft_lcd_clk_),
188,12 → 191,20
.sram_adv_ld_n_ (sram_adv_ld_n_)
);
 
but_int but0 (
.clk (clk),
.rst (rst),
.but_ (but2_),
.intr (intr),
.inta (inta)
ps2_keyb #(5900, // number of clks for 60usec.
13, // number of bits needed for 60usec. timer
126, // number of clks for debounce
7, // number of bits needed for debounce timer
0 // Trap the shift keys, no event generated
) keyboard0 ( // Instance name
.wb_clk_i (clk_100M),
.wb_rst_i (rst),
.wb_dat_o (keyb_dat_o),
.wb_tgc_o (intr),
.wb_tgc_i (inta),
 
.ps2_clk_ (ps2_clk_),
.ps2_data_ (ps2_data_)
);
 
cpu zet_proc (
281,20 → 292,26
`endif
 
assign io_dat_i = flash_io_arena ? flash_dat_o
: (vdu_io_arena ? vdu_dat_o : 16'h0);
assign dat_i = inta ? 16'd3 : (tga ? io_dat_i
: (vdu_io_arena ? vdu_dat_o
: (keyb_io_arena ? keyb_dat_o : 16'h0));
assign dat_i = inta ? 16'd9 : (tga ? io_dat_i
: (vdu_mem_arena ? vdu_dat_o
: (flash_mem_arena ? flash_dat_o : zbt_dat_o)));
 
assign flash_mem_arena = (adr[19:16]==4'hc || adr[19:16]==4'hf);
assign vdu_mem_arena = (adr[19:12]==8'hb8);
 
assign flash_io_arena = (adr[15:9]==7'b1110_000);
assign vdu_io_arena = (adr[15:8]==8'hb8 && we) ||
(adr[15:1]==15'h01ed && !we);
assign keyb_io_arena = (adr[15:1]==15'h0030 && !we);
 
assign flash_arena = (!tga & flash_mem_arena)
| (tga & flash_io_arena);
assign vdu_mem_arena = (adr[19:12]==8'hb8);
assign vdu_io_arena = (adr[15:8]==8'hb8 && we) ||
(adr[15:1]==15'h01ed && !we);
assign vdu_arena = (!tga & vdu_mem_arena)
| (tga & vdu_io_arena);
assign keyb_arena = (tga & keyb_io_arena);
 
assign flash_stb = flash_arena & stb & cyc;
assign zbt_stb = !vdu_mem_arena & !flash_mem_arena
& !tga & stb & cyc;
/trunk/impl/virtex4-ml403ep/syn/kotku.prj
12,7 → 12,7
verilog work "../../../../rtl-model/fetch.v"
verilog work "../../../../rtl-model/exec.v"
verilog work "../../../../soc/vga/rtl/vdu.v"
verilog work "../../../../soc/but_int.v"
verilog work "../../../../soc/keyb/rtl/ps2_keyb.v"
verilog work "../../../../rtl-model/cpu.v"
verilog work "../../mem/zbt_cntrl.v"
verilog work "../../mem/flash_cntrl.v"
/trunk/impl/virtex4-ml403ep/syn/ml403.ucf
110,16 → 110,26
#NET db_[4] LOC = AB10 | IOSTANDARD = LVCMOS33 | TIG; # LCD_DB4
 
#NET but_ LOC = B6; # C Button
NET but2_ LOC = A6; # S Button
#NET but2_ LOC = A6; # S Button
 
#NET leds_[0] LOC = G5; #GPLED0
#NET leds_[1] LOC = G6; #GPLED1
#NET leds_[2] LOC = A11; #GPLED2
#NET leds_[3] LOC = A12; #GPLED3
#NET led_[0] LOC = G5; #GPLED0
#NET led_[1] LOC = G6; #GPLED1
#NET led_[2] LOC = A11; #GPLED2
#NET led_[3] LOC = A12; #GPLED3
 
# North-East-South-West-Center LEDs
#NET leds_[4] LOC = C6; # C LED
#NET leds_[5] LOC = F9; # W LED
#NET leds_[6] LOC = A5; # S LED
#NET leds_[7] LOC = E10; # E LED
#NET leds_[8] LOC = E2; # N LED
#NET led_[4] LOC = C6; # C LED
#NET led_[5] LOC = F9; # W LED
#NET led_[6] LOC = A5; # S LED
#NET led_[7] LOC = E10; # E LED
#NET led_[8] LOC = E2; # N LED
 
#Keyboard
NET ps2_clk_ LOC = D2;
NET ps2_clk_ SLEW = SLOW;
NET ps2_clk_ DRIVE = 2;
NET ps2_clk_ TIG;
NET ps2_data_ LOC = G9;
NET ps2_data_ SLEW = SLOW;
NET ps2_data_ DRIVE = 2;
NET ps2_data_ TIG;
/trunk/soc/keyb/test/test_ps2_keyb.v
0,0 → 1,39
module test_ps2_keyb (
input clk_,
output [8:0] led_,
inout ps2_clk_,
inout ps2_data_
 
 
);
 
// Net declarations
wire sys_clk_0;
wire lock;
wire rst;
 
// Module instances
clock c0 (
.CLKIN_IN (clk_),
.CLKDV_OUT (sys_clk_0),
.LOCKED_OUT (lock)
);
 
ps2_keyb #(2950, // number of clks for 60usec.
12, // number of bits needed for 60usec. timer
63, // number of clks for debounce
6, // number of bits needed for debounce timer
0 // Trap the shift keys, no event generated
) keyboard0 ( // Instance name
.wb_clk_i (sys_clk_0),
.wb_rst_i (rst),
.wb_dat_o (led_[7:0]),
.test (led_[8]),
 
.ps2_clk_ (ps2_clk_),
.ps2_data_ (ps2_data_)
);
 
// Continuous assignments
assign rst = !lock;
endmodule
/trunk/soc/keyb/test/clock.xaw
0,0 → 1,3
XILINX-XDB 0.1 STUB 0.1 ASCII
XILINX-XDM V1.4e
$8;x64=(`fgn#wkzs.xfp*uhk&anuo!llnah*}gp92:>7= ?10784+54;81::6??.1233>77&8$;?>5>01:853!oN9L;>6?W1:01?7353:8:79?4869BVFNPAS;<7L\XZ^MMH\YDIZIJHD@H_BNH5==FZ^PTCCBV_BNHMKYBP]OYBLB>5:CQS_YHFESTOAEFN^TBHPC6j2KY[WQ@NM[\@FKX[^C_OEGAG^AOO46<I[]QSB@CY^FGVZE7991J^ZTPOONZ[ABUWJ;:=6O]W[]LJI_XLMXTOAE>6:CQS_YHFESTHI\PEEEFIJBB9?1J^ZTPOONZ[ABUWOFB\KB@P008EWQ]WFDGURJKR^KMMQ703HX\VRAALX]G@WYUMZO_XT^J149BVR\XGGFRSKLPEYVFVKGK9;1J^ZTPOONZ[LHT\VD^A<k4ASUY[JHKQV@BXYK]_QI1TNYIGGEB_H?m;@PT^ZIIDPUAEYZJR^WJ[KIIG@YN=:5NRVX\KKJ^W[OHCCHFG^RJJV723HX\VRAALX]QAVCSWEELEN?=;@PT^ZIIDPUYIYO]GDV2<>GU_SUDBAWPV@NJ@ZBA[VGDHHo4ARQLGZQN\Al0MZTPCMIAQCR^XL;::6OXZ^AOOGSA\PZN=R@@EEKW56=F_SUH@FQ@UURVPZR^XLi0MZTPFMMTP\VB02K\VR^NRUf8ER\X[PD_DYA@L59AKQN33K_MK95LLJ2;?FJL8VH^Jh5LLJ2\FP@@W@DXX55LLJ2\KPR13JF@=5>9;BNH62623JF@>U64CMI1\4>7=2IGG4>:;BNH@S?<KEAOZRLZFg9@HNBQWK_MKRGASUa8GIMC^VNBZDJJ9:AOOAPXG\^>7NBDFC:8GIMAJVCE96MCKGZ;?FJLNQ;3<n5LLJD[[AOQAMOn7NBDFY]NQIRNXES>7NBDIO32?FJLAGUOE[GKE^@Z[7d<KEABBRGMUGE24>EKC@DTEO[IG^KMWQ`<KEABBRGMUGE\KPR?3JF@ECQFNb9@HNOIWYOYEBJj;BNHMKYTZJU_U]K>2:AOOJSSWYBJ_HQ\HHDWg>EKCVLNIILNCJ;8GJKJA]^NH:5LRDCWAA3<LHNO^95KCMI4?AEJWHN]o6JLM^CGRZOI[];87IMB_@WWKFGKAKXJXDAA159GGHYWM[LD^@OACD]NKAC43MOEh6JJSJGT[DBM]Z^:>6JIS^DQATSBFJSTABJJ2:FJ7>BKD880HABPFSGRQ@HDQVGDHH<4DN68@WB^9<1OYYWPCXAOAZEHZ[OHXDAA3:FTA2=CW_KGYH64EYVFVKGKi2LJOYA]Y^HE1>@FDZO27KLPSNWQG@e<NLOONLMD_CWE=>@NFV_EEY]7;GMVPZUSZh1MCXZPUOKWWd=AG\^TZLBZE09J1>OE]OM37D@[ESLBH47<B@^_I_QFNQWW[Q_WM?1GCLJJD79OKFMBLh1GCNEJD^MVP6=KG^30ALVPSQGF@6=J@S=0ARXNLTG4?KCS_FX@86@@ND38K1=HLMX37B^_ORKWAg=W@HYNS^FFFU;8TLHOIZH^_l5_IOKPCKBBL11[ECYFDUJ;?UTNE]S[I<>4PSMS[UOIAZKHXDXJ5:RPGIM13YYOCCK;;QQFJ==W[@DHHHM<;SQWf>UNOLR_I_@NL79PMKAKMj1XXL\[UQ]TELRe3ZSEOE\@NNWP57=TQZ^NAR]VNBJQKKIR[:1_C]:4TSWF<>STMVH^JJ74URG\FP@@[<1]EHY>b:ZBSZPBZZCDB<j4XHNJJ]+_LK*;"<.\TT@#4+7'IZIBE>5WSU48\adXAm;;7Ujb_LcikwPbzzcdb<>4Xeo\Ilhhz_oydaa5:Y3>5[13R:1=8S:;Z292X2<i{}q?6jlmc9uawungg*:"=:4vifo55=k=|mt<<"11de23>zHIz?<6NOx18E>3<6sZ>i64:5978277>c8j08<46tn9d95>h>83>0(5k58b9~W1g=1=02:7?<29f3g?568>1X:l464;;5>4550m:h6><86:Q7e??320<1=><7d1a977>43Z<j64:5978277>c=m099=78;R6b><2=1?0:??6k5e8115g43m3?6=4>:0yP0g<><33=6<==8e2`>66>02|_4l4?:082><}T<k028779:011<a6d2::246l76;294?2=1r.m64;4$359=2=#:10246*=9;:g?!>e2?1i8k4?:0:94?6|,>k18h5+11801>"693297)?<:3a8 4d=0;1/=n4;;%3;>22<,8>1>n5+14804>"6>38h7)?8:678 4?=92.:m76;;%3e>0`<,;:19k5+2086b>"31330(>65a:&0a?d<,:l1i6*;1;7e?!212<1/8:4:d:&7<?153-?;6594$4392`=#=:0396*:4;4g?!302?n0(8o5869'1f<33-?n655+6185<>"1:3<m7)8;:7d8 33=k2.=578<;%53>a=#??0:7)6<:4d8 =>=001/=?48;%05>00<,;81>l5+1d81?!7c2:1b8=4?:%5:><7<,>h14:54i2c94?"0133:7)9m:958?l2d290/;4463:&4<?>03-=<6594;h76>5<#?002>6*88;:4?!1021=07d;m:18'3<<>92.<4768;:k66?6=,>315<5+798;3>=n<m0;6)96:838 2>=0>10e5>50;&4=??63-=36594;h5f>5<#?002=6*88;:4?>o0n3:1(:75909'3=<??21b;n4?:%5:><7<,>214:54o3a94?"0133:7)9m:958 72=:k1/>8491:9l71<72-=264?4;n13>5<#?002=65`3083>!1>20;07b=::18'3<<>92.<n768;%07>7d<3f996=4+788:5>=h;:0;6)96:838?j5d290/;4461:&10?4e32e8h7>5$6;9=4=<g<31<7*89;;2?>i203:1(:75939'32<??21d:o4?:%5:><7<,>h14:54o6f94?"0133:76sm4283>7<729q/;l497:k52?6=,>315<5+7c8;3>=h?:0;6)96:838 2d=0>10qo<j:181>5<7s-=j6?l4i7494?"0133:7)9m:958?j14290/;4461:&4f?>032wi?:4?:383>5}#?h09n6g96;29 2?=181/;o477:9l36<72-=264?4$6`9<2=<uz>96=4={<6e>16<5=91;>5+22870>{t;k0;6?u24g80e>;5m3=87)<<:3d8yv4c2909w0:i:3a897c=>?1v>850;0x91`=;<16?:496:p2f<728q68k49b:&;5?143ty?97>51z?77?013-2:6;84}r1:>5<6s49<6:=4$93936=z{=>1<7>t$93936=z{;l1<7>t$93936=zug8n6=4>{|l1b?6=9rwe?=4?:0y~j67=83;pqc==:182xh4;3:1=vsa3583>4}zf:?1<7?t}o15>5<6stwvqMNL{529a04b90o9qMNM{1CDU}zHI
/trunk/soc/keyb/test/test_ps2_keyb.ucf
0,0 → 1,24
NET clk_ LOC = AE14;
NET clk_ IOSTANDARD = LVCMOS33;
 
NET led_[0] LOC = G5; #GPLED0
NET led_[1] LOC = G6; #GPLED1
NET led_[2] LOC = A11; #GPLED2
NET led_[3] LOC = A12; #GPLED3
 
# North-East-South-West-Center LEDs
NET led_[4] LOC = C6; # C LED
NET led_[5] LOC = F9; # W LED
NET led_[6] LOC = A5; # S LED
NET led_[7] LOC = E10; # E LED
NET led_[8] LOC = E2; # N LED
 
#Keyboard
NET ps2_clk_ LOC = D2;
NET ps2_clk_ SLEW = SLOW;
NET ps2_clk_ DRIVE = 2;
NET ps2_clk_ TIG;
NET ps2_data_ LOC = G9;
NET ps2_data_ SLEW = SLOW;
NET ps2_data_ DRIVE = 2;
NET ps2_data_ TIG;
/trunk/soc/keyb/rtl/ps2_keyb.v
0,0 → 1,502
/*
* PS2 Wishbone 8042 compatible keyboard controller
*
* Copyright (c) 2009 Zeus Gomez Marmolejo <zeus@opencores.org>
* adapted from the opencores keyboard controller from John Clayton
*
* This file is part of the Zet processor. This processor is free
* hardware; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software
* Foundation; either version 3, or (at your option) any later version.
*
* Zet is distrubuted 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 Zet; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/
 
`timescale 1ns/100ps
 
`define TOTAL_BITS 11
`define RELEASE_CODE 16'hF0
`define LEFT_SHIFT 16'h12
`define RIGHT_SHIFT 16'h59
 
module ps2_keyb (
// Wishbone slave interface
input wb_clk_i,
input wb_rst_i,
output reg [7:0] wb_dat_o, // scancode
output reg wb_tgc_o, // intr
input wb_tgc_i, // inta
 
// PS2 PAD signals
inout ps2_clk_,
inout ps2_data_
);
 
// Parameter declarations
// The timer value can be up to (2^bits) inclusive.
parameter TIMER_60USEC_VALUE_PP = 1920; // Number of sys_clks for 60usec.
parameter TIMER_60USEC_BITS_PP = 11; // Number of bits needed for timer
parameter TIMER_5USEC_VALUE_PP = 186; // Number of sys_clks for debounce
parameter TIMER_5USEC_BITS_PP = 8; // Number of bits needed for timer
parameter TRAP_SHIFT_KEYS_PP = 0; // Default: No shift key trap.
 
// State encodings, provided as parameters
// for flexibility to the one instantiating the module.
// In general, the default values need not be changed.
 
// State "m1_rx_clk_l" has been chosen on purpose. Since the input
// synchronizing flip-flops initially contain zero, it takes one clk
// for them to update to reflect the actual (idle = high) status of
// the I/O lines from the keyboard. Therefore, choosing 0 for m1_rx_clk_l
// allows the state machine to transition to m1_rx_clk_h when the true
// values of the input signals become present at the outputs of the
// synchronizing flip-flops. This initial transition is harmless, and it
// eliminates the need for a "reset" pulse before the interface can operate.
parameter m1_rx_clk_h = 1;
parameter m1_rx_clk_l = 0;
parameter m1_rx_falling_edge_marker = 13;
parameter m1_rx_rising_edge_marker = 14;
parameter m1_tx_force_clk_l = 3;
parameter m1_tx_first_wait_clk_h = 10;
parameter m1_tx_first_wait_clk_l = 11;
parameter m1_tx_reset_timer = 12;
parameter m1_tx_wait_clk_h = 2;
parameter m1_tx_clk_h = 4;
parameter m1_tx_clk_l = 5;
parameter m1_tx_wait_keyboard_ack = 6;
parameter m1_tx_done_recovery = 7;
parameter m1_tx_error_no_keyboard_ack = 8;
parameter m1_tx_rising_edge_marker = 9;
 
// Nets and registers
wire rx_output_event;
wire rx_output_strobe;
wire rx_shifting_done;
wire tx_shifting_done;
wire timer_60usec_done;
wire timer_5usec_done;
 
wire released;
 
wire [6:0] xt_code;
 
reg [3:0] bit_count;
reg [3:0] m1_state;
reg [3:0] m1_next_state;
 
reg ps2_clk_hi_z; // Without keyboard, high Z equals 1 due to pullups.
reg ps2_data_hi_z; // Without keyboard, high Z equals 1 due to pullups.
reg ps2_clk_s; // Synchronous version of this input
reg ps2_data_s; // Synchronous version of this input
 
reg enable_timer_60usec;
reg enable_timer_5usec;
reg [TIMER_60USEC_BITS_PP-1:0] timer_60usec_count;
reg [TIMER_5USEC_BITS_PP-1:0] timer_5usec_count;
 
reg [`TOTAL_BITS-1:0] q;
 
reg hold_released; // Holds prior value, cleared at rx_output_strobe
 
// Module instantiation
translate_8042 tr0 (
.at_code (q[7:1]),
.xt_code (xt_code)
);
 
// Continuous assignments
// This signal is high for one clock at the end of the timer count.
assign rx_shifting_done = (bit_count == `TOTAL_BITS);
assign tx_shifting_done = (bit_count == `TOTAL_BITS-1);
 
assign rx_output_event = (rx_shifting_done
&& ~released
);
assign rx_output_strobe = (rx_shifting_done
&& ~released
&& ( (TRAP_SHIFT_KEYS_PP == 0)
|| ( (q[8:1] != `RIGHT_SHIFT)
&&(q[8:1] != `LEFT_SHIFT)
)
)
);
 
assign ps2_clk_ = ps2_clk_hi_z ? 1'bZ : 1'b0;
assign ps2_data_ = ps2_data_hi_z ? 1'bZ : 1'b0;
 
assign timer_60usec_done =
(timer_60usec_count == (TIMER_60USEC_VALUE_PP - 1));
assign timer_5usec_done = (timer_5usec_count == TIMER_5USEC_VALUE_PP - 1);
 
// Create the signals which indicate special scan codes received.
// These are the "unlatched versions."
//assign extended = (q[8:1] == `EXTEND_CODE) && rx_shifting_done;
assign released = (q[8:1] == `RELEASE_CODE) && rx_shifting_done;
 
// Behaviour
// intr
always @(posedge wb_clk_i)
wb_tgc_o <= wb_rst_i ? 1'b0
: ((rx_output_strobe & !wb_tgc_i) ? 1'b1
: (wb_tgc_o ? !wb_tgc_i : 1'b0));
 
// This is the shift register
always @(posedge wb_clk_i)
if (wb_rst_i) q <= 0;
// else if (((m1_state == m1_rx_clk_h) && ~ps2_clk_s)
else if ( (m1_state == m1_rx_falling_edge_marker)
||(m1_state == m1_tx_rising_edge_marker) )
q <= {ps2_data_s,q[`TOTAL_BITS-1:1]};
 
// This is the 60usec timer counter
always @(posedge wb_clk_i)
if (~enable_timer_60usec) timer_60usec_count <= 0;
else if (~timer_60usec_done) timer_60usec_count <= timer_60usec_count + 1;
 
// This is the 5usec timer counter
always @(posedge wb_clk_i)
if (~enable_timer_5usec) timer_5usec_count <= 0;
else if (~timer_5usec_done) timer_5usec_count <= timer_5usec_count + 1;
 
// Input "synchronizing" logic -- synchronizes the inputs to the state
// machine clock, thus avoiding errors related to
// spurious state machine transitions.
//
// Since the initial state of registers is zero, and the idle state
// of the ps2_clk and ps2_data lines is "1" (due to pullups), the
// "sense" of the ps2_clk_s signal is inverted from the true signal.
// This allows the state machine to "come up" in the correct
always @(posedge wb_clk_i)
begin
ps2_clk_s <= ps2_clk_;
ps2_data_s <= ps2_data_;
end
 
// State transition logic
always @(m1_state
or q
or tx_shifting_done
or ps2_clk_s
or ps2_data_s
or timer_60usec_done
or timer_5usec_done
)
begin : m1_state_logic
 
// Output signals default to this value,
// unless changed in a state condition.
ps2_clk_hi_z <= 1;
ps2_data_hi_z <= 1;
enable_timer_60usec <= 0;
enable_timer_5usec <= 0;
 
case (m1_state)
 
m1_rx_clk_h :
begin
enable_timer_60usec <= 1;
if (~ps2_clk_s)
m1_next_state <= m1_rx_falling_edge_marker;
else m1_next_state <= m1_rx_clk_h;
end
 
m1_rx_falling_edge_marker :
begin
enable_timer_60usec <= 0;
m1_next_state <= m1_rx_clk_l;
end
 
m1_rx_rising_edge_marker :
begin
enable_timer_60usec <= 0;
m1_next_state <= m1_rx_clk_h;
end
 
m1_rx_clk_l :
begin
enable_timer_60usec <= 1;
if (ps2_clk_s)
m1_next_state <= m1_rx_rising_edge_marker;
else m1_next_state <= m1_rx_clk_l;
end
 
m1_tx_reset_timer :
begin
enable_timer_60usec <= 0;
m1_next_state <= m1_tx_force_clk_l;
end
 
m1_tx_force_clk_l :
begin
enable_timer_60usec <= 1;
ps2_clk_hi_z <= 0; // Force the ps2_clk line low.
if (timer_60usec_done)
m1_next_state <= m1_tx_first_wait_clk_h;
else m1_next_state <= m1_tx_force_clk_l;
end
 
m1_tx_first_wait_clk_h :
begin
enable_timer_5usec <= 1;
ps2_data_hi_z <= 0; // Start bit.
if (~ps2_clk_s && timer_5usec_done)
m1_next_state <= m1_tx_clk_l;
else
m1_next_state <= m1_tx_first_wait_clk_h;
end
 
// This state must be included because the device might possibly
// delay for up to 10 milliseconds before beginning its clock pulses.
// During that waiting time, we cannot drive the data (q[0]) because it
// is possibly 1, which would cause the keyboard to abort its receive
// and the expected clocks would then never be generated.
m1_tx_first_wait_clk_l :
begin
ps2_data_hi_z <= 0;
if (~ps2_clk_s) m1_next_state <= m1_tx_clk_l;
else m1_next_state <= m1_tx_first_wait_clk_l;
end
 
m1_tx_wait_clk_h :
begin
enable_timer_5usec <= 1;
ps2_data_hi_z <= q[0];
if (ps2_clk_s && timer_5usec_done)
m1_next_state <= m1_tx_rising_edge_marker;
else
m1_next_state <= m1_tx_wait_clk_h;
end
 
m1_tx_rising_edge_marker :
begin
ps2_data_hi_z <= q[0];
m1_next_state <= m1_tx_clk_h;
end
 
m1_tx_clk_h :
begin
ps2_data_hi_z <= q[0];
if (tx_shifting_done) m1_next_state <= m1_tx_wait_keyboard_ack;
else if (~ps2_clk_s) m1_next_state <= m1_tx_clk_l;
else m1_next_state <= m1_tx_clk_h;
end
 
m1_tx_clk_l :
begin
ps2_data_hi_z <= q[0];
if (ps2_clk_s) m1_next_state <= m1_tx_wait_clk_h;
else m1_next_state <= m1_tx_clk_l;
end
 
m1_tx_wait_keyboard_ack :
begin
if (~ps2_clk_s && ps2_data_s)
m1_next_state <= m1_tx_error_no_keyboard_ack;
else if (~ps2_clk_s && ~ps2_data_s)
m1_next_state <= m1_tx_done_recovery;
else m1_next_state <= m1_tx_wait_keyboard_ack;
end
 
m1_tx_done_recovery :
begin
if (ps2_clk_s && ps2_data_s) m1_next_state <= m1_rx_clk_h;
else m1_next_state <= m1_tx_done_recovery;
end
 
m1_tx_error_no_keyboard_ack :
begin
if (ps2_clk_s && ps2_data_s) m1_next_state <= m1_rx_clk_h;
else m1_next_state <= m1_tx_error_no_keyboard_ack;
end
 
default : m1_next_state <= m1_rx_clk_h;
endcase
end
 
// State register
always @(posedge wb_clk_i)
begin : m1_state_register
if (wb_rst_i) m1_state <= m1_rx_clk_h;
else m1_state <= m1_next_state;
end
 
// wb_dat_o - scancode
always @(posedge wb_clk_i)
if (wb_rst_i) wb_dat_o <= 8'b0;
else wb_dat_o <=
(rx_output_strobe && q[8:1]) ? (q[8] ? q[8:1]
: {hold_released,xt_code})
: wb_dat_o;
 
// This is the bit counter
always @(posedge wb_clk_i)
begin
if (wb_rst_i
|| rx_shifting_done
|| (m1_state == m1_tx_wait_keyboard_ack) // After tx is done.
) bit_count <= 0; // normal reset
else if (timer_60usec_done
&& (m1_state == m1_rx_clk_h)
&& (ps2_clk_s)
) bit_count <= 0; // rx watchdog timer reset
else if ( (m1_state == m1_rx_falling_edge_marker) // increment for rx
||(m1_state == m1_tx_rising_edge_marker) // increment for tx
)
bit_count <= bit_count + 1;
end
 
// Store the special scan code status bits
// Not the final output, but an intermediate storage place,
// until the entire set of output data can be assembled.
always @(posedge wb_clk_i)
if (wb_rst_i || rx_output_event) hold_released <= 0;
else if (rx_shifting_done && released) hold_released <= 1;
 
endmodule
 
 
module translate_8042 (
input [6:0] at_code,
output reg [6:0] xt_code
);
 
// Behaviour
always @(at_code)
case (at_code)
7'h00: xt_code <= 7'h7f;
7'h01: xt_code <= 7'h43;
7'h02: xt_code <= 7'h41;
7'h03: xt_code <= 7'h3f;
7'h04: xt_code <= 7'h3d;
7'h05: xt_code <= 7'h3b;
7'h06: xt_code <= 7'h3c;
7'h07: xt_code <= 7'h58;
7'h08: xt_code <= 7'h64;
7'h09: xt_code <= 7'h44;
7'h0a: xt_code <= 7'h42;
7'h0b: xt_code <= 7'h40;
7'h0c: xt_code <= 7'h3e;
7'h0d: xt_code <= 7'h0f;
7'h0e: xt_code <= 7'h29;
7'h0f: xt_code <= 7'h59;
7'h10: xt_code <= 7'h65;
7'h11: xt_code <= 7'h38;
7'h12: xt_code <= 7'h2a;
7'h13: xt_code <= 7'h70;
7'h14: xt_code <= 7'h1d;
7'h15: xt_code <= 7'h10;
7'h16: xt_code <= 7'h02;
7'h17: xt_code <= 7'h5a;
7'h18: xt_code <= 7'h66;
7'h19: xt_code <= 7'h71;
7'h1a: xt_code <= 7'h2c;
7'h1b: xt_code <= 7'h1f;
7'h1c: xt_code <= 7'h1e;
7'h1d: xt_code <= 7'h11;
7'h1e: xt_code <= 7'h03;
7'h1f: xt_code <= 7'h5b;
7'h20: xt_code <= 7'h67;
7'h21: xt_code <= 7'h2e;
7'h22: xt_code <= 7'h2d;
7'h23: xt_code <= 7'h20;
7'h24: xt_code <= 7'h12;
7'h25: xt_code <= 7'h05;
7'h26: xt_code <= 7'h04;
7'h27: xt_code <= 7'h5c;
7'h28: xt_code <= 7'h68;
7'h29: xt_code <= 7'h39;
7'h2a: xt_code <= 7'h2f;
7'h2b: xt_code <= 7'h21;
7'h2c: xt_code <= 7'h14;
7'h2d: xt_code <= 7'h13;
7'h2e: xt_code <= 7'h06;
7'h2f: xt_code <= 7'h5d;
7'h30: xt_code <= 7'h69;
7'h31: xt_code <= 7'h31;
7'h32: xt_code <= 7'h30;
7'h33: xt_code <= 7'h23;
7'h34: xt_code <= 7'h22;
7'h35: xt_code <= 7'h15;
7'h36: xt_code <= 7'h07;
7'h37: xt_code <= 7'h5e;
7'h38: xt_code <= 7'h6a;
7'h39: xt_code <= 7'h72;
7'h3a: xt_code <= 7'h32;
7'h3b: xt_code <= 7'h24;
7'h3c: xt_code <= 7'h16;
7'h3d: xt_code <= 7'h08;
7'h3e: xt_code <= 7'h09;
7'h3f: xt_code <= 7'h5f;
7'h40: xt_code <= 7'h6b;
7'h41: xt_code <= 7'h33;
7'h42: xt_code <= 7'h25;
7'h43: xt_code <= 7'h17;
7'h44: xt_code <= 7'h18;
7'h45: xt_code <= 7'h0b;
7'h46: xt_code <= 7'h0a;
7'h47: xt_code <= 7'h60;
7'h48: xt_code <= 7'h6c;
7'h49: xt_code <= 7'h34;
7'h4a: xt_code <= 7'h35;
7'h4b: xt_code <= 7'h26;
7'h4c: xt_code <= 7'h27;
7'h4d: xt_code <= 7'h19;
7'h4e: xt_code <= 7'h0c;
7'h4f: xt_code <= 7'h61;
7'h50: xt_code <= 7'h6d;
7'h51: xt_code <= 7'h73;
7'h52: xt_code <= 7'h28;
7'h53: xt_code <= 7'h74;
7'h54: xt_code <= 7'h1a;
7'h55: xt_code <= 7'h0d;
7'h56: xt_code <= 7'h62;
7'h57: xt_code <= 7'h6e;
7'h58: xt_code <= 7'h3a;
7'h59: xt_code <= 7'h36;
7'h5a: xt_code <= 7'h1c;
7'h5b: xt_code <= 7'h1b;
7'h5c: xt_code <= 7'h75;
7'h5d: xt_code <= 7'h2b;
7'h5e: xt_code <= 7'h63;
7'h5f: xt_code <= 7'h76;
7'h60: xt_code <= 7'h55;
7'h61: xt_code <= 7'h56;
7'h62: xt_code <= 7'h77;
7'h63: xt_code <= 7'h78;
7'h64: xt_code <= 7'h79;
7'h65: xt_code <= 7'h7a;
7'h66: xt_code <= 7'h0e;
7'h67: xt_code <= 7'h7b;
7'h68: xt_code <= 7'h7c;
7'h69: xt_code <= 7'h4f;
7'h6a: xt_code <= 7'h7d;
7'h6b: xt_code <= 7'h4b;
7'h6c: xt_code <= 7'h47;
7'h6d: xt_code <= 7'h7e;
7'h6e: xt_code <= 7'h7f;
7'h6f: xt_code <= 7'h6f;
7'h70: xt_code <= 7'h52;
7'h71: xt_code <= 7'h53;
7'h72: xt_code <= 7'h50;
7'h73: xt_code <= 7'h4c;
7'h74: xt_code <= 7'h4d;
7'h75: xt_code <= 7'h48;
7'h76: xt_code <= 7'h01;
7'h77: xt_code <= 7'h45;
7'h78: xt_code <= 7'h57;
7'h79: xt_code <= 7'h4e;
7'h7a: xt_code <= 7'h51;
7'h7b: xt_code <= 7'h4a;
7'h7c: xt_code <= 7'h37;
7'h7d: xt_code <= 7'h49;
7'h7e: xt_code <= 7'h46;
7'h7f: xt_code <= 7'h54;
endcase
endmodule
/trunk/soc/bios/biossums.c
1,5 → 1,5
/*
* $Id: biossums.c,v 1.6 2009-01-26 02:37:39 zeus Exp $
* $Id: biossums.c,v 1.7 2009-02-06 03:48:27 zeus Exp $
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/trunk/soc/bios/makesym.perl
1,6 → 1,6
#!/usr/bin/perl
#
# $Id: makesym.perl,v 1.6 2009-01-26 02:37:39 zeus Exp $
# $Id: makesym.perl,v 1.7 2009-02-06 03:48:27 zeus Exp $
#
# Read output file from as86 (e.g. rombios.txt) and write out a symbol
# table suitable for the Bochs debugger.
/trunk/soc/bios/rombios.c
438,11 → 438,15
static void write_word();
static void bios_printf();
 
static void int09_function();
static void int13_harddisk();
static void int13_diskette_function();
static void int16_function();
static void int19_function();
static Bit16u get_CS();
static Bit16u get_SS();
static unsigned int enqueue_key();
static unsigned int dequeue_key();
static void set_diskette_ret_status();
static void set_diskette_current_cyl();
 
450,6 → 454,12
static void print_boot_device();
static void print_boot_failure();
 
#if DEBUG_INT16
# define BX_DEBUG_INT16(a...) BX_DEBUG(a)
#else
# define BX_DEBUG_INT16(a...)
#endif
 
#define SET_AL(val8) AX = ((AX & 0xff00) | (val8))
#define SET_BL(val8) BX = ((BX & 0xff00) | (val8))
#define SET_CL(val8) CX = ((CX & 0xff00) | (val8))
479,6 → 489,109
#define CLEAR_ZF() FLAGS &= 0xffbf
#define GET_ZF() (FLAGS & 0x0040)
 
#define UNSUPPORTED_FUNCTION 0x86
 
#define none 0
#define MAX_SCAN_CODE 0x58
 
static struct {
Bit16u normal;
Bit16u shift;
Bit16u control;
Bit16u alt;
Bit8u lock_flags;
} scan_to_scanascii[MAX_SCAN_CODE + 1] = {
{ none, none, none, none, none },
{ 0x011b, 0x011b, 0x011b, 0x0100, none }, /* escape */
{ 0x0231, 0x0221, none, 0x7800, none }, /* 1! */
{ 0x0332, 0x0340, 0x0300, 0x7900, none }, /* 2@ */
{ 0x0433, 0x0423, none, 0x7a00, none }, /* 3# */
{ 0x0534, 0x0524, none, 0x7b00, none }, /* 4$ */
{ 0x0635, 0x0625, none, 0x7c00, none }, /* 5% */
{ 0x0736, 0x075e, 0x071e, 0x7d00, none }, /* 6^ */
{ 0x0837, 0x0826, none, 0x7e00, none }, /* 7& */
{ 0x0938, 0x092a, none, 0x7f00, none }, /* 8* */
{ 0x0a39, 0x0a28, none, 0x8000, none }, /* 9( */
{ 0x0b30, 0x0b29, none, 0x8100, none }, /* 0) */
{ 0x0c2d, 0x0c5f, 0x0c1f, 0x8200, none }, /* -_ */
{ 0x0d3d, 0x0d2b, none, 0x8300, none }, /* =+ */
{ 0x0e08, 0x0e08, 0x0e7f, none, none }, /* backspace */
{ 0x0f09, 0x0f00, none, none, none }, /* tab */
{ 0x1071, 0x1051, 0x1011, 0x1000, 0x40 }, /* Q */
{ 0x1177, 0x1157, 0x1117, 0x1100, 0x40 }, /* W */
{ 0x1265, 0x1245, 0x1205, 0x1200, 0x40 }, /* E */
{ 0x1372, 0x1352, 0x1312, 0x1300, 0x40 }, /* R */
{ 0x1474, 0x1454, 0x1414, 0x1400, 0x40 }, /* T */
{ 0x1579, 0x1559, 0x1519, 0x1500, 0x40 }, /* Y */
{ 0x1675, 0x1655, 0x1615, 0x1600, 0x40 }, /* U */
{ 0x1769, 0x1749, 0x1709, 0x1700, 0x40 }, /* I */
{ 0x186f, 0x184f, 0x180f, 0x1800, 0x40 }, /* O */
{ 0x1970, 0x1950, 0x1910, 0x1900, 0x40 }, /* P */
{ 0x1a5b, 0x1a7b, 0x1a1b, none, none }, /* [{ */
{ 0x1b5d, 0x1b7d, 0x1b1d, none, none }, /* ]} */
{ 0x1c0d, 0x1c0d, 0x1c0a, none, none }, /* Enter */
{ none, none, none, none, none }, /* L Ctrl */
{ 0x1e61, 0x1e41, 0x1e01, 0x1e00, 0x40 }, /* A */
{ 0x1f73, 0x1f53, 0x1f13, 0x1f00, 0x40 }, /* S */
{ 0x2064, 0x2044, 0x2004, 0x2000, 0x40 }, /* D */
{ 0x2166, 0x2146, 0x2106, 0x2100, 0x40 }, /* F */
{ 0x2267, 0x2247, 0x2207, 0x2200, 0x40 }, /* G */
{ 0x2368, 0x2348, 0x2308, 0x2300, 0x40 }, /* H */
{ 0x246a, 0x244a, 0x240a, 0x2400, 0x40 }, /* J */
{ 0x256b, 0x254b, 0x250b, 0x2500, 0x40 }, /* K */
{ 0x266c, 0x264c, 0x260c, 0x2600, 0x40 }, /* L */
{ 0x273b, 0x273a, none, none, none }, /* ;: */
{ 0x2827, 0x2822, none, none, none }, /* '" */
{ 0x2960, 0x297e, none, none, none }, /* `~ */
{ none, none, none, none, none }, /* L shift */
{ 0x2b5c, 0x2b7c, 0x2b1c, none, none }, /* |\ */
{ 0x2c7a, 0x2c5a, 0x2c1a, 0x2c00, 0x40 }, /* Z */
{ 0x2d78, 0x2d58, 0x2d18, 0x2d00, 0x40 }, /* X */
{ 0x2e63, 0x2e43, 0x2e03, 0x2e00, 0x40 }, /* C */
{ 0x2f76, 0x2f56, 0x2f16, 0x2f00, 0x40 }, /* V */
{ 0x3062, 0x3042, 0x3002, 0x3000, 0x40 }, /* B */
{ 0x316e, 0x314e, 0x310e, 0x3100, 0x40 }, /* N */
{ 0x326d, 0x324d, 0x320d, 0x3200, 0x40 }, /* M */
{ 0x332c, 0x333c, none, none, none }, /* ,< */
{ 0x342e, 0x343e, none, none, none }, /* .> */
{ 0x352f, 0x353f, none, none, none }, /* /? */
{ none, none, none, none, none }, /* R Shift */
{ 0x372a, 0x372a, none, none, none }, /* * */
{ none, none, none, none, none }, /* L Alt */
{ 0x3920, 0x3920, 0x3920, 0x3920, none }, /* space */
{ none, none, none, none, none }, /* caps lock */
{ 0x3b00, 0x5400, 0x5e00, 0x6800, none }, /* F1 */
{ 0x3c00, 0x5500, 0x5f00, 0x6900, none }, /* F2 */
{ 0x3d00, 0x5600, 0x6000, 0x6a00, none }, /* F3 */
{ 0x3e00, 0x5700, 0x6100, 0x6b00, none }, /* F4 */
{ 0x3f00, 0x5800, 0x6200, 0x6c00, none }, /* F5 */
{ 0x4000, 0x5900, 0x6300, 0x6d00, none }, /* F6 */
{ 0x4100, 0x5a00, 0x6400, 0x6e00, none }, /* F7 */
{ 0x4200, 0x5b00, 0x6500, 0x6f00, none }, /* F8 */
{ 0x4300, 0x5c00, 0x6600, 0x7000, none }, /* F9 */
{ 0x4400, 0x5d00, 0x6700, 0x7100, none }, /* F10 */
{ none, none, none, none, none }, /* Num Lock */
{ none, none, none, none, none }, /* Scroll Lock */
{ 0x4700, 0x4737, 0x7700, none, 0x20 }, /* 7 Home */
{ 0x4800, 0x4838, none, none, 0x20 }, /* 8 UP */
{ 0x4900, 0x4939, 0x8400, none, 0x20 }, /* 9 PgUp */
{ 0x4a2d, 0x4a2d, none, none, none }, /* - */
{ 0x4b00, 0x4b34, 0x7300, none, 0x20 }, /* 4 Left */
{ 0x4c00, 0x4c35, none, none, 0x20 }, /* 5 */
{ 0x4d00, 0x4d36, 0x7400, none, 0x20 }, /* 6 Right */
{ 0x4e2b, 0x4e2b, none, none, none }, /* + */
{ 0x4f00, 0x4f31, 0x7500, none, 0x20 }, /* 1 End */
{ 0x5000, 0x5032, none, none, 0x20 }, /* 2 Down */
{ 0x5100, 0x5133, 0x7600, none, 0x20 }, /* 3 PgDn */
{ 0x5200, 0x5230, none, none, 0x20 }, /* 0 Ins */
{ 0x5300, 0x532e, none, none, 0x20 }, /* Del */
{ none, none, none, none, none },
{ none, none, none, none, none },
{ 0x565c, 0x567c, none, none, none }, /* \| */
{ 0x5700, 0x5700, none, none, none }, /* F11 */
{ 0x5800, 0x5800, none, none, none } /* F12 */
};
 
Bit16u
inw(port)
Bit16u port;
847,7 → 960,7
}
}
 
static char bios_svn_version_string[] = "$Revision: 1.8 $ $Date: 2009-01-26 02:37:39 $";
static char bios_svn_version_string[] = "$Revision: 1.9 $ $Date: 2009-02-06 03:48:27 $";
 
//--------------------------------------------------------------------------
// print_bios_banner
965,6 → 1078,369
}
 
 
void
int16_function(DI, SI, BP, SP, BX, DX, CX, AX, FLAGS)
Bit16u DI, SI, BP, SP, BX, DX, CX, AX, FLAGS;
{
Bit8u scan_code, ascii_code, shift_flags, led_flags, count;
Bit16u kbd_code, max;
 
shift_flags = read_byte(0x0040, 0x17);
led_flags = read_byte(0x0040, 0x97);
 
switch (GET_AH()) {
case 0x00: /* read keyboard input */
 
if ( !dequeue_key(&scan_code, &ascii_code, 1) ) {
BX_PANIC("KBD: int16h: out of keyboard input\n");
}
if (scan_code !=0 && ascii_code == 0xF0) ascii_code = 0;
else if (ascii_code == 0xE0) ascii_code = 0;
AX = (scan_code << 8) | ascii_code;
break;
 
case 0x01: /* check keyboard status */
if ( !dequeue_key(&scan_code, &ascii_code, 0) ) {
SET_ZF();
return;
}
if (scan_code !=0 && ascii_code == 0xF0) ascii_code = 0;
else if (ascii_code == 0xE0) ascii_code = 0;
AX = (scan_code << 8) | ascii_code;
CLEAR_ZF();
break;
 
case 0x02: /* get shift flag status */
shift_flags = read_byte(0x0040, 0x17);
SET_AL(shift_flags);
break;
 
case 0x05: /* store key-stroke into buffer */
if ( !enqueue_key(GET_CH(), GET_CL()) ) {
SET_AL(1);
}
else {
SET_AL(0);
}
break;
 
case 0x09: /* GET KEYBOARD FUNCTIONALITY */
// bit Bochs Description
// 7 0 reserved
// 6 0 INT 16/AH=20h-22h supported (122-key keyboard support)
// 5 1 INT 16/AH=10h-12h supported (enhanced keyboard support)
// 4 1 INT 16/AH=0Ah supported
// 3 0 INT 16/AX=0306h supported
// 2 0 INT 16/AX=0305h supported
// 1 0 INT 16/AX=0304h supported
// 0 0 INT 16/AX=0300h supported
//
SET_AL(0x30);
break;
 
case 0x10: /* read MF-II keyboard input */
 
if ( !dequeue_key(&scan_code, &ascii_code, 1) ) {
BX_PANIC("KBD: int16h: out of keyboard input\n");
}
if (scan_code !=0 && ascii_code == 0xF0) ascii_code = 0;
AX = (scan_code << 8) | ascii_code;
break;
 
case 0x11: /* check MF-II keyboard status */
if ( !dequeue_key(&scan_code, &ascii_code, 0) ) {
SET_ZF();
return;
}
if (scan_code !=0 && ascii_code == 0xF0) ascii_code = 0;
AX = (scan_code << 8) | ascii_code;
CLEAR_ZF();
break;
 
case 0x12: /* get extended keyboard status */
shift_flags = read_byte(0x0040, 0x17);
SET_AL(shift_flags);
shift_flags = read_byte(0x0040, 0x18) & 0x73;
shift_flags |= read_byte(0x0040, 0x96) & 0x0c;
SET_AH(shift_flags);
BX_DEBUG_INT16("int16: func 12 sending %04x\n",AX);
break;
 
case 0x92: /* keyboard capability check called by DOS 5.0+ keyb */
SET_AH(0x80); // function int16 ah=0x10-0x12 supported
break;
 
case 0xA2: /* 122 keys capability check called by DOS 5.0+ keyb */
// don't change AH : function int16 ah=0x20-0x22 NOT supported
break;
 
case 0x6F:
if (GET_AL() == 0x08)
SET_AH(0x02); // unsupported, aka normal keyboard
 
default:
BX_INFO("KBD: unsupported int 16h function %02x\n", GET_AH());
}
}
 
unsigned int
dequeue_key(scan_code, ascii_code, incr)
Bit8u *scan_code;
Bit8u *ascii_code;
unsigned int incr;
{
Bit16u buffer_start, buffer_end, buffer_head, buffer_tail;
Bit16u ss;
Bit8u acode, scode;
 
#if BX_CPU < 2
buffer_start = 0x001E;
buffer_end = 0x003E;
#else
buffer_start = read_word(0x0040, 0x0080);
buffer_end = read_word(0x0040, 0x0082);
#endif
 
buffer_head = read_word(0x0040, 0x001a);
buffer_tail = read_word(0x0040, 0x001c);
 
if (buffer_head != buffer_tail) {
ss = get_SS();
acode = read_byte(0x0040, buffer_head);
scode = read_byte(0x0040, buffer_head+1);
write_byte(ss, ascii_code, acode);
write_byte(ss, scan_code, scode);
 
if (incr) {
buffer_head += 2;
if (buffer_head >= buffer_end)
buffer_head = buffer_start;
write_word(0x0040, 0x001a, buffer_head);
}
return(1);
}
else {
return(0);
}
}
 
void
int09_function(DI, SI, BP, SP, BX, DX, CX, AX)
Bit16u DI, SI, BP, SP, BX, DX, CX, AX;
{
Bit8u scancode, asciicode, shift_flags;
Bit8u mf2_flags, mf2_state;
 
//
// DS has been set to F000 before call
//
 
 
scancode = GET_AL();
 
if (scancode == 0) {
BX_INFO("KBD: int09 handler: AL=0\n");
return;
}
 
 
shift_flags = read_byte(0x0040, 0x17);
mf2_flags = read_byte(0x0040, 0x18);
mf2_state = read_byte(0x0040, 0x96);
asciicode = 0;
 
switch (scancode) {
case 0x3a: /* Caps Lock press */
shift_flags ^= 0x40;
write_byte(0x0040, 0x17, shift_flags);
mf2_flags |= 0x40;
write_byte(0x0040, 0x18, mf2_flags);
break;
case 0xba: /* Caps Lock release */
mf2_flags &= ~0x40;
write_byte(0x0040, 0x18, mf2_flags);
break;
 
case 0x2a: /* L Shift press */
shift_flags |= 0x02;
write_byte(0x0040, 0x17, shift_flags);
break;
case 0xaa: /* L Shift release */
shift_flags &= ~0x02;
write_byte(0x0040, 0x17, shift_flags);
break;
 
case 0x36: /* R Shift press */
shift_flags |= 0x01;
write_byte(0x0040, 0x17, shift_flags);
break;
case 0xb6: /* R Shift release */
shift_flags &= ~0x01;
write_byte(0x0040, 0x17, shift_flags);
break;
 
case 0x1d: /* Ctrl press */
if ((mf2_state & 0x01) == 0) {
shift_flags |= 0x04;
write_byte(0x0040, 0x17, shift_flags);
if (mf2_state & 0x02) {
mf2_state |= 0x04;
write_byte(0x0040, 0x96, mf2_state);
} else {
mf2_flags |= 0x01;
write_byte(0x0040, 0x18, mf2_flags);
}
}
break;
case 0x9d: /* Ctrl release */
if ((mf2_state & 0x01) == 0) {
shift_flags &= ~0x04;
write_byte(0x0040, 0x17, shift_flags);
if (mf2_state & 0x02) {
mf2_state &= ~0x04;
write_byte(0x0040, 0x96, mf2_state);
} else {
mf2_flags &= ~0x01;
write_byte(0x0040, 0x18, mf2_flags);
}
}
break;
 
case 0x38: /* Alt press */
shift_flags |= 0x08;
write_byte(0x0040, 0x17, shift_flags);
if (mf2_state & 0x02) {
mf2_state |= 0x08;
write_byte(0x0040, 0x96, mf2_state);
} else {
mf2_flags |= 0x02;
write_byte(0x0040, 0x18, mf2_flags);
}
break;
case 0xb8: /* Alt release */
shift_flags &= ~0x08;
write_byte(0x0040, 0x17, shift_flags);
if (mf2_state & 0x02) {
mf2_state &= ~0x08;
write_byte(0x0040, 0x96, mf2_state);
} else {
mf2_flags &= ~0x02;
write_byte(0x0040, 0x18, mf2_flags);
}
break;
 
case 0x45: /* Num Lock press */
if ((mf2_state & 0x03) == 0) {
mf2_flags |= 0x20;
write_byte(0x0040, 0x18, mf2_flags);
shift_flags ^= 0x20;
write_byte(0x0040, 0x17, shift_flags);
}
break;
case 0xc5: /* Num Lock release */
if ((mf2_state & 0x03) == 0) {
mf2_flags &= ~0x20;
write_byte(0x0040, 0x18, mf2_flags);
}
break;
 
case 0x46: /* Scroll Lock press */
mf2_flags |= 0x10;
write_byte(0x0040, 0x18, mf2_flags);
shift_flags ^= 0x10;
write_byte(0x0040, 0x17, shift_flags);
break;
 
case 0xc6: /* Scroll Lock release */
mf2_flags &= ~0x10;
write_byte(0x0040, 0x18, mf2_flags);
break;
 
default:
if (scancode & 0x80) {
break; /* toss key releases ... */
}
if (scancode > MAX_SCAN_CODE) {
BX_INFO("KBD: int09h_handler(): unknown scancode read: 0x%02x!\n", scancode);
return;
}
if (shift_flags & 0x08) { /* ALT */
asciicode = scan_to_scanascii[scancode].alt;
scancode = scan_to_scanascii[scancode].alt >> 8;
} else if (shift_flags & 0x04) { /* CONTROL */
asciicode = scan_to_scanascii[scancode].control;
scancode = scan_to_scanascii[scancode].control >> 8;
} else if (((mf2_state & 0x02) > 0) && ((scancode >= 0x47) && (scancode <= 0x53))) {
/* extended keys handling */
asciicode = 0xe0;
scancode = scan_to_scanascii[scancode].normal >> 8;
} else if (shift_flags & 0x03) { /* LSHIFT + RSHIFT */
/* check if lock state should be ignored
* because a SHIFT key are pressed */
 
if (shift_flags & scan_to_scanascii[scancode].lock_flags) {
asciicode = scan_to_scanascii[scancode].normal;
scancode = scan_to_scanascii[scancode].normal >> 8;
} else {
asciicode = scan_to_scanascii[scancode].shift;
scancode = scan_to_scanascii[scancode].shift >> 8;
}
} else {
/* check if lock is on */
if (shift_flags & scan_to_scanascii[scancode].lock_flags) {
asciicode = scan_to_scanascii[scancode].shift;
scancode = scan_to_scanascii[scancode].shift >> 8;
} else {
asciicode = scan_to_scanascii[scancode].normal;
scancode = scan_to_scanascii[scancode].normal >> 8;
}
}
if (scancode==0 && asciicode==0) {
BX_INFO("KBD: int09h_handler(): scancode & asciicode are zero?\n");
}
enqueue_key(scancode, asciicode);
break;
}
if ((scancode & 0x7f) != 0x1d) {
mf2_state &= ~0x01;
}
mf2_state &= ~0x02;
write_byte(0x0040, 0x96, mf2_state);
}
 
unsigned int
enqueue_key(scan_code, ascii_code)
Bit8u scan_code, ascii_code;
{
Bit16u buffer_start, buffer_end, buffer_head, buffer_tail, temp_tail;
 
#if BX_CPU < 2
buffer_start = 0x001E;
buffer_end = 0x003E;
#else
buffer_start = read_word(0x0040, 0x0080);
buffer_end = read_word(0x0040, 0x0082);
#endif
 
buffer_head = read_word(0x0040, 0x001A);
buffer_tail = read_word(0x0040, 0x001C);
 
temp_tail = buffer_tail;
buffer_tail += 2;
if (buffer_tail >= buffer_end)
buffer_tail = buffer_start;
 
if (buffer_tail == buffer_head) {
return(0);
}
 
write_byte(0x0040, temp_tail, ascii_code);
write_byte(0x0040, temp_tail+1, scan_code);
write_word(0x0040, 0x001C, buffer_tail);
return(1);
}
 
 
#define SET_DISK_RET_STATUS(status) write_byte(0x0040, 0x0074, status)
 
void
1624,8 → 2100,35
call ebda_post
 
;; Keyboard
SET_INT_VECTOR(0x09, #0xF000, #int09_handler)
SET_INT_VECTOR(0x16, #0xF000, #int16_handler)
 
xor ax, ax
mov ds, ax
mov 0x0417, al /* keyboard shift flags, set 1 */
mov 0x0418, al /* keyboard shift flags, set 2 */
mov 0x0419, al /* keyboard alt-numpad work area */
mov 0x0471, al /* keyboard ctrl-break flag */
mov 0x0497, al /* keyboard status flags 4 */
mov al, #0x10
mov 0x0496, al /* keyboard status flags 3 */
 
 
/* keyboard head of buffer pointer */
mov bx, #0x001E
mov 0x041A, bx
 
/* keyboard end of buffer pointer */
mov 0x041C, bx
 
/* keyboard pointer to start of buffer */
mov bx, #0x001E
mov 0x0480, bx
 
/* keyboard pointer to end of buffer */
mov bx, #0x003E
mov 0x0482, bx
 
;; Video setup
SET_INT_VECTOR(0x10, #0xF000, #int10_handler)
 
1666,20 → 2169,59
 
jmp int19_relocated
 
 
;----------------------------------------
;- INT 16h Keyboard Service Entry Point -
;----------------------------------------
.org 0xe82e
int16_handler:
cmp ah, #0x01
je int16_01
cmp ah, #0x02
je int16_02
 
sti
push ds
pushf
;pusha ; we do this instead:
push ax
push cx
push dx
push bx
push sp
mov bx, sp
add [bx], #10
mov bx, [bx+2]
push bp
push si
push di
 
cmp ah, #0x00
je int16_F00
cmp ah, #0x10
je int16_F00
 
mov bx, #0xf000
mov ds, bx
call _int16_function
; popa ; we do this instead:
pop di
pop si
pop bp
add sp, #2
pop bx
pop dx
pop cx
pop ax
popf
pop ds
jz int16_zero_set
 
int16_zero_clear:
push bp
mov bp, sp
//SEG SS
and BYTE [bp + 0x06], #0xbf
pop bp
iret
int16_02:
mov al, #0x0
iret
int16_01:
 
int16_zero_set:
push bp
mov bp, sp
//SEG SS
1687,10 → 2229,121
pop bp
iret
 
.org 0xf045 ; INT 10 Functions 0-Fh Entry Point
;; HALT(__LINE__)
int16_F00:
mov bx, #0x0040
mov ds, bx
 
int16_wait_for_key:
cli
mov bx, 0x001a
cmp bx, 0x001c
jne int16_key_found
sti
nop
#if 0
/* no key yet, call int 15h, function AX=9002 */
0x50, /* push AX */
0xb8, 0x02, 0x90, /* mov AX, #0x9002 */
0xcd, 0x15, /* int 15h */
0x58, /* pop AX */
0xeb, 0xea, /* jmp WAIT_FOR_KEY */
#endif
jmp int16_wait_for_key
 
int16_key_found:
mov bx, #0xf000
mov ds, bx
call _int16_function
; popa ; we do this instead:
pop di
pop si
pop bp
add sp, #2
pop bx
pop dx
pop cx
pop ax
popf
pop ds
#if 0
/* notify int16 complete w/ int 15h, function AX=9102 */
0x50, /* push AX */
0xb8, 0x02, 0x91, /* mov AX, #0x9102 */
0xcd, 0x15, /* int 15h */
0x58, /* pop AX */
#endif
iret
 
 
 
;-------------------------------------------------
;- INT09h : Keyboard Hardware Service Entry Point -
;-------------------------------------------------
.org 0xe987
int09_handler:
cli
push ax
 
in al, #0x60 ;;read key from keyboard controller
sti
push ds
;pusha ; we do this instead:
 
push ax
push cx
push dx
push bx
push sp
mov bx, sp
add [bx], #10
mov bx, [bx+2]
push bp
push si
push di
 
;; check for extended key
cmp al, #0xe0
jne int09_check_pause
xor ax, ax
mov ds, ax
mov al, BYTE [0x496] ;; mf2_state |= 0x02
or al, #0x02
mov BYTE [0x496], al
jmp int09_done
 
int09_check_pause: ;; check for pause key
cmp al, #0xe1
jne int09_process_key
xor ax, ax
mov ds, ax
mov al, BYTE [0x496] ;; mf2_state |= 0x01
or al, #0x01
mov BYTE [0x496], al
jmp int09_done
 
int09_process_key:
mov bx, #0xf000
mov ds, bx
call _int09_function
 
int09_done:
; popa ; we do this instead:
pop di
pop si
pop bp
add sp, #2
pop bx
pop dx
pop cx
pop ax
 
pop ds
cli
 
pop ax
iret
 
 
;----------
;- INT10h -
;----------
/trunk/soc/bios/vgabios.c
234,7 → 234,7
 
#if defined(USE_BX_INFO) || defined(DEBUG)
msg_vga_init:
.ascii "VGABios $Id: vgabios.c,v 1.6 2009-01-26 02:37:39 zeus Exp $"
.ascii "VGABios $Id: vgabios.c,v 1.7 2009-02-06 03:48:27 zeus Exp $"
.byte 0x0d,0x0a,0x00
#endif
ASM_END
/trunk/src/bochs-diff-2.3.7/disasm/syntax.cc
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: syntax.cc,v 1.4 2009-01-26 02:37:40 zeus Exp $
// $Id: syntax.cc,v 1.5 2009-02-06 03:48:30 zeus Exp $
/////////////////////////////////////////////////////////////////////////
 
#include <stdio.h>
/trunk/src/bochs-diff-2.3.7/bochs.h
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: bochs.h,v 1.4 2009-01-26 02:37:39 zeus Exp $
// $Id: bochs.h,v 1.5 2009-02-06 03:48:29 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
/trunk/src/bochs-diff-2.3.7/gui/gui.cc
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.4 2009-01-26 02:37:41 zeus Exp $
// $Id: gui.cc,v 1.5 2009-02-06 03:48:31 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
/trunk/src/bochs-diff-2.3.7/plugin.h
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: plugin.h,v 1.4 2009-01-26 02:37:39 zeus Exp $
// $Id: plugin.h,v 1.5 2009-02-06 03:48:29 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// This file provides macros and types needed for plugins. It is based on
/trunk/src/bochs-diff-2.3.7/iodev/devices.cc
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: devices.cc,v 1.4 2009-01-26 02:37:42 zeus Exp $
// $Id: devices.cc,v 1.5 2009-02-06 03:48:32 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
124,7 → 124,7
unsigned i;
const char def_name[] = "Default";
 
BX_DEBUG(("Init $Id: devices.cc,v 1.4 2009-01-26 02:37:42 zeus Exp $"));
BX_DEBUG(("Init $Id: devices.cc,v 1.5 2009-02-06 03:48:32 zeus Exp $"));
mem = newmem;
 
/* set no-default handlers, will be overwritten by the real default handler */
/trunk/src/bochs-diff-2.3.7/iodev/hdemu.cc
38,7 → 38,7
{
char name[16];
 
BX_DEBUG(("Init $Id: hdemu.cc,v 1.4 2009-01-26 02:37:42 zeus Exp $"));
BX_DEBUG(("Init $Id: hdemu.cc,v 1.5 2009-02-06 03:48:32 zeus Exp $"));
 
sprintf(name, "Hd emu");
/* hdemu i/o ports */
/trunk/src/bochs-diff-2.3.7/iodev/iodev.h
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: iodev.h,v 1.4 2009-01-26 02:37:42 zeus Exp $
// $Id: iodev.h,v 1.5 2009-02-06 03:48:32 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
/trunk/src/bochs-diff-2.3.7/cpu/cpu.cc
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.cc,v 1.4 2009-01-26 02:37:40 zeus Exp $
// $Id: cpu.cc,v 1.5 2009-02-06 03:48:30 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
/trunk/src/bochs-diff-2.3.7/cpu/crregs.h
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: crregs.h,v 1.4 2009-01-26 02:37:40 zeus Exp $
// $Id: crregs.h,v 1.5 2009-02-06 03:48:30 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007 Stanislav Shwartsman
/trunk/src/bochs-diff-2.3.7/cpu/bcd.cc
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: bcd.cc,v 1.4 2009-01-26 02:37:40 zeus Exp $
// $Id: bcd.cc,v 1.5 2009-02-06 03:48:30 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
/trunk/src/bochs-diff-2.3.7/instrument/zet/instrument.cc
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: instrument.cc,v 1.4 2009-01-26 02:37:41 zeus Exp $
// $Id: instrument.cc,v 1.5 2009-02-06 03:48:31 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
/trunk/src/bochs-diff-2.3.7/instrument/zet/instrument.h
1,5 → 1,5
/////////////////////////////////////////////////////////////////////////
// $Id: instrument.h,v 1.4 2009-01-26 02:37:41 zeus Exp $
// $Id: instrument.h,v 1.5 2009-02-06 03:48:31 zeus Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
/trunk/README
5,9 → 5,7
 
For building the system (Xilinx tools must be installed):
$ source /opt/Xilinx/10.1/ISE/settings64.sh # (or equivalent)
$ cd rtl-model/
$ ../bin/web2rom # (php-cli package must be installed)
$ cd ../impl/virtex4-ml403ep/syn/
$ cd impl/virtex4-ml403ep/syn/
$ make
 
As a result, you will have a file named "kotku.bit", which is the conf-

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.