Combined .com executable/DOS driver (Announce)
So, did you find if FreeDOS does mimic MS-DOS's undocumented behaviour i.e. will it accept to load our tricky COM files as drivers ?
FWIW, here's one short source complete from my archives, hopefully demonstrating how I do it (assembles w/ TASM in MASM mode). Apologies : I didn't review, trim or edit the specifics - for lack of time. HTH anyway !
; =============
; == S.R. 09 ==
; =============
;
; ==== Objet : Rendre accessible la RAM @ E0000-EFFFF sur le systeme AsRock 741
; et l'initialiser pour UMBPCI (=FFFFFF...)
; ==== Forme : Double! A la fois Pseudo-Driver-DOS, ET programme .COM
.586P
.model small
JUMPS
ASSUME CS:CODE, DS:nothing
code SEGMENT USE16
ORG 0
; DEBUG = 1 ; supprimer en regime de croisiere !
;
; ======= Equates :
;
CR EQU 0Dh
LF EQU 0Ah
BELL EQU 07h
EoL EQU CR,LF,'$' ; fin de message ( pour DOS 21/09)
ERRG EQU 8003h ; erreur generale (driver)
; ======= Deplacements dans le bloc de parametres de driver:
NumFonc EQU 02h ; byte
CodeRet EQU 03h ; word ( sortie )
Offs_Fin EQU 0Eh ; ptr
ParmAddress EQU 12h ; ptr
InitErrFlag EQU 17h ; byte ( sortie ; pour faire aff msg d'err par DOS )
; ======= En-tete (pilote de caracteres, bidon). Doit etre a l'Offs zero
ORG 0 ; initialement en 0100h si .COM ...
HEADER LABEL NEAR ; En-tete Pilote, ET debut .COM !
jmp short COM_Start ; saut (relatif) court necessaire .
DW -1
DW 8000h ; attributs du "peripherique"
DW Offset Strat
DW Offset IntRou
DB "741UMEM" ; nom de pilote, bidon, Pour diagnostic !
COM_Flag DB "$" ; fin du nom de pilote, OU 00 si appel-COM !
; ======== Debut-COM : Ajuster le CS pour commencer : ====
COM_Start: CLD ; au depart CS=DS=PSP, IP=100h
MOV AX, CS
ADD AX, 10h ; compense la taille du PSP
MOV Word Ptr[DS:req_header_ptr] +2 +100h, AX
MOV Word Ptr [DS:req_header_ptr] +100h, offset COM_Adjusted
JMP DWord Ptr [DS:req_header_ptr]+100h ;-> COM_Adjusted
; ======== Donnees: constantes / variables. ===============
req_header_ptr DW 2 DUP (?) ; ptr -> bloc de parametres (req header)
; ======== Donnees specifiques a CE pilote
SysConfig = 0C0010010h
MTRR_FIX4K_E0000 = 026Ch
; MTRR_FIX4K_E8000 = 026Dh
PCI_Addr_Port = 0CF8h
SiS741_shadow_RAM = 70h
Enable_RAM_E0000 = 0F008F00h ; shadow enabled, +RW at E0000
SiS741 = 07411039h ; PCI device and vendor ID
; ======== Messages Ascii '$' - pour DOS int 21/09 : EoL=CR LF $
MSG0 DB 'Repair SiS741 upper memory, by S.R. (c) 2009' ,EoL
M_MBREAL DB BELL, 'Sorry! Processor must be in REAL mode for 741UMEM to do its magic. Aborting!' ,CR,LF
DB 'Please try launching it from CONFIG.SYS, BEFORE any memory manager', EOL
M_BADCHIP DB BELL, 'Error! Wrong chipset or processor.' ,EoL
M_DidntWork DB BELL, 'Error! Something went wrong, aborting.' ,EoL
M_Fin_OK DB 'SUCCESS! RAM at segment E0000 available & initialised.',EoL
; ======== Code. =========================================================
; 'Strategy routine' = acquisition du <request header>
STRAT PROC FAR
MOV CS:[req_header_ptr] , BX
MOV CS:[req_header_ptr+2], ES
RET
STRAT ENDP
;=========================================================================
; 'Interruption routine' pour le pseudo-pilote:
INTROU PROC FAR
CLD ; ----- vers le HAUT, une fois pour toutes.
PUSHA
ASSUME DS: Code
PUSH CS
POP DS
LES DI, DWORD PTR [req_header_ptr]
MOV BL, ES: [DI+ NumFonc]
OR BL , BL
JZ near ptr INIT ; le code fonction doit etre = zero
MOV AX, ERRG ; err generale signalee a MSDOS, et retour
JMP FFIN2
; Suite adaptation pour la version .COM
; On arrive ici avec le CS voulu, le meme que le driver:
COM_Adjusted:
; DS pointe encore vers le PSP !!
MOV COM_Flag + 100h, 0 ; marquer version .COM
JMP short INIT1
; =========================================================================
INIT: ; driver, fonction unique : atteinte via un JMP
MOV AH, 09
MOV DX, Offset MSG0 ; message d'accueil
INT 21h ; ne touche qu' AX
LES DI, DWORD PTR [req_header_ptr]
lds si, es:[di + ParmAddress] ; pointe sur ligne device=...
; =========================================================================
INIT1: ; commune a COM et SYS
ASSUME DS: Nothing ; (DS:SI) -> ligne d'appel
PUSH CS
POP DS
ASSUME DS: code
; ============== TESTS =================
IFDEF Debug
int 3
ENDIF
; 1st : check for REAL MODE !
MOV DX, offset M_MBREAL
SMSW AX
TEST AX, 1
JNZ MSG_et_FIN ; sinon, message d'erreur et retour :
; OK, now check proc and chipset
; call CPUID fun 0 :
MOV EAX, 0
CPUID
CMP EBX, "htuA"
JNE bad
CMP EDX, "itne"
JNE bad
CMP ECX, "DMAc"
JNE bad
; call CPUID extended func 80000001 :
MOV EAX, 80000001h
CPUID
CMP AH, 07 ; AMD family number
JB bad
AND EDX, (1 SHL 12) ;Memory type registers
JNZ testNB ; OK, next check North bridge
bad:
MOV DX, offset M_BADCHIP ; wrong processor or north bridge
; fall through -> MSG_ET_FIN
; =========================================================================
MSG_et_FIN Label NEAR
PUSH CS
POP DS ; c'est necessaire. Message adresse' par [DS:DX]
MOV AH, 9
INT 21h
TEST [COM_Flag], 0FFh
JNZ FFIN
; retour a l'appelant , version 'COM' (programme) ! - - - - - -
FFIN_COM LABEL NEAR
MOV AX, 4C00h ; pas d'erreur a renvoyer.
INT 21h ; et c'est tout !
; retour a MSDOS pour la version 'SYS' (driver) ====
FFIN LABEL NEAR
XOR AX,AX ; signale initialisation reussie!
PUSH CS
POP DS
LES DI, DWORD PTR [req_header_ptr]
FFIN2: OR AX, 0100h ; fixer le bit <termine'>
MOV ES: [DI+ CodeRet], AX
MOV WORD PTR ES: [DI+ Offs_Fin], 0 ; p/ rendre tte la memoire et
MOV ES: [DI+ Offs_Fin+2], CS ; ne PAS s'installer resident
POPA
RET ; FAR! vers MSDOS (config.sys).
; =========================================================================
; OK assume this Athlon (or better) can do the memory trick
; access PCI config space, northbridge (bus 0 dev 0 fun 0)
testNB:
mov DX, PCI_Addr_Port ; CF8
mov EAX, 0 + (1 SHL 31)
CLI
out DX, EAX
JNC loc3
loc3: MOV DL, 0FCh ; set DX = PCI_Data_Port
IN EAX, DX ; get manufacurer & model
JC loc4 ; delay, just in case
loc4: STI
MOV DX, offset M_BADCHIP
CMP EAX, SiS741
JNE MSG_et_FIN
; All correct !
; ============== ACTION ================
; Program K7 MSRs & SiS741 shadow :
; the meat of this program !
; 1 : K7: open access to extended MTRR attributes :
WBINVD ; before messing with mem mappings
mov ECX, SysConfig ; MSR C001_0010
RDMSR
or EAX, 1 SHL 19
WRMSR
; 2 : K7: appliquer tout le segment "E" (64 k) sur le bus PCI
mov ECX, MTRR_FIX4K_E0000
mov EAX, 06060606h ; IO, write-back !
mov EDX, EAX
WRMSR
INC CX ; MTRR_FIX4K_E8000
WRMSR
;3 : K7: close access to extended MTRR attributes :
mov ECX, SysConfig ; MSR C001_0010
RDMSR
and EAX, NOT (1 SHL 19)
WRMSR
; 4 : SiS 741 : enable shadow RAM, segment E (R/W)
; access PCI config space, bus 0 dev 0 fun 0
mov DX, PCI_Addr_Port ; CF8
mov EAX, SiS741_shadow_RAM + (1 SHL 31)
CLI
out DX, EAX
JNC loc1
loc1: MOV DL, 0FCh ; set DX = PCI_Data_Port
IN EAX, DX ; read shadow RAM attributes
JC loc2 ; delay, just in case
loc2:
OR EAX, Enable_RAM_E0000
out DX, EAX ; update SiS shadow
STI
; Check if it worked : can we access the memory at E0000 ?
MOV AX, 0E000h
MOV DS, AX
MOV ES, AX
ASSUME DS: nothing, ES: nothing
MOV AX, [DS:0]
MOV BX, 0-1
XOR BX, AX
CLI ; in case foreign BIOS would use the region
MOV [DS:0], BX
CMP BX, [DS:0]
MOV [DS:0], AX ; reset it
STI
MOV DX, offset M_DidntWork
JNE done
; OK! Initialise segment E - fill it with FF's
XOR AX, AX
MOV DI, AX
DEC AX ; set to FFFFh
MOV CX, 8000h
REP STOSW
MOV DX, offset M_Fin_OK
done:
; FIN ! affiche un message... et retour a MSDOS
JMP MSG_et_FIN
INTROU ENDP
; ==========================================================================
; end_of_code = $
code ENDS
END HEADER ; dummy label so as to please TASM
---
Ninho
Complete thread:
- "That Will Be ALL!" For UIDE and USB! - Jack, 06.06.2010, 20:37
![Open in board view [Board]](img/board_d.gif)
![Open in mix view [Mix]](img/mix_d.gif)
- "That Will Be ALL!" For UIDE and USB! - Rugxulo, 07.06.2010, 04:20
- Re: UIDE Unloading And Cache-Sizes. - Jack, 07.06.2010, 05:30
- Re: UIDE Unloading And Cache-Sizes. - Rugxulo, 08.06.2010, 01:35
- Re: UIDE Unloading And Cache-Sizes. - marcov, 08.06.2010, 23:18
- Re: UIDE Unloading And Cache-Sizes. - Rugxulo, 09.06.2010, 04:23
- Re: UIDE Unloading And Cache-Sizes. - marcov, 08.06.2010, 23:18
- Re: UIDE Unloading And Cache-Sizes. - Rugxulo, 08.06.2010, 01:35
- Re: UIDE Unloading And Cache-Sizes. - Jack, 07.06.2010, 05:30
- "That Will Be ALL!" For UIDE and USB! - Japheth, 07.06.2010, 07:51
- TSR vs DEVICE= - DOS386, 07.06.2010, 08:01
- TSR vs DEVICE= - RayeR, 08.06.2010, 15:46
- TSR vs DEVICE= - Arjay, 08.06.2010, 19:30
- TSR vs DEVICE= - RayeR, 09.06.2010, 02:00
- TSR vs DEVICE= - Japheth, 09.06.2010, 09:50
- TSR vs DEVICE= - RayeR, 09.06.2010, 16:15
- TSR vs DEVICE= - roytam, 09.06.2010, 18:18
- TSR vs DEVICE= - DOS386, 27.06.2010, 14:30
- TSR vs DEVICE= - Arjay, 08.06.2010, 19:30
- TSR vs DEVICE= - bretjohn, 18.06.2010, 21:50
- TSR vs DEVICE= - Jack, 18.06.2010, 23:29
- TSR vs DEVICE= - bretjohn, 19.06.2010, 01:18
- Nothing Against You! - Jack, 19.06.2010, 01:52
- TSR vs DEVICE= - Japheth, 19.06.2010, 09:02
- TSR vs DEVICE= - Arjay, 19.06.2010, 19:13
- TSR vs DEVICE= - bretjohn, 19.06.2010, 20:33
- TSR vs DEVICE= - Japheth, 20.06.2010, 09:04
- TSR vs DEVICE= - Arjay, 20.06.2010, 12:48
- TSR vs DEVICE= - bretjohn, 20.06.2010, 16:32
- TSR vs DEVICE= - Ninho, 20.06.2010, 17:34
- TSR vs DEVICE= - Japheth, 20.06.2010, 09:04
- TSR vs DEVICE= - Jack, 18.06.2010, 23:29
- TSR vs DEVICE= - RayeR, 08.06.2010, 15:46
- "That Will Be ALL!" For UIDE and USB! - marcov, 08.06.2010, 22:41
- "Capital Letters". - Jack, 08.06.2010, 23:15
- "Capital Letters". - marcov, 08.06.2010, 23:19
- No "Rants", But ... - Jack, 09.06.2010, 00:24
- "Capital Letters". - Arjay, 09.06.2010, 00:37
- "Capital Letters". - Jack, 09.06.2010, 00:48
- Seeking the middle ground: thinking re flexibility+realibity - Arjay, 09.06.2010, 02:29
- Bret's USB driver bugs - I was testing v0.11 by accident - Arjay, 09.06.2010, 02:50
- Seeking the middle ground ... - Jack, 09.06.2010, 04:29
- giving back a block of HMA - Ninho, 10.06.2010, 16:03
- Giving Back HMA ... - Jack, 10.06.2010, 17:03
- Giving Back HMA ... - Ninho, 11.06.2010, 09:48
- Giving Back HMA ... - Jack, 11.06.2010, 16:43
- Giving Back HMA ... - Ninho, 12.06.2010, 20:30
- Giving Back HMA ... - Jack, 11.06.2010, 16:43
- Giving Back HMA ... - Ninho, 11.06.2010, 09:48
- Giving Back HMA ... - Jack, 10.06.2010, 17:03
- Seeking the middle ground ... - Arjay, 11.06.2010, 19:29
- Seeking the middle ground ... - Jack, 11.06.2010, 21:42
- Seeking the middle ground ... - Arjay, 12.06.2010, 01:12
- Combined .com executable/DOS driver - Ninho, 12.06.2010, 14:37
- Combined .com executable/DOS driver - Arjay, 12.06.2010, 15:13
- Combined .com executable/DOS driver - Ninho, 12.06.2010, 15:49
- Combined .com executable/DOS driver - Arjay, 12.06.2010, 16:33
- Combined .com executable/DOS driver - RayeR, 13.06.2010, 10:41
- Combined .com executable/DOS driver - Arjay, 13.06.2010, 16:11
- Combined .com executable/DOS driver - Ninho, 13.06.2010, 13:24
- Combined .com executable/DOS driver - Arjay, 13.06.2010, 18:54
- Combined .com executable/DOS driver - RayeR, 13.06.2010, 10:41
- Combined .com executable/DOS driver - Arjay, 12.06.2010, 16:33
- Combined .com executable/DOS driver - Arjay, 13.06.2010, 20:42
- Combined .com executable/DOS driver - Rugxulo, 14.06.2010, 04:27
- Combined .com executable/DOS driver / RJDUMP - Arjay, 19.06.2010, 15:08
- Combined .com executable/DOS driver - Matjaz, 20.06.2010, 11:58
- Combined .com executable/DOS driver - Turbo pascal example - Arjay, 20.06.2010, 13:06
- Combined .com executable/DOS driver - Turbo pascal example - Arjay, 20.06.2010, 13:39
- Combined .com executable/DOS driver - Turbo pascal example - Arjay, 20.06.2010, 13:06
- Combined .com executable/DOS driver - Rugxulo, 14.06.2010, 04:27
- Combined .com executable/DOS driver - Ninho, 12.06.2010, 15:49
- Combined SYS device drivers - more than 1 driver in a file - Arjay, 21.06.2010, 17:48
- Combined .com executable/DOS driver, multi-header drivers - ecm, 10.08.2010, 18:49
- Combined .com executable/DOS driver, multi-header drivers - Arjay, 10.08.2010, 19:41
- Combined .com executable/DOS driver, multi-header drivers - ecm, 10.08.2010, 20:21
- Combined .com executable/DOS driver, multi-header drivers - Arjay, 10.08.2010, 19:41
- Combined .com executable/DOS driver - Arjay, 12.06.2010, 15:13
- Combined .com executable/DOS driver - Ninho, 12.06.2010, 14:37
- Seeking the middle ground ... - Arjay, 12.06.2010, 01:12
- Seeking the middle ground ... - Jack, 11.06.2010, 21:42
- giving back a block of HMA - Ninho, 10.06.2010, 16:03
- Seeking the middle ground: thinking re flexibility+realibity - Arjay, 09.06.2010, 02:29
- "Capital Letters". - Jack, 09.06.2010, 00:48
- "Capital Letters". - marcov, 08.06.2010, 23:19
- "Capital Letters". - Jack, 08.06.2010, 23:15
- No "Removable" HARD Disks Supported By UIDE! - Jack, 08.06.2010, 23:57
- "That Will Be ALL!" For UIDE and USB! - bretjohn, 15.06.2010, 22:47
- Further Comments ... - Jack, 16.06.2010, 01:35
- "That Will Be ALL!" For UIDE and USB! - Rugxulo, 17.06.2010, 12:07
- "That Will Be ALL!" For UIDE and USB! - bretjohn, 17.06.2010, 16:53
- "That Will Be ALL!" For UIDE and USB! - Rugxulo, 17.06.2010, 17:45
- "That Will Be ALL!" For UIDE and USB! - bretjohn, 17.06.2010, 16:53
- "That Will Be ALL!" For UIDE and USB! - Rugxulo, 07.06.2010, 04:20
Mix view