Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
6933ee64cd | |||
4cfb1a27b5 | |||
8f7ee79d05 | |||
|
da418f65b3 | ||
|
bfc59f6636 | ||
|
f7bdaa8909 | ||
|
2dd6a1516e | ||
5593d344cd | |||
|
28668acd86 | ||
|
cb733c6d1d | ||
|
cf354ec8d3 | ||
c8e9e5a2a7 | |||
|
b815aee084 | ||
|
7a6d042da7 | ||
2d9007da32 | |||
|
b558f23604 | ||
|
dd5a6a7316 |
2
.gitignore
vendored
@ -7,3 +7,5 @@ ehthumbs_vista.db
|
||||
### macOS ###
|
||||
.DS_Store
|
||||
._*
|
||||
programs/cmm/cmm.code-workspace
|
||||
programs/cmm/menu/.gitignore
|
||||
|
@ -474,21 +474,22 @@ tup.append_table(img_files, {
|
||||
{"DEVELOP/EXAMPLES/USE_MB", VAR_PROGS .. "/demos/use_mb/use_mb"},
|
||||
{"File Managers/KFAR", VAR_PROGS .. "/fs/kfar/trunk/kfar"},
|
||||
{"File Managers/OPENDIAL", VAR_PROGS .. "/fs/opendial/opendial"},
|
||||
{"GAMES/15", VAR_PROGS .. "/games/15/trunk/15"},
|
||||
{"GAMES/15", VAR_PROGS .. "/games/15/15"},
|
||||
{"GAMES/DINO", VAR_PROGS .. "/games/dino/dino"},
|
||||
{"GAMES/FREECELL", VAR_PROGS .. "/games/freecell/freecell"},
|
||||
{"GAMES/GOMOKU", VAR_PROGS .. "/games/gomoku/trunk/gomoku"},
|
||||
{"GAMES/LIGHTS", VAR_PROGS .. "/games/sq_game/trunk/SQ_GAME"},
|
||||
{"GAMES/GOMOKU", VAR_PROGS .. "/games/gomoku/gomoku"},
|
||||
{"GAMES/LIGHTS", VAR_PROGS .. "/games/sq_game/SQ_GAME"},
|
||||
{"GAMES/LINES", VAR_PROGS .. "/games/lines/lines"},
|
||||
{"GAMES/MSQUARE", VAR_PROGS .. "/games/MSquare/trunk/MSquare"},
|
||||
{"GAMES/MSQUARE", VAR_PROGS .. "/games/MSquare/MSquare"},
|
||||
{"GAMES/PIPES", VAR_PROGS .. "/games/pipes/pipes"},
|
||||
{"GAMES/PONG", VAR_PROGS .. "/games/pong/trunk/pong"},
|
||||
{"GAMES/PONG3", VAR_PROGS .. "/games/pong3/trunk/pong3"},
|
||||
{"GAMES/RSQUARE", VAR_PROGS .. "/games/rsquare/trunk/rsquare"},
|
||||
{"GAMES/SNAKE", VAR_PROGS .. "/games/snake/trunk/snake"},
|
||||
{"GAMES/SUDOKU", VAR_PROGS .. "/games/sudoku/trunk/sudoku"},
|
||||
{"GAMES/SW", VAR_PROGS .. "/games/sw/trunk/sw"},
|
||||
{"GAMES/TANKS", VAR_PROGS .. "/games/tanks/trunk/tanks"},
|
||||
{"GAMES/TETRIS", VAR_PROGS .. "/games/tetris/trunk/tetris"},
|
||||
{"GAMES/PONG", VAR_PROGS .. "/games/pong/pong"},
|
||||
{"GAMES/PONG3", VAR_PROGS .. "/games/pong3/pong3"},
|
||||
{"GAMES/RSQUARE", VAR_PROGS .. "/games/rsquare/rsquare"},
|
||||
{"GAMES/SNAKE", VAR_PROGS .. "/games/snake/snake"},
|
||||
{"GAMES/SUDOKU", VAR_PROGS .. "/games/sudoku/sudoku"},
|
||||
{"GAMES/SW", VAR_PROGS .. "/games/sw/sw"},
|
||||
{"GAMES/TANKS", VAR_PROGS .. "/games/tanks/tanks"},
|
||||
{"GAMES/TETRIS", VAR_PROGS .. "/games/tetris/tetris"},
|
||||
{"LIB/ARCHIVER.OBJ", VAR_PROGS .. "/fs/kfar/trunk/kfar_arc/kfar_arc.obj"},
|
||||
{"LIB/BOX_LIB.OBJ", VAR_PROGS .. "/develop/libraries/box_lib/trunk/box_lib.obj"},
|
||||
{"LIB/BUF2D.OBJ", VAR_PROGS .. "/develop/libraries/buf2d/trunk/buf2d.obj"},
|
||||
@ -587,20 +588,21 @@ tup.append_table(extra_files, {
|
||||
{"kolibrios/3D/voxel_utilites/VOX_CREATOR" , VAR_PROGS .. "/media/voxel_editor/utilites/vox_creator"},
|
||||
{"kolibrios/3D/voxel_utilites/VOX_MOVER" , VAR_PROGS .. "/media/voxel_editor/utilites/vox_mover"},
|
||||
{"kolibrios/3D/voxel_utilites/VOX_TGL" , VAR_PROGS .. "/media/voxel_editor/utilites/vox_tgl"},
|
||||
{"kolibrios/demos/life3", VAR_PROGS .. "/games/life3/trunk/life3"},
|
||||
{"kolibrios/demos/life3", VAR_PROGS .. "/games/life3/life3"},
|
||||
{"kolibrios/demos/qjulia", VAR_PROGS .. "/demos/qjulia/trunk/qjulia"},
|
||||
{"kolibrios/develop/utils/koldbg", VAR_PROGS .. "/develop/koldbg/koldbg"},
|
||||
{"kolibrios/develop/utils/charset_checker", VAR_PROGS .. "/other/charset_checker/charchck"},
|
||||
{"kolibrios/games/Almaz", VAR_PROGS .. "/games/almaz/almaz"},
|
||||
{"kolibrios/games/arcanii", VAR_PROGS .. "/games/arcanii/trunk/arcanii"},
|
||||
{"kolibrios/games/arcanii", VAR_PROGS .. "/games/arcanii/arcanii"},
|
||||
{"kolibrios/games/bomber/bomber", VAR_PROGS .. "/games/bomber/bomber"},
|
||||
{"kolibrios/games/bomber/bomberdata.bin", VAR_PROGS .. "/games/bomber/sounds/bomberdata.bin"},
|
||||
{"kolibrios/games/codemaster/binary_master", VAR_PROGS .. "/games/codemaster/binary_master"},
|
||||
{"kolibrios/games/codemaster/hang_programmer", VAR_PROGS .. "/games/codemaster/hang_programmer"},
|
||||
{"kolibrios/games/codemaster/kolibri_puzzle", VAR_PROGS .. "/games/codemaster/kolibri_puzzle"},
|
||||
{"kolibrios/games/megamaze", VAR_PROGS .. "/games/megamaze/trunk/megamaze"},
|
||||
{"kolibrios/games/megamaze", VAR_PROGS .. "/games/megamaze/megamaze"},
|
||||
{"kolibrios/games/invaders", VAR_PROGS .. "/games/invaders/invaders"},
|
||||
{"kolibrios/games/phenix", VAR_PROGS .. "/games/phenix/trunk/phenix"},
|
||||
{"kolibrios/games/soko/soko", VAR_PROGS .. "/games/soko/trunk/SOKO"},
|
||||
{"kolibrios/games/phenix", VAR_PROGS .. "/games/phenix/phenix"},
|
||||
{"kolibrios/games/soko/soko", VAR_PROGS .. "/games/soko/SOKO"},
|
||||
{"kolibrios/media/img_transform", VAR_PROGS .. "/media/img_transform/img_transform"},
|
||||
{"kolibrios/media/zsea/zsea", VAR_PROGS .. "/media/zsea/zSea"},
|
||||
{"kolibrios/media/zsea/plugins/cnv_bmp.obj", VAR_PROGS .. "/media/zsea/plugins/bmp/cnv_bmp.obj"},
|
||||
@ -617,7 +619,7 @@ tup.append_table(extra_files, {
|
||||
-- For russian build, add russian-only programs.
|
||||
if build_type == "ru_RU" then tup.append_table(img_files, {
|
||||
{"PERIOD", VAR_PROGS .. "/other/period/trunk/period"},
|
||||
{"GAMES/KLAVISHA", VAR_PROGS .. "/games/klavisha/trunk/klavisha"},
|
||||
{"GAMES/KLAVISHA", VAR_PROGS .. "/games/klavisha/klavisha"},
|
||||
{"DEVELOP/EXAMPLES/TESTCON2", VAR_PROGS .. "/develop/libraries/console_coff/examples/testcon2_rus"},
|
||||
}) else tup.append_table(img_files, {
|
||||
{"DEVELOP/TESTCON2", VAR_PROGS .. "/develop/libraries/console_coff/examples/testcon2_eng"},
|
||||
@ -638,7 +640,7 @@ tup.append_table(img_files, {
|
||||
{"TINFO", VAR_PROGS .. "/system/tinfo/tinfo"},
|
||||
{"DEVELOP/MSTATE", VAR_PROGS .. "/develop/mstate/mstate"},
|
||||
{"DEVELOP/GENFILES", VAR_PROGS .. "/testing/genfiles/GenFiles"},
|
||||
{"GAMES/C4", VAR_PROGS .. "/games/c4/trunk/c4"},
|
||||
{"GAMES/C4", VAR_PROGS .. "/games/c4/c4"},
|
||||
{"MEDIA/FILLSCR", VAR_PROGS .. "/media/FillScr/fillscr"},
|
||||
})
|
||||
tup.append_table(extra_files, {
|
||||
@ -675,11 +677,11 @@ tup.append_table(img_files, {
|
||||
{"File Managers/KFM2", VAR_PROGS .. "/cmm/misc/kfm2.com"},
|
||||
{"KF_VIEW", VAR_PROGS .. "/cmm/kf_font_viewer/font_viewer.com"},
|
||||
{"DEVELOP/DIFF", VAR_PROGS .. "/cmm/diff/diff.com"},
|
||||
{"GAMES/CLICKS", VAR_PROGS .. "/games/clicks/trunk/clicks.com"},
|
||||
{"GAMES/CLICKS", VAR_PROGS .. "/games/clicks/clicks.com"},
|
||||
{"GAMES/MBLOCKS", VAR_PROGS .. "/cmm/misc/mblocks.com"},
|
||||
{"GAMES/FLOOD-IT", VAR_PROGS .. "/games/flood-it/trunk/flood-it.com"},
|
||||
{"GAMES/MINE", VAR_PROGS .. "/games/mine/trunk/mine"},
|
||||
{"GAMES/NUMBERS", VAR_PROGS .. "/games/FindNumbers/trunk/FindNumbers"},
|
||||
{"GAMES/FLOOD-IT", VAR_PROGS .. "/games/flood-it/flood-it.com"},
|
||||
{"GAMES/MINE", VAR_PROGS .. "/games/mine/mine"},
|
||||
{"GAMES/NUMBERS", VAR_PROGS .. "/games/FindNumbers/FindNumbers"},
|
||||
{"MEDIA/PIXIE", VAR_PROGS .. "/cmm/pixie2/pixie.com"},
|
||||
{"MEDIA/ICONEDIT", VAR_PROGS .. "/cmm/iconedit/iconedit.com"},
|
||||
{"NETWORK/DL", VAR_PROGS .. "/cmm/downloader/dl.com"},
|
||||
@ -706,12 +708,12 @@ tup.append_table(img_files, {
|
||||
{"TABLE", VAR_PROGS .. "/other/table/table"},
|
||||
{"MEDIA/AC97SND", VAR_PROGS .. "/media/ac97snd/ac97snd.bin"},
|
||||
{"GAMES/KOSILKA", VAR_PROGS .. "/games/kosilka/kosilka"},
|
||||
{"GAMES/RFORCES", VAR_PROGS .. "/games/rforces/trunk/rforces"},
|
||||
{"GAMES/XONIX", VAR_PROGS .. "/games/xonix/trunk/xonix"},
|
||||
{"GAMES/RFORCES", VAR_PROGS .. "/games/rforces/rforces"},
|
||||
{"GAMES/XONIX", VAR_PROGS .. "/games/xonix/xonix"},
|
||||
})
|
||||
tup.append_table(extra_files, {
|
||||
{"kolibrios/games/fara/fara", VAR_PROGS .. "/games/fara/trunk/fara"},
|
||||
{"kolibrios/games/LaserTank/LaserTank", VAR_PROGS .. "/games/LaserTank/trunk/LaserTank"},
|
||||
{"kolibrios/games/fara/fara", VAR_PROGS .. "/games/fara/fara"},
|
||||
{"kolibrios/games/LaserTank/LaserTank", VAR_PROGS .. "/games/LaserTank/LaserTank"},
|
||||
})
|
||||
end -- tup.getconfig('NO_MSVC') ~= 'full'
|
||||
|
||||
@ -741,7 +743,7 @@ end -- tup.getconfig('NO_TCC') ~= 'full'
|
||||
-- Programs that require GCC to compile.
|
||||
if tup.getconfig('NO_GCC') ~= 'full' then
|
||||
tup.append_table(img_files, {
|
||||
{"GAMES/REVERSI", VAR_PROGS .. "/games/reversi/trunk/reversi"},
|
||||
{"GAMES/REVERSI", VAR_PROGS .. "/games/reversi/reversi"},
|
||||
{"LIB/BASE64.OBJ", VAR_PROGS .. "/develop/libraries/base64/base64.obj"},
|
||||
{"LIB/LIBC.OBJ", VAR_PROGS .. "/develop/ktcc/trunk/libc.obj/source/libc.obj"},
|
||||
{"LIB/ICONV.OBJ", VAR_PROGS .. "/develop/libraries/iconv/iconv.obj"},
|
||||
@ -753,7 +755,7 @@ tup.append_table(extra_files, {
|
||||
{"kolibrios/emul/e80/e80", VAR_PROGS .. "/emulator/e80/trunk/e80"},
|
||||
{"kolibrios/emul/uarm/", VAR_CONTRIB .. "/other/uarm/uARM"},
|
||||
{"kolibrios/games/2048", VAR_PROGS .. "/games/2048/2048"},
|
||||
{"kolibrios/games/checkers", VAR_PROGS .. "/games/checkers/trunk/checkers"},
|
||||
{"kolibrios/games/checkers", VAR_PROGS .. "/games/checkers/checkers"},
|
||||
{"kolibrios/games/donkey", VAR_PROGS .. "/games/donkey/donkey"},
|
||||
{"kolibrios/games/heliothryx", VAR_PROGS .. "/games/heliothryx/heliothryx"},
|
||||
{"kolibrios/games/marblematch3", VAR_PROGS .. "/games/marblematch3/marblematch3"},
|
||||
|
@ -1,9 +1,8 @@
|
||||
[rbmenu]
|
||||
Processes=cpu
|
||||
Themes=desktop
|
||||
Theme settings=skincfg
|
||||
Background=/sys/media/palitra
|
||||
Device setup=setup
|
||||
Shell=shell
|
||||
System panel=syspanel
|
||||
[00]
|
||||
name=KFM2
|
||||
path=/SYS/FILE MANAGERS/KFM2
|
||||
@ -22,23 +21,23 @@ y=68
|
||||
name=EOLITE
|
||||
path=/SYS/FILE MANAGERS/EOLITE
|
||||
param=
|
||||
ico=1
|
||||
ico=0
|
||||
x=68
|
||||
y=0
|
||||
[03]
|
||||
name=SHELL
|
||||
path=SHELL
|
||||
param=
|
||||
ico=2
|
||||
x=136
|
||||
y=0
|
||||
ico=1
|
||||
x=-203
|
||||
y=136
|
||||
[04]
|
||||
name=KFAR
|
||||
path=/SYS/FILE MANAGERS/KFAR
|
||||
param=
|
||||
ico=16
|
||||
x=68
|
||||
y=68
|
||||
x=136
|
||||
y=0
|
||||
[05]
|
||||
name=RDSAVE
|
||||
path=RDSAVE
|
||||
@ -64,7 +63,7 @@ y=68
|
||||
name=KPACK
|
||||
path=KPACK
|
||||
param=
|
||||
ico=10
|
||||
ico=99
|
||||
x=-67
|
||||
y=0
|
||||
[09]
|
||||
@ -89,10 +88,10 @@ ico=66
|
||||
x=-135
|
||||
y=-67
|
||||
[0C]
|
||||
name=MBLOCKS
|
||||
path=/SYS/GAMES/MBLOCKS
|
||||
name=TETRIS
|
||||
path=/SYS/GAMES/TETRIS
|
||||
param=
|
||||
ico=11
|
||||
ico=47
|
||||
x=-67
|
||||
y=-135
|
||||
[0D]
|
||||
@ -107,8 +106,8 @@ name=15
|
||||
path=/SYS/GAMES/15
|
||||
param=
|
||||
ico=34
|
||||
x=-271
|
||||
y=-67
|
||||
x=-67
|
||||
y=-203
|
||||
[0F]
|
||||
name=DOCPACK
|
||||
path=DOCPACK
|
||||
@ -170,8 +169,8 @@ name=FLAPPY-BIRD
|
||||
path=/SYS/GAMES/FLPYBIRD
|
||||
param=
|
||||
ico=49
|
||||
x=-271
|
||||
y=-135
|
||||
x=-135
|
||||
y=-203
|
||||
[18]
|
||||
name=KOSILKA
|
||||
path=/SYS/GAMES/KOSILKA
|
||||
@ -215,16 +214,44 @@ ico=6
|
||||
x=-67
|
||||
y=136
|
||||
[1E]
|
||||
name=CALC
|
||||
path=CALC
|
||||
param=
|
||||
ico=4
|
||||
x=-203
|
||||
y=68
|
||||
[1F]
|
||||
name=APP+
|
||||
path=app_plus
|
||||
param=
|
||||
ico=27
|
||||
x=204
|
||||
y=68
|
||||
[1F]
|
||||
name=DIFF
|
||||
path=/sys/DEVELOP/DIFF
|
||||
param=
|
||||
ico=84
|
||||
x=-203
|
||||
y=68
|
||||
[20]
|
||||
name=CEDIT
|
||||
path=/sys/develop/cedit
|
||||
param=
|
||||
ico=58
|
||||
x=68
|
||||
y=68
|
||||
[21]
|
||||
name=CALC
|
||||
path=CALC
|
||||
param=
|
||||
ico=4
|
||||
x=204
|
||||
y=0
|
||||
[22]
|
||||
name=NETSURF
|
||||
path=/sys/NETWORK/NSINST
|
||||
param=
|
||||
ico=125
|
||||
x=204
|
||||
y=136
|
||||
[23]
|
||||
name=DINO
|
||||
path=/sys/games/dino
|
||||
param=
|
||||
ico=129
|
||||
x=-203
|
||||
y=-203
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 44 KiB |
@ -16,6 +16,7 @@ Freecell=games/freecell,68
|
||||
Pong=games/pong,101
|
||||
Pong3=games/pong3,12
|
||||
Arcanii=/kg/arcanii,12
|
||||
Dino=games/dino,129
|
||||
|
||||
[Arcade]
|
||||
LaserTank=/kg/lasertank/lasertank,72
|
||||
|
@ -106,8 +106,8 @@ name=15
|
||||
path=/SYS/GAMES/15
|
||||
param=
|
||||
ico=34
|
||||
x=-271
|
||||
y=-67
|
||||
x=-67
|
||||
y=-203
|
||||
[0F]
|
||||
name=DOCPACK
|
||||
path=DOCPACK
|
||||
@ -169,8 +169,8 @@ name=FLAPPY-BIRD
|
||||
path=/SYS/GAMES/FLPYBIRD
|
||||
param=
|
||||
ico=49
|
||||
x=-271
|
||||
y=-135
|
||||
x=-135
|
||||
y=-203
|
||||
[18]
|
||||
name=KOSILKA
|
||||
path=/SYS/GAMES/KOSILKA
|
||||
@ -248,3 +248,10 @@ param=
|
||||
ico=125
|
||||
x=204
|
||||
y=136
|
||||
[23]
|
||||
name=DINO
|
||||
path=/sys/games/dino
|
||||
param=
|
||||
ico=129
|
||||
x=-203
|
||||
y=-203
|
||||
|
@ -106,8 +106,8 @@ name=15
|
||||
path=/SYS/GAMES/15
|
||||
param=
|
||||
ico=34
|
||||
x=-271
|
||||
y=-67
|
||||
x=-67
|
||||
y=-203
|
||||
[0F]
|
||||
name=DOCPACK
|
||||
path=DOCPACK
|
||||
@ -169,8 +169,8 @@ name=FLAPPY-BIRD
|
||||
path=/SYS/GAMES/FLPYBIRD
|
||||
param=
|
||||
ico=49
|
||||
x=-271
|
||||
y=-135
|
||||
x=-135
|
||||
y=-203
|
||||
[18]
|
||||
name=KOSILKA
|
||||
path=/SYS/GAMES/KOSILKA
|
||||
@ -248,3 +248,10 @@ param=
|
||||
ico=125
|
||||
x=204
|
||||
y=136
|
||||
[23]
|
||||
name=DINO
|
||||
path=/sys/games/dino
|
||||
param=
|
||||
ico=129
|
||||
x=-203
|
||||
y=-203
|
||||
|
@ -106,8 +106,8 @@ name=15
|
||||
path=/SYS/GAMES/15
|
||||
param=
|
||||
ico=34
|
||||
x=-271
|
||||
y=-67
|
||||
x=-67
|
||||
y=-203
|
||||
[0F]
|
||||
name=DOCPACK
|
||||
path=DOCPACK
|
||||
@ -169,8 +169,8 @@ name=FLAPPY-BIRD
|
||||
path=/SYS/GAMES/FLPYBIRD
|
||||
param=
|
||||
ico=49
|
||||
x=-271
|
||||
y=-135
|
||||
x=-135
|
||||
y=-203
|
||||
[18]
|
||||
name=KOSILKA
|
||||
path=/SYS/GAMES/KOSILKA
|
||||
@ -248,3 +248,10 @@ param=
|
||||
ico=125
|
||||
x=204
|
||||
y=136
|
||||
[23]
|
||||
name=DINO
|
||||
path=/sys/games/dino
|
||||
param=
|
||||
ico=129
|
||||
x=-203
|
||||
y=-203
|
||||
|
@ -106,8 +106,8 @@ name=15
|
||||
path=/SYS/GAMES/15
|
||||
param=
|
||||
ico=34
|
||||
x=-271
|
||||
y=-67
|
||||
x=-67
|
||||
y=-203
|
||||
[0F]
|
||||
name=DOCPACK
|
||||
path=DOCPACK
|
||||
@ -169,8 +169,8 @@ name=FLAPPY-BIRD
|
||||
path=/SYS/GAMES/FLPYBIRD
|
||||
param=
|
||||
ico=49
|
||||
x=-271
|
||||
y=-135
|
||||
x=-135
|
||||
y=-203
|
||||
[18]
|
||||
name=KOSILKA
|
||||
path=/SYS/GAMES/KOSILKA
|
||||
@ -248,3 +248,10 @@ param=
|
||||
ico=125
|
||||
x=204
|
||||
y=136
|
||||
[23]
|
||||
name=DINO
|
||||
path=/sys/games/dino
|
||||
param=
|
||||
ico=129
|
||||
x=-203
|
||||
y=-203
|
||||
|
@ -16,6 +16,7 @@ Freecell=games/freecell,68
|
||||
Pong=games/pong,101
|
||||
Pong3=games/pong3,12
|
||||
Arcanii=/kg/arcanii,12
|
||||
Dino=games/dino,129
|
||||
|
||||
[€àª ¤ë]
|
||||
LaserTank=/kg/lasertank/lasertank,72
|
||||
|
@ -106,8 +106,8 @@ name=15
|
||||
path=/SYS/GAMES/15
|
||||
param=
|
||||
ico=34
|
||||
x=-271
|
||||
y=-67
|
||||
x=-67
|
||||
y=-203
|
||||
[0F]
|
||||
name=DOCPACK
|
||||
path=DOCPACK
|
||||
@ -169,8 +169,8 @@ name=FLAPPY-BIRD
|
||||
path=/SYS/GAMES/FLPYBIRD
|
||||
param=
|
||||
ico=49
|
||||
x=-271
|
||||
y=-135
|
||||
x=-135
|
||||
y=-203
|
||||
[18]
|
||||
name=KOSILKA
|
||||
path=/SYS/GAMES/KOSILKA
|
||||
@ -248,3 +248,10 @@ param=
|
||||
ico=125
|
||||
x=204
|
||||
y=136
|
||||
[23]
|
||||
name=DINO
|
||||
path=/sys/games/dino
|
||||
param=
|
||||
ico=129
|
||||
x=-203
|
||||
y=-203
|
||||
|
3
drivers/serial/Tupfile.lua
Normal file
@ -0,0 +1,3 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
ROOT = "../.."
|
||||
tup.rule("serial.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "%B.sys")
|
272
drivers/serial/common.inc
Executable file
@ -0,0 +1,272 @@
|
||||
SERIAL_API_GET_VERSION = 0
|
||||
SERIAL_API_SRV_ADD_PORT = 1
|
||||
SERIAL_API_SRV_REMOVE_PORT = 2
|
||||
SERIAL_API_SRV_HANDLE_EVENT = 3
|
||||
SERIAL_API_OPEN_PORT = 4
|
||||
SERIAL_API_CLOSE_PORT = 5
|
||||
SERIAL_API_SETUP_PORT = 6
|
||||
SERIAL_API_READ = 7
|
||||
SERIAL_API_WRITE = 8
|
||||
|
||||
SERIAL_API_ERR_PORT_INVALID = 1
|
||||
SERIAL_API_ERR_PORT_BUSY = 2
|
||||
SERIAL_API_ERR_CONF = 3
|
||||
|
||||
SERIAL_EVT_TXE = 1 ; tx fifo or register is empty, all data has been sent
|
||||
SERIAL_EVT_RXNE = 2 ; rx fifo or register is not empty
|
||||
|
||||
SERIAL_CONF_PARITY_NONE = 0
|
||||
SERIAL_CONF_PARITY_EVEN = 1
|
||||
SERIAL_CONF_PARITY_ODD = 2
|
||||
SERIAL_CONF_PARITY_MARK = 3
|
||||
SERIAL_CONF_PARITY_SPACE = 4
|
||||
|
||||
SERIAL_CONF_FLOW_CTRL_NONE = 0
|
||||
|
||||
struct SP_DRIVER
|
||||
size dd ? ; size of this struct
|
||||
startup dd ? ; void __stdcall (*startup)(void *drv_data, const struct serial_conf *conf);
|
||||
shutdown dd ? ; void __stdcall (*shutdown)(void *drv_data);
|
||||
reconf dd ? ; void __stdcall (*reconf)(void *drv_data, const struct serial_conf *conf);
|
||||
tx dd ? ; void __stdcall (*tx)(void *drv_data);
|
||||
ends
|
||||
|
||||
struct SP_CONF
|
||||
size dd ? ; size of this struct
|
||||
baudrate dd ?
|
||||
word_size db ?
|
||||
stop_bits db ?
|
||||
parity db ?
|
||||
flow_ctrl db ?
|
||||
ends
|
||||
|
||||
proc serial_add_port stdcall, drv:dword, drv_data:dword
|
||||
locals
|
||||
handler dd ?
|
||||
io_code dd ?
|
||||
input dd ?
|
||||
inp_size dd ?
|
||||
output dd ?
|
||||
out_size dd ?
|
||||
endl
|
||||
mov eax, [serial_drv_entry]
|
||||
mov [handler], eax
|
||||
mov [io_code], SERIAL_API_SRV_ADD_PORT
|
||||
lea eax, [drv]
|
||||
mov [input], eax
|
||||
mov [inp_size], 8
|
||||
xor eax, eax
|
||||
mov [output], eax
|
||||
mov [out_size], eax
|
||||
lea eax, [handler]
|
||||
push esi edi
|
||||
invoke ServiceHandler, eax
|
||||
pop edi esi
|
||||
ret
|
||||
endp
|
||||
|
||||
proc serial_remove_port stdcall, port:dword
|
||||
locals
|
||||
handler dd ?
|
||||
io_code dd ?
|
||||
input dd ?
|
||||
inp_size dd ?
|
||||
output dd ?
|
||||
out_size dd ?
|
||||
endl
|
||||
mov eax, [serial_drv_entry]
|
||||
mov [handler], eax
|
||||
mov [io_code], SERIAL_API_SRV_REMOVE_PORT
|
||||
lea eax, [port]
|
||||
mov [input], eax
|
||||
mov [inp_size], 4
|
||||
xor eax, eax
|
||||
mov [output], eax
|
||||
mov [out_size], eax
|
||||
lea eax, [handler]
|
||||
push esi edi
|
||||
invoke ServiceHandler, eax
|
||||
pop edi esi
|
||||
ret
|
||||
endp
|
||||
|
||||
; see SERIAL_EVT_*
|
||||
proc serial_handle_event stdcall, port:dword, event:dword, count:dword, buff:dword
|
||||
locals
|
||||
handler dd ?
|
||||
io_code dd ?
|
||||
input dd ?
|
||||
inp_size dd ?
|
||||
output dd ?
|
||||
out_size dd ?
|
||||
endl
|
||||
mov eax, [serial_drv_entry]
|
||||
mov [handler], eax
|
||||
mov [io_code], SERIAL_API_SRV_HANDLE_EVENT
|
||||
lea eax, [port]
|
||||
mov [input], eax
|
||||
mov [inp_size], 16
|
||||
xor eax, eax
|
||||
mov [output], eax
|
||||
mov [out_size], eax
|
||||
lea eax, [handler]
|
||||
push esi edi
|
||||
invoke ServiceHandler, eax
|
||||
pop edi esi
|
||||
ret
|
||||
endp
|
||||
|
||||
proc serial_port_init
|
||||
lea ecx, [serial_drv_name]
|
||||
mcall SF_SYS_MISC, SSF_LOAD_DRIVER
|
||||
mov [serial_drv_handle], eax
|
||||
ret
|
||||
endp
|
||||
|
||||
proc serial_port_open stdcall uses ebx, port_id:dword, conf:dword, handle:dword
|
||||
locals
|
||||
.handler dd ?
|
||||
.io_code dd ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
endl
|
||||
push [conf]
|
||||
push [port_id]
|
||||
mov eax, [serial_drv_handle]
|
||||
mov [.handler], eax
|
||||
mov dword [.io_code], SERIAL_API_OPEN_PORT
|
||||
mov [.input], esp
|
||||
mov dword [.inp_size], 8
|
||||
mov eax, [handle]
|
||||
mov [.output], eax
|
||||
mov dword [.out_size], 4
|
||||
|
||||
lea ecx, [.handler]
|
||||
mcall SF_SYS_MISC, SSF_CONTROL_DRIVER
|
||||
|
||||
add esp, 8
|
||||
ret
|
||||
endp
|
||||
|
||||
proc serial_port_close stdcall uses ebx, handle:dword
|
||||
locals
|
||||
.handler dd ?
|
||||
.io_code dd ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
endl
|
||||
push [handle]
|
||||
mov eax, [serial_drv_handle]
|
||||
mov [.handler], eax
|
||||
mov dword [.io_code], SERIAL_API_CLOSE_PORT
|
||||
mov [.input], esp
|
||||
mov dword [.inp_size], 4
|
||||
mov dword [.output], 0
|
||||
mov dword [.out_size], 0
|
||||
|
||||
lea ecx, [.handler]
|
||||
mcall SF_SYS_MISC, SSF_CONTROL_DRIVER
|
||||
|
||||
add esp, 4
|
||||
ret
|
||||
endp
|
||||
|
||||
proc serial_port_setup stdcall uses ebx, handle:dword, conf:dword
|
||||
locals
|
||||
.handler dd ?
|
||||
.io_code dd ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
endl
|
||||
push [conf]
|
||||
push [handle]
|
||||
mov eax, [serial_drv_handle]
|
||||
mov [.handler], eax
|
||||
mov dword [.io_code], SERIAL_API_SETUP_PORT
|
||||
mov [.input], esp
|
||||
mov dword [.inp_size], 8
|
||||
sub esp, 4
|
||||
mov [.output], esp
|
||||
mov dword [.out_size], 4
|
||||
|
||||
lea ecx, [.handler]
|
||||
mcall SF_SYS_MISC, SSF_CONTROL_DRIVER
|
||||
|
||||
pop eax
|
||||
add esp, 8
|
||||
ret
|
||||
endp
|
||||
|
||||
proc serial_port_read stdcall uses ebx, handle:dword, dest:dword, count_ptr:dword
|
||||
locals
|
||||
.handler dd ?
|
||||
.io_code dd ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
endl
|
||||
mov eax, [count_ptr]
|
||||
push dword [eax]
|
||||
push [dest]
|
||||
push [handle]
|
||||
mov eax, [serial_drv_handle]
|
||||
mov [.handler], eax
|
||||
mov dword [.io_code], SERIAL_API_READ
|
||||
mov [.input], esp
|
||||
mov dword [.inp_size], 12
|
||||
sub esp, 4
|
||||
mov [.output], esp
|
||||
mov [.out_size], 4
|
||||
|
||||
lea ecx, [.handler]
|
||||
mcall SF_SYS_MISC, SSF_CONTROL_DRIVER
|
||||
|
||||
pop ecx
|
||||
mov edx, [count_ptr]
|
||||
mov [edx], ecx
|
||||
add esp, 12
|
||||
ret
|
||||
endp
|
||||
|
||||
proc serial_port_write stdcall uses ebx, handle:dword, src:dword, count_ptr:dword
|
||||
locals
|
||||
.handler dd ?
|
||||
.io_code dd ?
|
||||
.input dd ?
|
||||
.inp_size dd ?
|
||||
.output dd ?
|
||||
.out_size dd ?
|
||||
endl
|
||||
mov eax, [count_ptr]
|
||||
push dword [eax]
|
||||
push [src]
|
||||
push [handle]
|
||||
mov eax, [serial_drv_handle]
|
||||
mov [.handler], eax
|
||||
mov dword [.io_code], SERIAL_API_WRITE
|
||||
mov [.input], esp
|
||||
mov dword [.inp_size], 12
|
||||
sub esp, 4
|
||||
mov dword [.output], esp
|
||||
mov dword [.out_size], 4
|
||||
|
||||
lea ecx, [.handler]
|
||||
mcall SF_SYS_MISC, SSF_CONTROL_DRIVER
|
||||
|
||||
pop ecx
|
||||
mov edx, [count_ptr]
|
||||
mov [edx], ecx
|
||||
add esp, 12
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
serial_drv_name db "SERIAL", 0
|
||||
serial_drv_handle dd ?
|
178
drivers/serial/ring_buf.inc
Executable file
@ -0,0 +1,178 @@
|
||||
struct RING_BUF
|
||||
start_ptr dd ? ; Pointer to start of buffer
|
||||
end_ptr dd ? ; Pointer to end of buffer
|
||||
read_ptr dd ? ; Read pointer
|
||||
write_ptr dd ? ; Write pointer
|
||||
size dd ? ; Size of buffer
|
||||
ends
|
||||
|
||||
;bool __fastcall ring_buf_create(struct RING_BUF *buf, u32 size)
|
||||
align 4
|
||||
proc ring_buf_create
|
||||
push ecx
|
||||
push edx
|
||||
invoke CreateRingBuffer, edx, PG_SW
|
||||
pop edx
|
||||
pop ecx
|
||||
test eax, eax
|
||||
jz .exit
|
||||
|
||||
mov [ecx + RING_BUF.start_ptr], eax
|
||||
mov [ecx + RING_BUF.write_ptr], eax
|
||||
mov [ecx + RING_BUF.read_ptr], eax
|
||||
add eax, edx
|
||||
mov [ecx + RING_BUF.end_ptr], eax
|
||||
mov [ecx + RING_BUF.size], edx
|
||||
or eax, 1
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
;void __fastcall ring_buf_destroy(struct RING_BUF *buf)
|
||||
align 4
|
||||
proc ring_buf_destroy
|
||||
xor eax, eax
|
||||
mov [ecx + RING_BUF.write_ptr], eax
|
||||
mov [ecx + RING_BUF.read_ptr], eax
|
||||
mov [ecx + RING_BUF.end_ptr], eax
|
||||
mov [ecx + RING_BUF.size], eax
|
||||
xchg eax, [ecx + RING_BUF.start_ptr]
|
||||
invoke KernelFree, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;u32 __fastcall ring_buf_count(struct RING_BUF *buf)
|
||||
align 4
|
||||
proc ring_buf_count
|
||||
mov eax, [ecx + RING_BUF.write_ptr]
|
||||
mov edx, [ecx + RING_BUF.read_ptr]
|
||||
cmp eax, edx
|
||||
jb @f
|
||||
sub eax, edx
|
||||
ret
|
||||
|
||||
@@:
|
||||
sub eax, edx
|
||||
add eax, [ecx + RING_BUF.size]
|
||||
ret
|
||||
endp
|
||||
|
||||
;u32 __fastcall ring_buf_free(struct RING_BUF *buf)
|
||||
align 4
|
||||
proc ring_buf_free
|
||||
mov eax, [ecx + RING_BUF.read_ptr]
|
||||
mov edx, [ecx + RING_BUF.write_ptr]
|
||||
cmp eax, edx
|
||||
jae @f
|
||||
sub eax, edx
|
||||
dec eax
|
||||
ret
|
||||
|
||||
@@:
|
||||
sub eax, edx
|
||||
dec eax
|
||||
add eax, [ecx + RING_BUF.size]
|
||||
ret
|
||||
endp
|
||||
|
||||
;u32 __stdcall ring_buf_write(struct RING_BUF *buf, const u32 *src, u32 size)
|
||||
align 4
|
||||
proc ring_buf_write stdcall uses esi edi, buf, src, size
|
||||
mov ecx, [buf]
|
||||
call ring_buf_free
|
||||
test eax, eax
|
||||
jz .exit
|
||||
|
||||
mov esi, [src]
|
||||
mov edi, [ecx + RING_BUF.write_ptr]
|
||||
mov ecx, [size]
|
||||
cmp ecx, eax
|
||||
jbe .copy
|
||||
mov ecx, eax
|
||||
.copy:
|
||||
mov eax, ecx
|
||||
cld
|
||||
shr ecx, 1
|
||||
jnc .nb
|
||||
movsb
|
||||
.nb:
|
||||
shr ecx, 1
|
||||
jnc .nw
|
||||
movsw
|
||||
.nw:
|
||||
test ecx, ecx
|
||||
jz .nd
|
||||
rep movsd
|
||||
.nd:
|
||||
mov ecx, [buf]
|
||||
cmp edi, [ecx + RING_BUF.end_ptr]
|
||||
jb @f
|
||||
sub edi, [ecx + RING_BUF.size]
|
||||
@@:
|
||||
mov [ecx + RING_BUF.write_ptr], edi
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
;u32 __stdcall ring_buf_read(struct RING_BUF *buf, u32 *dst, u32 size)
|
||||
align 4
|
||||
proc ring_buf_read stdcall uses ebx esi edi, buf, dst, size
|
||||
mov ecx, [buf]
|
||||
call ring_buf_count
|
||||
test eax, eax
|
||||
jz .exit
|
||||
|
||||
mov esi, [ecx + RING_BUF.read_ptr]
|
||||
mov edi, [dst]
|
||||
mov ecx, [size]
|
||||
cmp ecx, eax
|
||||
jbe .copy
|
||||
mov ecx, eax
|
||||
.copy:
|
||||
mov eax, ecx
|
||||
shr ecx, 1
|
||||
jnc .nb
|
||||
cld
|
||||
movsb
|
||||
.nb:
|
||||
shr ecx, 1
|
||||
jnc .nw
|
||||
movsw
|
||||
.nw:
|
||||
test ecx, ecx
|
||||
jz .nd
|
||||
rep movsd
|
||||
.nd:
|
||||
mov ecx, [buf]
|
||||
cmp esi, [ecx + RING_BUF.end_ptr]
|
||||
jb .save_ptr
|
||||
sub esi, [ecx + RING_BUF.size]
|
||||
.save_ptr:
|
||||
mov [ecx + RING_BUF.read_ptr], esi
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
;u32 __fastcall ring_buf_discard(struct RING_BUF *buf, u32 size)
|
||||
align 4
|
||||
proc ring_buf_discard
|
||||
push ecx
|
||||
push edx
|
||||
call ring_buf_count
|
||||
pop edx
|
||||
pop ecx
|
||||
|
||||
cmp eax, edx
|
||||
jae .discard
|
||||
mov edx, eax
|
||||
.discard:
|
||||
push edx
|
||||
add edx, [ecx + RING_BUF.read_ptr]
|
||||
cmp edx, [ecx + RING_BUF.end_ptr]
|
||||
jb .save_ptr
|
||||
sub edx, [ecx + RING_BUF.size]
|
||||
.save_ptr:
|
||||
mov [ecx + RING_BUF.read_ptr], edx
|
||||
pop eax
|
||||
ret
|
||||
endp
|
675
drivers/serial/serial.asm
Executable file
@ -0,0 +1,675 @@
|
||||
format PE DLL native 0.05
|
||||
entry START
|
||||
|
||||
L_DBG = 1
|
||||
L_ERR = 2
|
||||
|
||||
__DEBUG__ = 0
|
||||
__DEBUG_LEVEL__ = L_DBG
|
||||
|
||||
SERIAL_RING_BUF_SIZE = 32768
|
||||
|
||||
API_VERSION = 1
|
||||
|
||||
section '.flat' readable writable executable
|
||||
|
||||
include '../struct.inc'
|
||||
include '../proc32.inc'
|
||||
include '../fdo.inc'
|
||||
include '../macros.inc'
|
||||
include '../peimport.inc'
|
||||
|
||||
include 'common.inc'
|
||||
include 'ring_buf.inc'
|
||||
include 'uart16550.inc'
|
||||
|
||||
struct SERIAL_OBJ
|
||||
magic dd ?
|
||||
destroy dd ?
|
||||
fd dd ?
|
||||
bk dd ?
|
||||
pid dd ?
|
||||
port dd ? ; pointer to SERIAL_PORT
|
||||
ends
|
||||
|
||||
struct SERIAL_PORT
|
||||
fd dd ?
|
||||
bk dd ?
|
||||
id dd ? ; unique port number
|
||||
mtx MUTEX
|
||||
con dd ? ; pointer to SERIAL_OBJ
|
||||
drv dd ? ; pointer to struct SP_DRIVER
|
||||
drv_data dd ? ; pointer to driver-defined data
|
||||
rx_buf RING_BUF
|
||||
tx_buf RING_BUF
|
||||
conf SP_CONF
|
||||
ends
|
||||
|
||||
proc START c, reason:dword
|
||||
cmp [reason], DRV_ENTRY
|
||||
jne .fail
|
||||
|
||||
mov ecx, port_list_mutex
|
||||
invoke MutexInit
|
||||
|
||||
stdcall uart_probe, 0x3f8, 4
|
||||
stdcall uart_probe, 0x2f8, 3
|
||||
stdcall uart_probe, 0x3e8, 4
|
||||
stdcall uart_probe, 0x2e8, 3
|
||||
invoke RegService, drv_name, service_proc
|
||||
ret
|
||||
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
srv_calls:
|
||||
dd service_proc.get_version
|
||||
dd service_proc.drv_add_port
|
||||
dd service_proc.drv_remove_port
|
||||
dd service_proc.drv_handle_event
|
||||
dd service_proc.open
|
||||
dd service_proc.close
|
||||
dd service_proc.setup
|
||||
dd service_proc.read
|
||||
dd service_proc.write
|
||||
; TODO enumeration
|
||||
srv_calls_end:
|
||||
|
||||
proc service_proc stdcall uses ebx esi edi, ioctl:dword
|
||||
mov edx, [ioctl]
|
||||
mov eax, [edx + IOCTL.io_code]
|
||||
cmp eax, (srv_calls_end - srv_calls) / 4
|
||||
jae .err
|
||||
jmp dword [srv_calls + eax * 4]
|
||||
|
||||
.get_version:
|
||||
cmp [edx + IOCTL.out_size], 4
|
||||
jb .err
|
||||
mov edx, [edx + IOCTL.output]
|
||||
mov dword [edx], API_VERSION
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.drv_add_port:
|
||||
; in:
|
||||
; +0: driver
|
||||
; +4: driver data
|
||||
cmp [edx + IOCTL.inp_size], 8
|
||||
jb .err
|
||||
mov ebx, [edx + IOCTL.input]
|
||||
mov ecx, [ebx]
|
||||
mov edx, [ebx + 4]
|
||||
call add_port
|
||||
ret
|
||||
|
||||
.drv_remove_port:
|
||||
; in:
|
||||
; +0: port handle
|
||||
cmp [edx + IOCTL.inp_size], 4
|
||||
jb .err
|
||||
mov ebx, [edx + IOCTL.input]
|
||||
mov ecx, [ebx]
|
||||
call remove_port
|
||||
ret
|
||||
|
||||
.drv_handle_event:
|
||||
; in:
|
||||
; +0: port handle
|
||||
; +4: event
|
||||
; +8: count
|
||||
; +12: buf
|
||||
cmp [edx + IOCTL.inp_size], 16
|
||||
jb .err
|
||||
mov ebx, [edx + IOCTL.input]
|
||||
mov eax, [ebx]
|
||||
mov edx, [ebx + 4]
|
||||
mov ecx, [ebx + 8]
|
||||
mov esi, [ebx + 12]
|
||||
call handle_event
|
||||
ret
|
||||
|
||||
.open:
|
||||
; in:
|
||||
; +0 port number
|
||||
; +4 addr to SERIAL_CONF
|
||||
; out:
|
||||
; +0 port handle if success
|
||||
cmp [edx + IOCTL.inp_size], 8
|
||||
jb .err
|
||||
cmp [edx + IOCTL.out_size], 4
|
||||
jb .err
|
||||
mov ebx, [edx + IOCTL.input]
|
||||
mov ecx, [edx + IOCTL.output]
|
||||
stdcall sp_open, [ebx], [ebx + 4], ecx
|
||||
ret
|
||||
|
||||
.close:
|
||||
; in:
|
||||
; +0 port handle
|
||||
cmp [edx + IOCTL.inp_size], 4
|
||||
jb .err
|
||||
mov ecx, [edx + IOCTL.input]
|
||||
mov ecx, [ecx]
|
||||
call sp_close
|
||||
ret
|
||||
|
||||
.setup:
|
||||
; in:
|
||||
; +0 port handle
|
||||
; +4 addr to SERIAL_CONF
|
||||
; out:
|
||||
; +0 result
|
||||
cmp [edx + IOCTL.inp_size], 8
|
||||
jb .err
|
||||
cmp [edx + IOCTL.out_size], 4
|
||||
jb .err
|
||||
mov ebx, [edx + IOCTL.input]
|
||||
push edx
|
||||
mov eax, [ebx]
|
||||
mov esi, [ebx + 4]
|
||||
call sp_setup
|
||||
pop edx
|
||||
mov ebx, [edx + IOCTL.output]
|
||||
mov [ebx], eax
|
||||
ret
|
||||
|
||||
.read:
|
||||
; in:
|
||||
; +0 port handle
|
||||
; +4 addr of dest buf
|
||||
; +8 count to read
|
||||
; out:
|
||||
; +0 bytes read
|
||||
cmp [edx + IOCTL.inp_size], 12
|
||||
jb .err
|
||||
cmp [edx + IOCTL.out_size], 4
|
||||
jb .err
|
||||
mov ebx, [edx + IOCTL.input]
|
||||
push edx
|
||||
mov eax, [ebx]
|
||||
mov edi, [ebx + 4]
|
||||
mov ecx, [ebx + 8]
|
||||
call sp_read
|
||||
pop edx
|
||||
mov ebx, [edx + IOCTL.output]
|
||||
mov [ebx], ecx
|
||||
ret
|
||||
|
||||
.write:
|
||||
; in:
|
||||
; +0 port handle
|
||||
; +4 addr to source buf
|
||||
; +8 count to write
|
||||
; out:
|
||||
; +0 bytes written
|
||||
cmp [edx + IOCTL.inp_size], 12
|
||||
jb .err
|
||||
cmp [edx + IOCTL.out_size], 4
|
||||
jb .err
|
||||
mov ebx, [edx + IOCTL.input]
|
||||
push edx
|
||||
mov eax, [ebx]
|
||||
mov esi, [ebx + 4]
|
||||
mov ecx, [ebx + 8]
|
||||
call sp_write
|
||||
pop edx
|
||||
mov ebx, [edx + IOCTL.output]
|
||||
mov [ebx], ecx
|
||||
ret
|
||||
|
||||
.err:
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
; struct SERIAL_PORT __fastcall *add_port(const struct SP_DRIVER *drv, const void *drv_data);
|
||||
align 4
|
||||
proc add_port uses edi
|
||||
DEBUGF L_DBG, "serial.sys: add port drv=%x drv_data=%x\n", ecx, edx
|
||||
|
||||
mov eax, [ecx + SP_DRIVER.size]
|
||||
cmp eax, sizeof.SP_DRIVER
|
||||
jne .fail
|
||||
|
||||
; alloc memory for serial port descriptor
|
||||
push ecx
|
||||
push edx
|
||||
movi eax, sizeof.SERIAL_PORT
|
||||
invoke Kmalloc
|
||||
pop edx
|
||||
pop ecx
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
; initialize fields of descriptor
|
||||
mov edi, eax
|
||||
mov [edi + SERIAL_PORT.drv], ecx
|
||||
mov [edi + SERIAL_PORT.drv_data], edx
|
||||
lea ecx, [edi + SERIAL_PORT.mtx]
|
||||
invoke MutexInit
|
||||
and [edi + SERIAL_PORT.con], 0
|
||||
|
||||
mov ecx, port_list_mutex
|
||||
invoke MutexLock
|
||||
|
||||
; TODO obtain unused id's
|
||||
mov eax, [port_count]
|
||||
mov [edi + SERIAL_PORT.id], eax
|
||||
inc [port_count]
|
||||
|
||||
; add port to linked list
|
||||
mov eax, port_list
|
||||
mov ecx, [eax + SERIAL_PORT.bk]
|
||||
mov [edi + SERIAL_PORT.bk], ecx
|
||||
mov [edi + SERIAL_PORT.fd], eax
|
||||
mov [ecx + SERIAL_PORT.fd], edi
|
||||
mov [eax + SERIAL_PORT.bk], edi
|
||||
|
||||
DEBUGF L_DBG, "serial.sys: add port %x with id %x\n", edi, [edi + SERIAL_PORT.id]
|
||||
|
||||
mov ecx, port_list_mutex
|
||||
invoke MutexUnlock
|
||||
|
||||
mov eax, edi
|
||||
ret
|
||||
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
; u32 __fastcall *remove_port(struct SERIAL_PORT *port);
|
||||
proc remove_port uses esi
|
||||
mov esi, ecx
|
||||
mov ecx, port_list_mutex
|
||||
invoke MutexLock
|
||||
|
||||
lea ecx, [esi + SERIAL_PORT.mtx]
|
||||
invoke MutexLock
|
||||
|
||||
mov eax, [esi + SERIAL_PORT.con]
|
||||
test eax, eax
|
||||
jz @f
|
||||
push esi
|
||||
call sp_destroy
|
||||
pop esi
|
||||
@@:
|
||||
|
||||
mov eax, [esi + SERIAL_PORT.fd]
|
||||
mov edx, [esi + SERIAL_PORT.bk]
|
||||
mov [edx + SERIAL_PORT.fd], eax
|
||||
mov [eax + SERIAL_PORT.bk], edx
|
||||
DEBUGF L_DBG, "serial.sys: remove port %x with id %x\n", esi, [esi + SERIAL_PORT.id]
|
||||
mov eax, esi
|
||||
invoke Kfree
|
||||
|
||||
mov ecx, port_list_mutex
|
||||
invoke MutexUnlock
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
; @param eax port
|
||||
; @param edx event
|
||||
; @param ecx count
|
||||
; @param esi buffer
|
||||
; @return eax count
|
||||
proc handle_event uses edi
|
||||
mov edi, eax
|
||||
cmp edx, SERIAL_EVT_RXNE
|
||||
jz .rx
|
||||
cmp edx, SERIAL_EVT_TXE
|
||||
jz .tx
|
||||
xor eax, eax
|
||||
jmp .exit
|
||||
.rx:
|
||||
lea eax, [edi + SERIAL_PORT.rx_buf]
|
||||
stdcall ring_buf_write, eax, esi, ecx
|
||||
jmp .exit
|
||||
.tx:
|
||||
lea eax, [edi + SERIAL_PORT.tx_buf]
|
||||
stdcall ring_buf_read, eax, esi, ecx
|
||||
; fallthrough
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc sp_validate_conf
|
||||
mov eax, [ecx + SP_CONF.size]
|
||||
cmp eax, sizeof.SP_CONF
|
||||
jnz .fail
|
||||
mov eax, [ecx + SP_CONF.baudrate]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
mov al, [ecx + SP_CONF.word_size]
|
||||
cmp al, 8
|
||||
jne .fail ; TODO implement different word size
|
||||
mov al, [ecx + SP_CONF.stop_bits]
|
||||
cmp al, 1
|
||||
jne .fail ; TODO implement different stop bits count
|
||||
mov al, [ecx + SP_CONF.parity]
|
||||
cmp al, SERIAL_CONF_PARITY_NONE
|
||||
jne .fail ; TODO implement parity
|
||||
mov al, [ecx + SP_CONF.flow_ctrl]
|
||||
cmp al, SERIAL_CONF_FLOW_CTRL_NONE
|
||||
jne .fail ; TODO implement flow control
|
||||
.ok:
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc sp_open stdcall uses ebx esi edi, port_id:dword, conf:dword, handle:dword
|
||||
DEBUGF L_DBG, "serial.sys: sp_open %x %x %x\n", [port_id], [conf], [handle]
|
||||
|
||||
mov ecx, [conf]
|
||||
call sp_validate_conf
|
||||
test eax, eax
|
||||
jz @f
|
||||
mov eax, SERIAL_API_ERR_CONF
|
||||
ret
|
||||
@@:
|
||||
mov edi, [conf]
|
||||
|
||||
; get access to the serial ports list
|
||||
mov ecx, port_list_mutex
|
||||
invoke MutexLock
|
||||
|
||||
; find port by id
|
||||
mov eax, [port_id]
|
||||
mov esi, port_list
|
||||
.find_port:
|
||||
mov esi, [esi + SERIAL_PORT.fd]
|
||||
cmp esi, port_list
|
||||
jz .not_found
|
||||
mov ecx, [esi + SERIAL_PORT.id]
|
||||
cmp ecx, eax
|
||||
jz .found
|
||||
jmp .find_port
|
||||
|
||||
.not_found:
|
||||
DEBUGF L_DBG, "serial.sys: port not found\n"
|
||||
mov eax, SERIAL_API_ERR_PORT_INVALID
|
||||
jmp .unlock_list
|
||||
|
||||
.found:
|
||||
DEBUGF L_DBG, "serial.sys: found port %x\n", esi
|
||||
|
||||
; get access to serial port
|
||||
lea ecx, [esi + SERIAL_PORT.mtx]
|
||||
invoke MutexLock
|
||||
|
||||
; availability check
|
||||
cmp [esi + SERIAL_PORT.con], 0
|
||||
jz .open
|
||||
mov eax, SERIAL_API_ERR_PORT_BUSY
|
||||
jmp .unlock_port
|
||||
|
||||
.open:
|
||||
; create rx and tx ring buffers
|
||||
lea ecx, [esi + SERIAL_PORT.rx_buf]
|
||||
mov edx, SERIAL_RING_BUF_SIZE
|
||||
call ring_buf_create
|
||||
test eax, eax
|
||||
jnz @f
|
||||
jmp .unlock_port
|
||||
@@:
|
||||
lea ecx, [esi + SERIAL_PORT.tx_buf]
|
||||
mov edx, SERIAL_RING_BUF_SIZE
|
||||
call ring_buf_create
|
||||
test eax, eax
|
||||
jnz @f
|
||||
jmp .free_rx_buf
|
||||
@@:
|
||||
invoke GetPid
|
||||
mov ebx, eax
|
||||
mov eax, sizeof.SERIAL_OBJ
|
||||
invoke CreateObject
|
||||
test eax, eax
|
||||
jnz @f
|
||||
or eax, -1
|
||||
jmp .free_tx_buf
|
||||
@@:
|
||||
DEBUGF L_DBG, "serial.sys: created object %x\n", eax
|
||||
|
||||
; save port handle
|
||||
mov ecx, [handle]
|
||||
mov [ecx], eax
|
||||
mov [eax + SERIAL_OBJ.magic], 'UART'
|
||||
mov [eax + SERIAL_OBJ.destroy], sp_destroy
|
||||
mov [eax + SERIAL_OBJ.port], esi
|
||||
|
||||
; fill fields
|
||||
mov [esi + SERIAL_PORT.con], eax
|
||||
; copy conf
|
||||
mov eax, [edi + SP_CONF.size]
|
||||
mov [esi + SERIAL_PORT.conf + SP_CONF.size], eax
|
||||
mov eax, [edi + SP_CONF.baudrate]
|
||||
mov [esi + SERIAL_PORT.conf + SP_CONF.baudrate], eax
|
||||
mov eax, dword [edi + SP_CONF.word_size]
|
||||
mov dword [esi + SERIAL_PORT.conf + SP_CONF.word_size], eax
|
||||
|
||||
; tell driver about port open
|
||||
mov ebx, [esi + SERIAL_PORT.drv]
|
||||
mov ecx, [esi + SERIAL_PORT.drv_data]
|
||||
stdcall dword [ebx + SP_DRIVER.startup], ecx, edi
|
||||
test eax, eax
|
||||
jz .unlock_port
|
||||
; on error fallthrough
|
||||
push eax
|
||||
mov eax, [esi + SERIAL_PORT.con]
|
||||
invoke DestroyObject
|
||||
and [esi + SERIAL_PORT.con], 0
|
||||
pop eax
|
||||
|
||||
.free_tx_buf:
|
||||
push eax
|
||||
lea ecx, [esi + SERIAL_PORT.tx_buf]
|
||||
call ring_buf_destroy
|
||||
pop eax
|
||||
|
||||
.free_rx_buf:
|
||||
push eax
|
||||
lea ecx, [esi + SERIAL_PORT.rx_buf]
|
||||
call ring_buf_destroy
|
||||
pop eax
|
||||
|
||||
.unlock_port:
|
||||
push eax
|
||||
lea ecx, [esi + SERIAL_PORT.mtx]
|
||||
invoke MutexUnlock
|
||||
pop eax
|
||||
|
||||
.unlock_list:
|
||||
push eax
|
||||
mov ecx, port_list_mutex
|
||||
invoke MutexUnlock
|
||||
pop eax
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
; @param ecx serial port handle
|
||||
proc sp_close uses ebx esi
|
||||
mov eax, ecx
|
||||
cmp [eax + SERIAL_OBJ.magic], 'UART'
|
||||
je .ok
|
||||
or eax, -1
|
||||
ret
|
||||
.ok:
|
||||
mov ebx, [eax + SERIAL_OBJ.port]
|
||||
push eax
|
||||
lea ecx, [ebx + SERIAL_PORT.mtx]
|
||||
invoke MutexLock
|
||||
pop eax
|
||||
|
||||
push ebx
|
||||
call sp_destroy
|
||||
pop ebx
|
||||
|
||||
lea ecx, [ebx + SERIAL_PORT.mtx]
|
||||
invoke MutexUnlock
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
; @param eax port handle
|
||||
; @param esi pointer to SP_CONF
|
||||
; @return eax = 0 on success
|
||||
proc sp_setup
|
||||
test esi, esi
|
||||
jz .fail
|
||||
cmp [eax + SERIAL_OBJ.magic], 'UART'
|
||||
jne .fail
|
||||
mov ebx, eax
|
||||
mov ecx, esi
|
||||
call sp_validate_conf
|
||||
test eax, eax
|
||||
jz @f
|
||||
DEBUGF L_DBG, "serial.sys: invalid conf %x\n", ecx
|
||||
mov eax, SERIAL_API_ERR_CONF
|
||||
ret
|
||||
@@:
|
||||
; lock mutex
|
||||
mov edi, [ebx + SERIAL_OBJ.port]
|
||||
lea ecx, [edi + SERIAL_PORT.mtx]
|
||||
invoke MutexLock
|
||||
; reconfigure port
|
||||
mov eax, [edi + SERIAL_PORT.drv]
|
||||
mov ecx, [edi + SERIAL_PORT.drv_data]
|
||||
stdcall dword [eax + SP_DRIVER.reconf], ecx, esi
|
||||
xor eax, eax
|
||||
push eax
|
||||
test eax, eax
|
||||
jnz @f
|
||||
; copy conf if success
|
||||
mov eax, [esi + SP_CONF.size]
|
||||
mov [edi + SERIAL_PORT.conf + SP_CONF.size], eax
|
||||
mov eax, [esi + SP_CONF.baudrate]
|
||||
mov [edi + SERIAL_PORT.conf + SP_CONF.baudrate], eax
|
||||
mov eax, dword [esi + SP_CONF.word_size]
|
||||
mov dword [edi + SERIAL_PORT.conf + SP_CONF.word_size], eax
|
||||
@@:
|
||||
; unlock mutex
|
||||
lea ecx, [edi + SERIAL_PORT.mtx]
|
||||
invoke MutexUnlock
|
||||
pop eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
; @param eax serial obj
|
||||
proc sp_destroy
|
||||
mov esi, [eax + SERIAL_OBJ.port]
|
||||
DEBUGF L_DBG, "serial.sys: destroy port %x\n", esi
|
||||
|
||||
invoke DestroyObject
|
||||
and [esi + SERIAL_PORT.con], 0
|
||||
|
||||
; tell driver about port close
|
||||
mov ebx, [esi + SERIAL_PORT.drv]
|
||||
mov edx, [esi + SERIAL_PORT.drv_data]
|
||||
stdcall dword [ebx + SP_DRIVER.shutdown], edx
|
||||
|
||||
lea ecx, [esi + SERIAL_PORT.tx_buf]
|
||||
call ring_buf_destroy
|
||||
lea ecx, [esi + SERIAL_PORT.rx_buf]
|
||||
call ring_buf_destroy
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
align 4
|
||||
; @param eax port handle
|
||||
; @param ecx bytes count
|
||||
; @param edi address of destination buffer
|
||||
; @return eax = 0 on success and ecx = count bytes read
|
||||
proc sp_read
|
||||
test edi, edi
|
||||
jz .fail
|
||||
test ecx, ecx
|
||||
jz .fail
|
||||
cmp [eax + SERIAL_OBJ.magic], 'UART'
|
||||
jne .fail
|
||||
mov esi, [eax + SERIAL_OBJ.port]
|
||||
push ecx ; last arg for ring_buf_read
|
||||
lea ecx, [esi + SERIAL_PORT.mtx]
|
||||
invoke MutexLock
|
||||
lea eax, [esi + SERIAL_PORT.rx_buf]
|
||||
stdcall ring_buf_read, eax, edi
|
||||
push eax
|
||||
lea ecx, [esi + SERIAL_PORT.mtx]
|
||||
invoke MutexUnlock
|
||||
pop ecx
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
; @param eax port handle
|
||||
; @param ecx bytes count
|
||||
; @param esi address of source buffer
|
||||
; @return eax = 0 on success and ecx = count bytes written
|
||||
proc sp_write
|
||||
test esi, esi
|
||||
jz .fail
|
||||
test ecx, ecx
|
||||
jz .fail
|
||||
cmp [eax + SERIAL_OBJ.magic], 'UART'
|
||||
jne .fail
|
||||
|
||||
push ecx ; last arg for ring_buf_write
|
||||
mov edi, [eax + SERIAL_OBJ.port]
|
||||
lea ecx, [edi + SERIAL_PORT.mtx]
|
||||
invoke MutexLock
|
||||
|
||||
lea ecx, [edi + SERIAL_PORT.tx_buf]
|
||||
stdcall ring_buf_write, ecx, esi
|
||||
push eax
|
||||
test eax, eax
|
||||
jz @f
|
||||
mov ebx, [edi + SERIAL_PORT.drv]
|
||||
mov edx, [edi + SERIAL_PORT.drv_data]
|
||||
stdcall dword [ebx + SP_DRIVER.tx], edx
|
||||
@@:
|
||||
lea ecx, [edi + SERIAL_PORT.mtx]
|
||||
invoke MutexUnlock
|
||||
pop ecx
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
drv_name db 'SERIAL', 0
|
||||
include_debug_strings
|
||||
|
||||
align 4
|
||||
port_count dd 0
|
||||
port_list_mutex MUTEX
|
||||
port_list:
|
||||
.fd dd port_list
|
||||
.bk dd port_list
|
||||
|
||||
align 4
|
||||
data fixups
|
||||
end data
|
408
drivers/serial/uart16550.inc
Executable file
@ -0,0 +1,408 @@
|
||||
BASE_FREQ = 1843200
|
||||
BASE_DIV = 16
|
||||
|
||||
THR_REG = 0 ; transtitter/reciever
|
||||
IER_REG = 1 ; interrupt enable
|
||||
IIR_REG = 2 ; interrupt info
|
||||
FCR_REG = 2 ; FIFO control
|
||||
LCR_REG = 3 ; line control
|
||||
MCR_REG = 4 ; modem control
|
||||
LSR_REG = 5 ; line status
|
||||
MSR_REG = 6 ; modem status
|
||||
SCR_REG = 7 ; scratch
|
||||
|
||||
DLL_REG = THR_REG ; divisor latch (LSB)
|
||||
DLM_REG = IER_REG ; divisor latch (MSB)
|
||||
|
||||
LCR_5BIT = 0x00
|
||||
LCR_6BIT = 0x01
|
||||
LCR_7BIT = 0x02
|
||||
LCR_8BIT = 0x03
|
||||
LCR_STOP_1 = 0x00
|
||||
LCR_STOP_2 = 0x04
|
||||
LCR_PARITY = 0x08
|
||||
LCR_EVEN = 0x10
|
||||
LCR_STICK = 0x20
|
||||
LCR_BREAK = 0x40
|
||||
LCR_DLAB = 0x80
|
||||
|
||||
LSR_DR = 0x01 ; data ready
|
||||
LSR_OE = 0x02 ; overrun error
|
||||
LSR_PE = 0x04 ; parity error
|
||||
LSR_FE = 0x08 ; framing error
|
||||
LSR_BI = 0x10 ; break interrupt
|
||||
LSR_THRE = 0x20 ; transmitter holding empty
|
||||
LSR_TEMT = 0x40 ; transmitter empty
|
||||
LSR_FER = 0x80 ; FIFO error
|
||||
|
||||
FCR_EFIFO = 0x01 ; enable FIFO
|
||||
FCR_CRB = 0x02 ; clear reciever FIFO
|
||||
FCR_CXMIT = 0x04 ; clear transmitter FIFO
|
||||
FCR_RDY = 0x08 ; set RXRDY and TXRDY pins
|
||||
FCR_FIFO_1 = 0x00 ; 1 byte trigger
|
||||
FCR_FIFO_4 = 0x40 ; 4 bytes trigger
|
||||
FCR_FIFO_8 = 0x80 ; 8 bytes trigger
|
||||
FCR_FIFO_14 = 0xC0 ; 14 bytes trigger
|
||||
|
||||
IIR_INTR = 0x01 ; 1= no interrupts
|
||||
IIR_IID = 0x0E ; interrupt source mask
|
||||
|
||||
IER_RDAI = 0x01 ; reciever data interrupt
|
||||
IER_THRI = 0x02 ; transmitter empty interrupt
|
||||
IER_LSI = 0x04 ; line status interrupt
|
||||
IER_MSI = 0x08 ; modem status interrupt
|
||||
|
||||
MCR_DTR = 0x01 ; 0-> DTR=1, 1-> DTR=0
|
||||
MCR_RTS = 0x02 ; 0-> RTS=1, 1-> RTS=0
|
||||
MCR_OUT1 = 0x04 ; 0-> OUT1=1, 1-> OUT1=0
|
||||
MCR_OUT2 = 0x08 ; 0-> OUT2=1, 1-> OUT2=0; enable intr
|
||||
MCR_LOOP = 0x10 ; lopback mode
|
||||
|
||||
MSR_DCTS = 0x01 ; delta clear to send
|
||||
MSR_DDSR = 0x02 ; delta data set redy
|
||||
MSR_TERI = 0x04 ; trailinh edge of ring
|
||||
MSR_DDCD = 0x08 ; delta carrier detect
|
||||
MSR_CTS = 0x10
|
||||
MSR_DSR = 0x20
|
||||
MSR_RI = 0x40
|
||||
MSR_DCD = 0x80
|
||||
|
||||
MCR_TEST_MASK = MCR_DTR or MCR_RTS or MCR_OUT1 or MCR_OUT2 or MCR_LOOP
|
||||
MSR_CHECK_MASK = MSR_CTS or MSR_DSR or MSR_RI or MSR_DCD
|
||||
|
||||
struct DRV_DATA
|
||||
io_addr dd ? ; base address of io port
|
||||
port dd ? ; serial port descriptor
|
||||
ends
|
||||
|
||||
; dx = base io
|
||||
; al = result
|
||||
macro rd_reg reg
|
||||
{
|
||||
push edx
|
||||
add dx, reg
|
||||
in al, dx
|
||||
pop edx
|
||||
}
|
||||
|
||||
; dx = base io
|
||||
; al = new value
|
||||
macro wr_reg reg
|
||||
{
|
||||
push edx
|
||||
add dx, reg
|
||||
out dx, al
|
||||
pop edx
|
||||
}
|
||||
|
||||
; dx = port
|
||||
; ax = divisor value
|
||||
proc uart_set_baud
|
||||
push eax
|
||||
rd_reg LCR_REG
|
||||
or al, LCR_DLAB
|
||||
wr_reg LCR_REG
|
||||
pop eax
|
||||
wr_reg DLL_REG
|
||||
shr ax, 8
|
||||
wr_reg DLM_REG
|
||||
rd_reg LCR_REG
|
||||
and al, 0x7f
|
||||
wr_reg LCR_REG
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_probe stdcall uses ebx esi edi, io_addr:dword, irqn:dword
|
||||
xor ebx, ebx ; 0 = reserve
|
||||
mov ecx, [io_addr]
|
||||
lea edx, [ecx + 7]
|
||||
push ebp
|
||||
invoke ReservePortArea
|
||||
pop ebp
|
||||
test eax, eax
|
||||
jnz .err
|
||||
|
||||
mov edx, [io_addr]
|
||||
|
||||
; enable loopback
|
||||
mov al, MCR_LOOP
|
||||
wr_reg MCR_REG
|
||||
|
||||
; read status
|
||||
rd_reg MSR_REG
|
||||
and al, MSR_CHECK_MASK
|
||||
test al, al
|
||||
jnz .free_port
|
||||
|
||||
; set test signals
|
||||
mov al, MCR_TEST_MASK
|
||||
wr_reg MCR_REG
|
||||
|
||||
; check signals
|
||||
rd_reg MSR_REG
|
||||
and al, MSR_CHECK_MASK
|
||||
cmp al, MSR_CHECK_MASK
|
||||
jnz .free_port
|
||||
|
||||
DEBUGF L_DBG, "uart16550: found serial port %x\n", [io_addr]
|
||||
|
||||
; initialize port
|
||||
xor ax, ax
|
||||
wr_reg MCR_REG
|
||||
wr_reg IER_REG
|
||||
wr_reg LCR_REG
|
||||
wr_reg FCR_REG
|
||||
|
||||
mov eax, sizeof.DRV_DATA
|
||||
invoke Kmalloc
|
||||
test eax, eax
|
||||
jz .free_port
|
||||
mov edi, eax
|
||||
|
||||
mov eax, [io_addr]
|
||||
mov [edi + DRV_DATA.io_addr], eax
|
||||
|
||||
invoke AttachIntHandler, [irqn], uart_int_handler, edi
|
||||
test eax, eax
|
||||
jz .free_desc
|
||||
|
||||
; register port
|
||||
lea ecx, [uart_drv]
|
||||
mov edx, edi
|
||||
call add_port
|
||||
test eax, eax
|
||||
jz .free_desc ; TODO detach_int_handler?
|
||||
|
||||
; save port handle
|
||||
mov [edi + DRV_DATA.port], eax
|
||||
ret
|
||||
|
||||
.free_desc:
|
||||
mov eax, edi
|
||||
invoke Kfree
|
||||
|
||||
.free_port:
|
||||
xor ebx, ebx
|
||||
inc ebx ; 1 = release
|
||||
mov ecx, [io_addr]
|
||||
lea edx, [ecx + 7]
|
||||
push ebp
|
||||
invoke ReservePortArea
|
||||
pop ebp
|
||||
|
||||
.err:
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_int_handler c uses ebx esi edi, data:dword
|
||||
locals
|
||||
.buf db ?
|
||||
endl
|
||||
mov edi, [data]
|
||||
mov edx, [edi + DRV_DATA.io_addr]
|
||||
xor ebx, ebx
|
||||
|
||||
.read_iir:
|
||||
rd_reg IIR_REG
|
||||
test al, IIR_INTR
|
||||
jnz .exit
|
||||
|
||||
inc ebx
|
||||
and ax, IIR_IID
|
||||
shr ax, 1
|
||||
|
||||
; check source
|
||||
test ax, ax
|
||||
jz .modem
|
||||
cmp ax, 1
|
||||
jz .xmit
|
||||
cmp ax, 2
|
||||
jz .recv
|
||||
cmp ax, 3
|
||||
jz .status
|
||||
jmp .exit
|
||||
|
||||
.modem:
|
||||
; read MSR for clear interrupt
|
||||
rd_reg MSR_REG
|
||||
jmp .read_iir
|
||||
|
||||
.xmit:
|
||||
push edx
|
||||
mov eax, [edi + DRV_DATA.port]
|
||||
mov edx, SERIAL_EVT_TXE
|
||||
mov ecx, 1
|
||||
lea esi, [.buf]
|
||||
call handle_event
|
||||
pop edx
|
||||
|
||||
test eax, eax
|
||||
jz .no_data
|
||||
|
||||
mov al, [.buf]
|
||||
wr_reg THR_REG
|
||||
jmp .read_iir
|
||||
|
||||
.no_data:
|
||||
; disable THR empty interrupt
|
||||
rd_reg IER_REG
|
||||
and ax, not IER_THRI
|
||||
wr_reg IER_REG
|
||||
jmp .read_iir
|
||||
|
||||
.recv:
|
||||
; read byte
|
||||
rd_reg THR_REG
|
||||
push edx
|
||||
mov [.buf], al
|
||||
mov eax, [edi + DRV_DATA.port]
|
||||
mov edx, SERIAL_EVT_RXNE
|
||||
mov ecx, 1
|
||||
lea esi, [.buf]
|
||||
call handle_event
|
||||
pop edx
|
||||
|
||||
; check for more recevied bytes
|
||||
rd_reg LSR_REG
|
||||
test al, LSR_DR
|
||||
jnz .recv
|
||||
jmp .read_iir
|
||||
|
||||
.status:
|
||||
rd_reg LSR_REG
|
||||
jmp .read_iir
|
||||
|
||||
.fifo:
|
||||
jmp .read_iir
|
||||
|
||||
.exit:
|
||||
xchg eax, ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_startup stdcall, data:dword, conf:dword
|
||||
DEBUGF L_DBG, "uart16550: startup %x %x\n", [data], [conf]
|
||||
; enable and reset fifo, 1 byte trigger level
|
||||
mov ecx, [data]
|
||||
mov edx, [ecx + DRV_DATA.io_addr]
|
||||
mov ax, FCR_EFIFO or FCR_CRB or FCR_CXMIT
|
||||
wr_reg FCR_REG
|
||||
; configure at startup
|
||||
stdcall uart_reconf, [data], [conf]
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_shutdown stdcall, data:dword
|
||||
DEBUGF L_DBG, "uart16550: shutdown %x\n", [data]
|
||||
; disable interrupts
|
||||
mov ecx, [data]
|
||||
mov edx, [ecx + DRV_DATA.io_addr]
|
||||
xor ax, ax
|
||||
wr_reg IER_REG
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_reconf stdcall uses ebx esi, data:dword, conf:dword
|
||||
locals
|
||||
divisor dw ?
|
||||
lcr dw ?
|
||||
endl
|
||||
; calc divisor = BASE_FREQ / BASE_DIV / baudrate
|
||||
mov esi, [conf]
|
||||
xor edx, edx
|
||||
mov eax, BASE_FREQ / BASE_DIV
|
||||
div [esi + SP_CONF.baudrate]
|
||||
test edx, edx
|
||||
jnz .fail
|
||||
test eax, eax
|
||||
jz .fail
|
||||
mov [divisor], ax
|
||||
|
||||
; calc word size
|
||||
xor eax, eax
|
||||
mov al, [esi + SP_CONF.word_size]
|
||||
cmp al, 8
|
||||
ja .fail
|
||||
sub al, 5
|
||||
jb .fail
|
||||
mov [lcr], ax
|
||||
|
||||
; calc parity
|
||||
mov al, [esi + SP_CONF.parity]
|
||||
xor bx, bx
|
||||
cmp al, SERIAL_CONF_PARITY_NONE
|
||||
je .parity_ok
|
||||
or bl, LCR_PARITY
|
||||
cmp al, SERIAL_CONF_PARITY_ODD
|
||||
je .parity_ok
|
||||
or bl, LCR_EVEN
|
||||
cmp al, SERIAL_CONF_PARITY_EVEN
|
||||
je .parity_ok
|
||||
mov bl, LCR_STICK or LCR_PARITY
|
||||
cmp al, SERIAL_CONF_PARITY_MARK
|
||||
je .parity_ok
|
||||
or bl, LCR_EVEN
|
||||
cmp al, SERIAL_CONF_PARITY_SPACE
|
||||
jne .fail
|
||||
.parity_ok:
|
||||
mov [lcr], bx
|
||||
|
||||
; calc stop bits
|
||||
mov bx, LCR_STOP_1
|
||||
mov al, [esi + SP_CONF.stop_bits]
|
||||
cmp al, 1
|
||||
je .stop_bits_ok
|
||||
or bx, LCR_STOP_2
|
||||
cmp al, 2
|
||||
jne .fail
|
||||
.stop_bits_ok:
|
||||
or [lcr], bx
|
||||
|
||||
mov esi, [data]
|
||||
mov edx, [esi + DRV_DATA.io_addr]
|
||||
|
||||
spin_lock_irqsave
|
||||
rd_reg IER_REG
|
||||
and ax, IER_RDAI or IER_LSI
|
||||
wr_reg IER_REG
|
||||
spin_unlock_irqrestore
|
||||
|
||||
mov ax, [divisor]
|
||||
call uart_set_baud
|
||||
|
||||
mov bx, [lcr]
|
||||
wr_reg LCR_REG
|
||||
|
||||
mov al, MCR_DTR or MCR_OUT1 or MCR_OUT2
|
||||
wr_reg MCR_REG
|
||||
|
||||
; enable rx interrupt
|
||||
mov al, IER_RDAI or IER_LSI
|
||||
wr_reg IER_REG
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
.fail:
|
||||
mov eax, SERIAL_API_ERR_CONF
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_tx stdcall, data:dword
|
||||
mov ecx, [data]
|
||||
mov edx, [ecx + DRV_DATA.io_addr]
|
||||
spin_lock_irqsave
|
||||
rd_reg IER_REG
|
||||
or ax, IER_THRI
|
||||
wr_reg IER_REG
|
||||
spin_unlock_irqrestore
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
uart_drv:
|
||||
dd uart_drv_end - uart_drv
|
||||
dd uart_startup
|
||||
dd uart_shutdown
|
||||
dd uart_reconf
|
||||
dd uart_tx
|
||||
uart_drv_end:
|
@ -27,6 +27,7 @@ include '../../proc32.inc'
|
||||
include '../../peimport.inc'
|
||||
include '../../fdo.inc'
|
||||
include '../../struct.inc'
|
||||
include '../../serial/common.inc'
|
||||
|
||||
; USB constants
|
||||
DEVICE_DESCR_TYPE = 1
|
||||
@ -60,6 +61,9 @@ LIBUSB_RECIPIENT_OTHER = 0x03
|
||||
LIBUSB_ENDPOINT_IN = 0x80
|
||||
LIBUSB_ENDPOINT_OUT = 0x00
|
||||
|
||||
H_CLK = 120000000
|
||||
C_CLK = 48000000
|
||||
|
||||
; FTDI Constants
|
||||
FTDI_DEVICE_OUT_REQTYPE = (LIBUSB_REQUEST_TYPE_VENDOR or LIBUSB_RECIPIENT_DEVICE or LIBUSB_ENDPOINT_OUT)
|
||||
FTDI_DEVICE_IN_REQTYPE = (LIBUSB_REQUEST_TYPE_VENDOR or LIBUSB_RECIPIENT_DEVICE or LIBUSB_ENDPOINT_IN)
|
||||
@ -119,6 +123,7 @@ TYPE_230X=7
|
||||
|
||||
;strings
|
||||
my_driver db 'usbother',0
|
||||
serial_driver db 'SERIAL',0
|
||||
nomemory_msg db 'K : no memory',13,10,0
|
||||
|
||||
; Structures
|
||||
@ -130,8 +135,8 @@ readBufChunkSize dd ?
|
||||
writeBufChunkSize dd ?
|
||||
readBufPtr dd ?
|
||||
writeBufPtr dd ?
|
||||
readBufSize dd ?
|
||||
writeBufSize dd ?
|
||||
readBufLock dd ?
|
||||
writeBufLock dd ?
|
||||
maxPacketSize dd ?
|
||||
interface dd ?
|
||||
index dd ?
|
||||
@ -140,6 +145,8 @@ outEP dd ?
|
||||
nullP dd ?
|
||||
lockPID dd ?
|
||||
next_context dd ?
|
||||
port_handle dd ?
|
||||
rx_timer dd ?
|
||||
ends
|
||||
|
||||
struct IOCTL
|
||||
@ -183,6 +190,8 @@ proc START c, .reason:DWORD, .cmdline:DWORD
|
||||
xor eax, eax ; initialize return value
|
||||
cmp [.reason], 1 ; compare the argument
|
||||
jnz .nothing
|
||||
invoke GetService, serial_driver
|
||||
mov [serial_drv_entry], eax
|
||||
invoke RegUSBDriver, my_driver, service_proc, usb_functions
|
||||
|
||||
.nothing:
|
||||
@ -215,6 +224,10 @@ proc AddDevice stdcall uses ebx esi edi, .config_pipe:DWORD, .config_descr:DWORD
|
||||
mov [eax + ftdi_context.maxPacketSize], 64
|
||||
mov [eax + ftdi_context.readBufChunkSize], 64
|
||||
mov [eax + ftdi_context.writeBufChunkSize], 64
|
||||
mov [eax + ftdi_context.readBufPtr], 0
|
||||
mov [eax + ftdi_context.writeBufPtr], 0
|
||||
mov [eax + ftdi_context.readBufLock], 0
|
||||
mov [eax + ftdi_context.writeBufLock], 0
|
||||
|
||||
mov [eax + ftdi_context.chipType], TYPE_R
|
||||
jmp .slow
|
||||
@ -270,6 +283,15 @@ proc AddDevice stdcall uses ebx esi edi, .config_pipe:DWORD, .config_descr:DWORD
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
mov [ebx + ftdi_context.inEP], eax
|
||||
|
||||
mov eax, [serial_drv_entry]
|
||||
test eax, eax
|
||||
jz @f
|
||||
stdcall serial_add_port, uart_drv, ebx
|
||||
DEBUGF 1, "usbftdi: add serial port with result %x\n", eax
|
||||
@@:
|
||||
mov [ebx + ftdi_context.port_handle], eax
|
||||
|
||||
mov eax, ebx
|
||||
ret
|
||||
|
||||
@ -1013,12 +1035,340 @@ endp
|
||||
proc DeviceDisconnected stdcall uses ebx esi edi, .device_data:DWORD
|
||||
|
||||
DEBUGF 1, 'K : FTDI deleting device data 0x%x\n', [.device_data]
|
||||
mov eax, [.device_data]
|
||||
mov esi, [.device_data]
|
||||
mov eax, [esi + ftdi_context.readBufPtr]
|
||||
test eax, eax
|
||||
jz @f
|
||||
invoke Kfree
|
||||
@@:
|
||||
mov eax, [esi + ftdi_context.writeBufPtr]
|
||||
test eax, eax
|
||||
jz @f
|
||||
invoke Kfree
|
||||
@@:
|
||||
mov eax, [esi + ftdi_context.port_handle]
|
||||
test eax, eax
|
||||
jz @f
|
||||
stdcall serial_remove_port, eax
|
||||
@@:
|
||||
mov eax, esi
|
||||
call linkedlist_unlink
|
||||
invoke Kfree
|
||||
ret
|
||||
endp
|
||||
|
||||
proc bulk_in_complete stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, \
|
||||
.buffer:DWORD, .length:DWORD, .calldata:DWORD
|
||||
mov eax, [.status]
|
||||
test eax, eax
|
||||
jz @f
|
||||
DEBUGF 2, 'ftdi: bulk in error %x\n', eax
|
||||
@@:
|
||||
mov ebx, [.calldata]
|
||||
btr dword [ebx + ftdi_context.writeBufLock], 0
|
||||
stdcall uart_tx, ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
proc bulk_out_complete stdcall uses ebx edi esi, .pipe:DWORD, .status:DWORD, \
|
||||
.buffer:DWORD, .length:DWORD, .calldata:DWORD
|
||||
mov eax, [.status]
|
||||
test eax, eax
|
||||
jz @f
|
||||
DEBUGF 2, 'ftdi: bulk out error %x\n', eax
|
||||
@@:
|
||||
mov ebx, [.calldata]
|
||||
mov ecx, [.length]
|
||||
cmp ecx, 2
|
||||
jb @f
|
||||
mov esi, [.buffer]
|
||||
add esi, 2
|
||||
sub ecx, 2
|
||||
stdcall serial_handle_event, [ebx + ftdi_context.port_handle], \
|
||||
SERIAL_EVT_RXNE, ecx, esi
|
||||
@@:
|
||||
btr dword [ebx + ftdi_context.readBufLock], 0
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_startup stdcall uses ebx, data:dword, conf:dword
|
||||
DEBUGF 1, "ftdi: startup %x %x\n", [data], [conf]
|
||||
stdcall uart_reconf, [data], [conf]
|
||||
test eax, eax
|
||||
jz @f
|
||||
DEBUGF 2, "ftdi: uart reconf error %x\n", eax
|
||||
jmp .exit
|
||||
@@:
|
||||
mov ebx, [data]
|
||||
invoke TimerHS, 2, 2, uart_rx, ebx
|
||||
test eax, eax
|
||||
jnz @f
|
||||
DEBUGF 2, "ftdi: timer creation error\n"
|
||||
or eax, -1
|
||||
jmp .exit
|
||||
@@:
|
||||
mov [ebx + ftdi_context.rx_timer], eax
|
||||
xor eax, eax
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_shutdown stdcall uses ebx, data:dword
|
||||
DEBUGF 1, "ftdi: shutdown %x\n", [data]
|
||||
mov ebx, [data]
|
||||
cmp [ebx + ftdi_context.rx_timer], 0
|
||||
jz @f
|
||||
invoke CancelTimerHS, [ebx + ftdi_context.rx_timer]
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_reconf stdcall uses ebx esi, dev:dword, conf:dword
|
||||
mov ebx, [dev]
|
||||
mov esi, [conf]
|
||||
stdcall ftdi_set_baudrate, ebx, [esi + SP_CONF.baudrate]
|
||||
; TODO set word_size, parity, etc.
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_tx stdcall uses ebx esi, data:dword
|
||||
xor eax, eax
|
||||
mov ebx, [data]
|
||||
bts dword [ebx + ftdi_context.writeBufLock], 0
|
||||
jc .exit
|
||||
|
||||
mov esi, [ebx + ftdi_context.writeBufPtr]
|
||||
test esi, esi
|
||||
jnz .read
|
||||
|
||||
; allocate buffer for bulk_in transfer if not yet
|
||||
mov eax, [ebx + ftdi_context.writeBufChunkSize]
|
||||
invoke Kmalloc
|
||||
test eax, eax
|
||||
jz .error
|
||||
mov [ebx + ftdi_context.writeBufPtr], eax
|
||||
mov esi, eax
|
||||
|
||||
.read:
|
||||
mov eax, [ebx + ftdi_context.writeBufChunkSize]
|
||||
stdcall serial_handle_event, [ebx + ftdi_context.port_handle], \
|
||||
SERIAL_EVT_TXE, eax, esi
|
||||
test eax, eax
|
||||
jz .unlock
|
||||
invoke USBNormalTransferAsync, [ebx + ftdi_context.inEP], esi, eax, \
|
||||
bulk_in_complete, ebx, 1
|
||||
test eax, eax
|
||||
jz .error
|
||||
xor eax, eax
|
||||
jmp .exit
|
||||
|
||||
.error:
|
||||
or eax, -1
|
||||
.unlock:
|
||||
btr dword [ebx + ftdi_context.writeBufLock], 0
|
||||
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
proc uart_rx stdcall uses ebx esi, data:dword
|
||||
xor eax, eax
|
||||
mov ebx, [data]
|
||||
bts dword [ebx + ftdi_context.readBufLock], 0
|
||||
jc .exit
|
||||
|
||||
mov esi, [ebx + ftdi_context.readBufPtr]
|
||||
test esi, esi
|
||||
jnz .read
|
||||
|
||||
; allocate buffer for bulk_out transfer if not yet
|
||||
mov eax, [ebx + ftdi_context.readBufChunkSize]
|
||||
invoke Kmalloc
|
||||
test eax, eax
|
||||
jz .error
|
||||
mov [ebx + ftdi_context.readBufPtr], eax
|
||||
mov esi, eax
|
||||
|
||||
.read:
|
||||
mov edx, [ebx + ftdi_context.readBufChunkSize]
|
||||
invoke USBNormalTransferAsync, [ebx + ftdi_context.outEP], esi, edx, \
|
||||
bulk_out_complete, ebx, 1
|
||||
test eax, eax
|
||||
jz .error
|
||||
xor eax, eax
|
||||
jmp .exit
|
||||
.error:
|
||||
btr dword [ebx + ftdi_context.readBufLock], 0
|
||||
or eax, -1
|
||||
.exit:
|
||||
ret
|
||||
endp
|
||||
|
||||
proc ftdi_set_baudrate stdcall uses ebx esi edi, dev:dword, baud:dword
|
||||
locals
|
||||
ConfPacket rb 10
|
||||
EventData rd 3
|
||||
endl
|
||||
xor esi, esi
|
||||
xor ecx, ecx
|
||||
invoke CreateEvent
|
||||
mov [EventData], eax
|
||||
mov [EventData + 4], edx
|
||||
|
||||
mov ebx, [dev]
|
||||
cmp [ebx + ftdi_context.chipType], TYPE_2232H
|
||||
jl .c_clk
|
||||
imul eax, [baud], 10
|
||||
cmp eax, H_CLK / 0x3FFF
|
||||
jle .c_clk
|
||||
.h_clk:
|
||||
cmp dword [baud], H_CLK / 10
|
||||
jl .h_nextbaud1
|
||||
xor edx, edx
|
||||
mov ecx, H_CLK / 10
|
||||
jmp .calcend
|
||||
|
||||
.c_clk:
|
||||
cmp dword [baud], C_CLK / 16
|
||||
jl .c_nextbaud1
|
||||
xor edx, edx
|
||||
mov ecx, C_CLK / 16
|
||||
jmp .calcend
|
||||
|
||||
.h_nextbaud1:
|
||||
cmp dword [baud], H_CLK / (10 + 10 / 2)
|
||||
jl .h_nextbaud2
|
||||
mov edx, 1
|
||||
mov ecx, H_CLK / (10 + 10 / 2)
|
||||
jmp .calcend
|
||||
|
||||
.c_nextbaud1:
|
||||
cmp dword [baud], C_CLK / (16 + 16 / 2)
|
||||
jl .c_nextbaud2
|
||||
mov edx, 1
|
||||
mov ecx, C_CLK/(16 + 16 / 2)
|
||||
jmp .calcend
|
||||
|
||||
.h_nextbaud2:
|
||||
cmp dword [baud], H_CLK / (2 * 10)
|
||||
jl .h_nextbaud3
|
||||
mov edx, 2
|
||||
mov ecx, H_CLK / (2 * 10)
|
||||
jmp .calcend
|
||||
|
||||
.c_nextbaud2:
|
||||
cmp dword [edi + 8], C_CLK / (2 * 16)
|
||||
jl .c_nextbaud3
|
||||
mov edx, 2
|
||||
mov ecx, C_CLK / (2 * 16)
|
||||
jmp .calcend
|
||||
|
||||
.h_nextbaud3:
|
||||
mov eax, H_CLK * 16 / 10 ; eax - best_divisor
|
||||
xor edx, edx
|
||||
div dword [baud]
|
||||
push eax
|
||||
and eax, 1
|
||||
pop eax
|
||||
shr eax, 1
|
||||
jz .h_rounddowndiv ; jump by result of and eax, 1
|
||||
inc eax
|
||||
.h_rounddowndiv:
|
||||
cmp eax, 0x20000
|
||||
jle .h_best_divok
|
||||
mov eax, 0x1FFFF
|
||||
.h_best_divok:
|
||||
mov ecx, eax
|
||||
mov eax, H_CLK * 16 / 10
|
||||
xor edx, edx
|
||||
div ecx
|
||||
xchg ecx, eax ; ecx - best_baud
|
||||
push ecx
|
||||
and ecx, 1
|
||||
pop ecx
|
||||
shr ecx, 1
|
||||
jz .rounddownbaud
|
||||
inc ecx
|
||||
jmp .rounddownbaud
|
||||
|
||||
.c_nextbaud3:
|
||||
mov eax, C_CLK ; eax - best_divisor
|
||||
xor edx, edx
|
||||
div dword [baud]
|
||||
push eax
|
||||
and eax, 1
|
||||
pop eax
|
||||
shr eax, 1
|
||||
jnz .c_rounddowndiv ; jump by result of and eax, 1
|
||||
inc eax
|
||||
.c_rounddowndiv:
|
||||
cmp eax, 0x20000
|
||||
jle .c_best_divok
|
||||
mov eax, 0x1FFFF
|
||||
.c_best_divok:
|
||||
mov ecx, eax
|
||||
mov eax, C_CLK
|
||||
xor edx, edx
|
||||
div ecx
|
||||
xchg ecx, eax ; ecx - best_baud
|
||||
push ecx
|
||||
and ecx, 1
|
||||
pop ecx
|
||||
shr ecx, 1
|
||||
jnz .rounddownbaud
|
||||
inc ecx
|
||||
|
||||
.rounddownbaud:
|
||||
mov edx, eax ; edx - encoded_divisor
|
||||
shr edx, 3
|
||||
and eax, 0x7
|
||||
push 7 6 5 1 4 2 3 0
|
||||
mov eax, [esp + eax * 4]
|
||||
shl eax, 14
|
||||
or edx, eax
|
||||
add esp, 32
|
||||
|
||||
.calcend:
|
||||
mov eax, edx ; eax - *value
|
||||
mov ecx, edx ; ecx - *index
|
||||
and eax, 0xFFFF
|
||||
cmp [ebx + ftdi_context.chipType], TYPE_2232H
|
||||
jge .foxyindex
|
||||
shr ecx, 16
|
||||
jmp .preparepacket
|
||||
.foxyindex:
|
||||
shr ecx, 8
|
||||
and ecx, 0xFF00
|
||||
or ecx, [ebx + ftdi_context.index]
|
||||
|
||||
.preparepacket:
|
||||
mov word [ConfPacket], (FTDI_DEVICE_OUT_REQTYPE) \
|
||||
+ (SIO_SET_BAUDRATE_REQUEST shl 8)
|
||||
mov word [ConfPacket + 2], ax
|
||||
mov word [ConfPacket + 4], cx
|
||||
mov word [ConfPacket + 6], 0
|
||||
|
||||
lea esi, [ConfPacket]
|
||||
lea edi, [EventData]
|
||||
invoke USBControlTransferAsync, [ebx + ftdi_context.nullP], esi, 0,\
|
||||
0, control_callback, edi, 0
|
||||
test eax, eax
|
||||
jz .error
|
||||
mov eax, [EventData]
|
||||
mov ebx, [EventData + 4]
|
||||
invoke WaitEvent
|
||||
|
||||
mov eax, [EventData]
|
||||
mov ebx, [EventData + 4]
|
||||
invoke DestroyEvent
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.error:
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
include 'linkedlist.inc'
|
||||
|
||||
align 4
|
||||
@ -1029,6 +1379,17 @@ usb_functions:
|
||||
dd AddDevice
|
||||
dd DeviceDisconnected
|
||||
|
||||
align 4
|
||||
uart_drv:
|
||||
dd uart_drv_end - uart_drv
|
||||
dd uart_startup
|
||||
dd uart_shutdown
|
||||
dd uart_reconf
|
||||
dd uart_tx
|
||||
uart_drv_end:
|
||||
|
||||
serial_drv_entry dd 0
|
||||
|
||||
data fixups
|
||||
end data
|
||||
|
||||
|
@ -81,7 +81,7 @@ __exports:
|
||||
pci_write32, 'PciWrite32', \ ; stdcall
|
||||
\
|
||||
get_pid, 'GetPid', \
|
||||
get_service, 'GetService', \ ;
|
||||
get_service, 'GetService', \ ; stdcall
|
||||
reg_service, 'RegService', \ ; stdcall
|
||||
attach_int_handler, 'AttachIntHandler', \ ; stdcall
|
||||
user_alloc, 'UserAlloc', \ ; stdcall
|
||||
|
@ -1333,7 +1333,7 @@ f68call: ; keep this table closer to main code
|
||||
|
||||
align 4
|
||||
proc load_pe_driver stdcall, file:dword, cmdline:dword
|
||||
push esi
|
||||
push ebx esi
|
||||
|
||||
stdcall load_PE, [file]
|
||||
test eax, eax
|
||||
@ -1352,13 +1352,13 @@ proc load_pe_driver stdcall, file:dword, cmdline:dword
|
||||
|
||||
mov [eax + SRV.base], ebx
|
||||
mov [eax + SRV.entry], esi
|
||||
pop esi
|
||||
pop esi ebx
|
||||
ret
|
||||
.fail_init:
|
||||
stdcall kernel_free, ebx ;clear memory driver
|
||||
.fail:
|
||||
xor eax, eax
|
||||
pop esi
|
||||
pop esi ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
char file_actions[]=
|
||||
"Žâªàëâì |Enter
|
||||
Žâªàëâì á ¯®¬®éìî |CrlEnt
|
||||
Žâªàëâì á ¯®¬®éìî |Ctrl+Ent
|
||||
-
|
||||
Š®¯¨à®¢ âì |Crl+C
|
||||
‚ë१ âì |Crl+X
|
||||
‚áâ ¢¨âì |Crl+V
|
||||
Š®¯¨à®¢ âì |Ctrl+C
|
||||
‚ë१ âì |Ctrl+X
|
||||
‚áâ ¢¨âì |Ctrl+V
|
||||
-
|
||||
<EFBFBD>¥à¥¨¬¥®¢ âì |F2
|
||||
“¤ «¨âì |Del
|
||||
‘¢®©á⢠|F1";
|
||||
char empty_folder_actions[]=
|
||||
"‚áâ ¢¨âì |Crl+V";
|
||||
"‚áâ ¢¨âì |Ctrl+V";
|
||||
char burger_menu_items[] =
|
||||
"<EFBFBD>®¢®¥ ®ª®|Ctrl+N
|
||||
Žâªàëâì ª®á®«ì|Ctrl+G
|
||||
@ -23,17 +23,17 @@ char burger_menu_items[] =
|
||||
#elif LANG_EST
|
||||
char file_actions[]=
|
||||
"Ava |Enter
|
||||
Ava ... |CrlEnt
|
||||
Ava ... |Ctrl+Ent
|
||||
-
|
||||
Kopeeri |Crl+C
|
||||
Lõika |Crl+X
|
||||
Aseta |Crl+V
|
||||
Kopeeri |Ctrl+C
|
||||
Lõika |Ctrl+X
|
||||
Aseta |Ctrl+V
|
||||
-
|
||||
Nimeta ümber |F2
|
||||
Kustuta |Del
|
||||
Properties |F1";
|
||||
char empty_folder_actions[]=
|
||||
"Aseta |Crl+V";
|
||||
"Aseta |Ctrl+V";
|
||||
char burger_menu_items[] =
|
||||
"New window|Ctrl+N
|
||||
Open console here|Ctrl+G
|
||||
@ -44,17 +44,17 @@ About";
|
||||
#else
|
||||
char file_actions[]=
|
||||
"Open |Enter
|
||||
Open with... |CrlEnt
|
||||
Open with... |Ctrl+Ent
|
||||
-
|
||||
Copy |Crl+C
|
||||
Cut |Crl+X
|
||||
Paste |Crl+V
|
||||
Copy |Ctrl+C
|
||||
Cut |Ctrl+X
|
||||
Paste |Ctrl+V
|
||||
-
|
||||
Rename |F2
|
||||
Delete |Del
|
||||
Properties |F1";
|
||||
char empty_folder_actions[]=
|
||||
"Paste |Crl+V";
|
||||
"Paste |Ctrl+V";
|
||||
char burger_menu_items[] =
|
||||
"New window|Ctrl+N
|
||||
Open console here|Ctrl+G
|
||||
|
@ -5,8 +5,12 @@
|
||||
#include "../lib/list_box.h"
|
||||
#include "../lib/fs.h"
|
||||
|
||||
#define ITEM_H 19
|
||||
#define ITEM_H 24
|
||||
#define SEP_H 4
|
||||
#define TEXT_FONT_TYPE 0x90
|
||||
#define TEXT_MARGIN 13
|
||||
#define FONT_WIDTH 8
|
||||
#define FONT_HEIGHT 16
|
||||
|
||||
llist menu1;
|
||||
collection names=0;
|
||||
@ -43,9 +47,9 @@ void GetMenuWidths()
|
||||
for (i=0; i<hotkeys.count; i++) {
|
||||
max_hotkey_len = math.max(max_hotkey_len, strlen(hotkeys.get(i)));
|
||||
}
|
||||
max_name_len = max_name_len * 6;
|
||||
max_hotkey_len *= 6;
|
||||
if (max_hotkey_len) max_name_len += 12;
|
||||
max_name_len = max_name_len * FONT_WIDTH;
|
||||
max_hotkey_len *= FONT_WIDTH;
|
||||
if (max_hotkey_len) max_name_len += FONT_WIDTH*2;
|
||||
}
|
||||
|
||||
void GetMenuItems(dword current_name)
|
||||
@ -108,12 +112,14 @@ void main()
|
||||
GetMenuItems(#param);
|
||||
GetMenuWidths();
|
||||
|
||||
menu_w = max_name_len + max_hotkey_len + 23;
|
||||
menu_w = max_name_len + max_hotkey_len + TEXT_MARGIN + TEXT_MARGIN;//23;
|
||||
menu_h = GetSeparatorsCount() * SEP_H
|
||||
+ calc(names.count - GetSeparatorsCount() * ITEM_H);
|
||||
|
||||
menu1.count = names.count;
|
||||
menu1.SetFont(6, 9, 0x80);
|
||||
// menu1.SetFont(8, 14, 10011000b);
|
||||
menu1.SetFont(8, 16, 0x80); // TODO what is third par
|
||||
// menu1.SetFont(6, 9, 0x80);
|
||||
menu1.SetSizes(2,2, menu_w, menu_h, ITEM_H);
|
||||
menu1.cur_y = -1;
|
||||
|
||||
@ -231,17 +237,17 @@ void draw_list()
|
||||
name_color = sc.work_text;
|
||||
hotkey_color = sc.line;
|
||||
DrawBar(menu1.x, item_y, menu1.w, ITEM_H, inactive_background_color);
|
||||
if (!skin_dark) WriteText(13+1, item_y + menu1.text_y +1, 0x80,
|
||||
if (!skin_dark) WriteText(TEXT_MARGIN+1, item_y + menu1.text_y +1, TEXT_FONT_TYPE,
|
||||
inactive_text_shadow_color, names.get(i));
|
||||
}
|
||||
WriteText(-strlen(hotkeys.get(i))*6 + 13 + max_name_len + max_hotkey_len,
|
||||
item_y + menu1.text_y, 0x80, hotkey_color, hotkeys.get(i));
|
||||
WriteText(13, item_y + menu1.text_y, 0x80, name_color, names.get(i));
|
||||
WriteText(-strlen(hotkeys.get(i))*FONT_WIDTH + menu_w - TEXT_MARGIN,
|
||||
item_y + menu1.text_y, TEXT_FONT_TYPE, hotkey_color, hotkeys.get(i));
|
||||
WriteText(TEXT_MARGIN, item_y + menu1.text_y, TEXT_FONT_TYPE, name_color, names.get(i));
|
||||
item_y += ITEM_H;
|
||||
item_i++;
|
||||
}
|
||||
}
|
||||
if (selected) WriteText(5, selected-1*ITEM_H + menu1.y + menu1.text_y, 0x80, 0xEE0000, "\x10");
|
||||
if (selected) WriteText(5, selected-1*ITEM_H + menu1.y + menu1.text_y, TEXT_FONT_TYPE, 0xEE0000, "\x10"); // ?
|
||||
}
|
||||
|
||||
void click()
|
||||
|
@ -1,5 +1,5 @@
|
||||
@del sysmon
|
||||
@c-- /D=LANG_RUS sysmon.c
|
||||
@c-- /D=LANG_ENG sysmon.c
|
||||
@rename sysmon.com sysmon
|
||||
@del warning.txt
|
||||
if not exist sysmon ( @pause )
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* System Monitor
|
||||
* version 1.41
|
||||
* version 1.42
|
||||
* Author: Leency
|
||||
*/
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
#define BOTPANEL_H 36
|
||||
|
||||
#ifdef LANG_RUS
|
||||
#define T_APP_TITLE "‘¨áâ¥¬ë© ¬®¨â®à"
|
||||
#define T_APP_TITLE "‘¨áâ¥¬ë© Œ®¨â®à 1.42"
|
||||
#define T_SHOW_SYSTEM "‘¨á⥬ë¥"
|
||||
#define T_DETAILS "<22>®¤à®¡¥¥"
|
||||
#define T_PROC_KILL "‘ïâì § ¤ çã"
|
||||
@ -49,7 +49,7 @@
|
||||
#define T_RD_USAGE "‘¨áâ¥¬ë© ¤¨áª: %i Š¡ ᢮¡®¤® ¨§ 1.4 Œ¡"
|
||||
#define T_TMP_USAGE "TMP%i ¤¨áª: %i Œ¡ ᢮¡®¤® ¨§ %i Œ¡"
|
||||
#else
|
||||
#define T_APP_TITLE "System Monitor"
|
||||
#define T_APP_TITLE "System Monitor 1.42"
|
||||
#define T_SHOW_SYSTEM "System"
|
||||
#define T_DETAILS "Details"
|
||||
#define T_PROC_KILL "Terminate"
|
||||
@ -57,7 +57,7 @@
|
||||
#define T_PROC_HEADER "Process RAM KB CPU %"
|
||||
#define T_CPU_LOAD "CPU load %i%% "
|
||||
#define T_RAM_USAGE "RAM usage: %i MB free of %i MB"
|
||||
#define T_RD_USAGE "System disk usage: %i MB free of 1.4 MB"
|
||||
#define T_RD_USAGE "System disk usage: %i KB free of 1.4 MB"
|
||||
#define T_TMP_USAGE "TMP%i usage: %i MB free of %i MB"
|
||||
#endif
|
||||
|
||||
@ -156,7 +156,7 @@ void main()
|
||||
break;
|
||||
case evReDraw:
|
||||
sc.get();
|
||||
DefineAndDrawWindow(Form.left, Form.top, Form.width, Form.height, 0x33, sc.work, T_APP_TITLE,0);
|
||||
DefineAndDrawWindow(Form.left, Form.top, Form.width, Form.height, 0x33, sc.work, T_APP_TITLE, 0);
|
||||
_DRAW_WINDOW:
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
if (Form.status_window&ROLLED_UP) break;
|
||||
@ -281,7 +281,7 @@ void SelectList_DrawLine(dword i)
|
||||
}
|
||||
|
||||
sprintf(#cpu_use, "%i", Process.use_cpu*100/maxcpu);
|
||||
if (maxcpu) WriteText(GAP+203 - calc(strlen(#cpu_use)-4*8),
|
||||
if (maxcpu) WriteText(GAP+205 - calc(strlen(#cpu_use)-4*8),
|
||||
posy+select_list.text_y, 0x90, 0x444444, #cpu_use);
|
||||
}
|
||||
|
||||
@ -311,6 +311,7 @@ dword GetTmpDiskFreeSpace(int _id)
|
||||
sprintf(#param, "/tmp%i/1", _id);
|
||||
dir_size.get(#param);
|
||||
dir_size.sizelo += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
|
||||
dir_size.sizelo += 1024*1024 - 1; // add this line to round up
|
||||
dir_size.sizelo /= 1024*1024; //convert to MiB
|
||||
return dir_size.sizelo;
|
||||
}
|
||||
|
@ -842,6 +842,19 @@ KOSAPI uint32_t _ksys_wait_event_timeout(uint32_t timeout)
|
||||
return val;
|
||||
}
|
||||
|
||||
/*=== Function 26, subfunction 2 - get keynoard layout. ==*/
|
||||
|
||||
typedef enum KSYS_KEYBOARD_LAYOUT {
|
||||
KSYS_KEYBOARD_LAYOUT_NORMAL = 1,
|
||||
KSYS_KEYBOARD_LAYOUT_SHIFT = 2,
|
||||
KSYS_KEYBOARD_LAYOUT_ALT = 3
|
||||
} ksys_keyboard_layout_t;
|
||||
|
||||
KOSAPI uint32_t _ksys_keyboard_layout(ksys_keyboard_layout_t layout, unsigned char *buf)
|
||||
{
|
||||
asm_inline("int $0x40" ::"a"(26), "b"(2), "c"(layout), "d"(buf) : "memory");
|
||||
}
|
||||
|
||||
/*=== Function 26, subfunction 9 - get the value of the time counter. ==*/
|
||||
|
||||
KOSAPI uint32_t _ksys_get_tick_count(void)
|
||||
|
@ -1,59 +0,0 @@
|
||||
# Libio
|
||||
> Lib for work with files
|
||||
|
||||
## Functions
|
||||
|
||||
### Files enumeration
|
||||
|
||||
##### `file_find_first`
|
||||
> Find first file with matching attributes and mask in specified directory.
|
||||
|
||||
**Prototype**:
|
||||
`proc file.find_first dir, mask, attr`
|
||||
|
||||
**Arguments**:
|
||||
| name | type | Describtion |
|
||||
| :--- | :----: | :------------------------------------------------------- |
|
||||
| dir | ASCIIZ | Directory path, to search in |
|
||||
| mask | ASCIIZ | File mask, with use of wildcards (a.k.a. shell patterns) |
|
||||
| attr | ASCIIZ | File attributes mask (combination of FA_* constants) |
|
||||
|
||||
**Result**:
|
||||
| register | type | Description |
|
||||
| :------- | :-------: | :--------------------------------------------------------------------- |
|
||||
| EAX | Fileinfo* | 0 for error<br/>Matched file data pointer (__acts as find descriptor__) |
|
||||
|
||||
|
||||
##### `file_find_next`
|
||||
> Find next file matching criteria.
|
||||
|
||||
**Prototype**:
|
||||
`proc file.find_next findd`
|
||||
|
||||
**Argument**:
|
||||
| name | type | Describtion |
|
||||
| :---- | :-------: | :--------------------------------------------------------- |
|
||||
| findd | Fileinfo* | Find describtion (see [file_find_first](#file_find_first)) |
|
||||
|
||||
**Result**:
|
||||
| register | type | Description |
|
||||
| :------- | :-------: | :--------------------------------------------------------------------- |
|
||||
| EAX | Fileinfo* | 0 for info<br/>Matched file data pointer (__acts as find descriptor__) |
|
||||
|
||||
|
||||
##### `file_find_close`
|
||||
> Find next file matching criteria.
|
||||
|
||||
**Prototype**:
|
||||
`Find next file matching criteria.`
|
||||
|
||||
**Arguments**:
|
||||
| name | type | Describtion |
|
||||
| :---- | :-------: | :--------------------------------------------------------- |
|
||||
| findd | Fileinfo* | Find describtion (see [file_find_first](#file_find_first)) |
|
||||
|
||||
|
||||
**Result**:
|
||||
| register | type | Description |
|
||||
| :------- | :---: | :------------------------------- |
|
||||
| EAX | dword | Result of memory freeing routine |
|
@ -5,7 +5,7 @@
|
||||
;
|
||||
|
||||
include 'lang.inc' ; Language support for locales: ru_RU (CP866), it_IT, de_DE, en_US.
|
||||
include '..\..\..\macros.inc' ; decreases program size (not required)
|
||||
include '..\..\macros.inc' ; decreases program size (not required)
|
||||
|
||||
StatusColor equ 0x00ffffff
|
||||
StatusColor2 equ 0x00dc1e14
|
@ -1,5 +1,5 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
add_include(tup.getvariantdir())
|
||||
|
@ -1,5 +1,5 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" or tup.getconfig("NO_MSVC") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_msvc.lua")
|
||||
if tup.getconfig("LANG") == "ru_RU"
|
||||
then CFLAGS = CFLAGS .. " /DLANG=RUS"
|
@ -45,7 +45,7 @@ debug_print_dec num
|
||||
popad
|
||||
}
|
||||
|
||||
include '../../../macros.inc'
|
||||
include '../../macros.inc'
|
||||
;include 'debug.inc'
|
||||
include 'editbox_ex.mac'
|
||||
include 'lang.inc'
|
@ -1,5 +1,5 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
add_include(tup.getvariantdir())
|
||||
|
@ -1,5 +1,5 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
add_include(tup.getvariantdir())
|
||||
|
@ -5,7 +5,7 @@
|
||||
;----------------------------------------
|
||||
|
||||
include 'lang.inc' ; Language support for locales: it_IT, en_US.
|
||||
include '../../../macros.inc'
|
||||
include '../../macros.inc'
|
||||
include 'ascl.inc'
|
||||
include 'ascgl.inc'
|
||||
include 'asjc.inc'
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
@ -1,5 +1,5 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
add_include(tup.getvariantdir())
|
||||
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
@ -20,7 +20,7 @@
|
||||
;******************************************************************************
|
||||
|
||||
include 'lang.inc' ; Language support for locales: it_IT, en_US.
|
||||
include '..\..\..\macros.inc'
|
||||
include '..\..\macros.inc'
|
||||
include 'ascl.inc'
|
||||
include 'ascgl.inc'
|
||||
include 'ascgml.inc'
|
@ -1,4 +1,4 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
tup.rule("bnc.asm", FASM .. " -dlang=" .. tup.getconfig("LANG") .. " %f %o " .. tup.getconfig("KPACK_CMD"), "bnc")
|
Before Width: | Height: | Size: 954 B After Width: | Height: | Size: 954 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 708 B |
Before Width: | Height: | Size: 703 B After Width: | Height: | Size: 703 B |