--- /dev/null
+; MMURTL Operating System Source Code\r
+; Copyright 1991,1992,1993,1994 Richard A. Burgess\r
+; ALL RIGHTS RESERVED Version 1.0\r
+;=============================================================================\r
+;Data and equates for Request Block management\r
+;\r
+.DATA\r
+;\r
+.INCLUDE RQB.INC\r
+\r
+;Request Block control variables\r
+\r
+pFreeRQB DD 0 ; Ptr to free Request Blocks\r
+PUBLIC pRQBs DD 0 ; RQBs are in allocated memory\r
+\r
+PUBLIC _nRQBLeft DD nRQBs ; For Monitor stats\r
+\r
+\r
+;=============== End Data, Begin Code =====================\r
+\r
+.CODE\r
+\r
+;================================================================\r
+\r
+InitFreeRQB:\r
+; INPUT : EAX - Address of RQBs to be initialized\r
+; ECX - Count of JCBs\r
+; EDX - Size of JCBs\r
+; OUTPUT : NONE\r
+; USED: EAX,ECX,EDX,ESI EFLAGS\r
+; MODIFIES: pFreeRQB, pRQBs\r
+;\r
+; This routine will initialize a free pool of Request Blocks (RQBs).\r
+; ECX is count of RQBs to initialize,\r
+; EDX is the size (in bytes), and EAX points to a list of free JCBs (pFreeJCB).\r
+;\r
+; The pFreeRQB pointer is set to address the first element in rgRQBs.\r
+; Each element of rgRQBs is set to point to the next element of rgRQBs.\r
+; The last element of rgRQBs is set to point to nothing (NIL).\r
+; The RqBlk handle used in many calls is its position in the array.\r
+; This can be done because the array of RQBs is allocated dynamically.\r
+;\r
+ MOV pFreeRQB,EAX ;Set up OS pointer to list\r
+ MOV pRQBs, EAX ;Set up global ptr to first RQB\r
+RQB_Loop:\r
+ MOV ESI,EAX ;EBX has pointer to current one\r
+ ADD EAX,EDX ;EAX points to next one\r
+ MOV [ESI+pNextRQB],EAX ;Make current point to next\r
+ LOOP RQB_Loop ;Go back till done\r
+ MOV DWORD PTR [ESI+pNextRQB],0 ;Make last one nil\r
+ RETN ;\r
+\r
+;---------------------------------------------------------------\r
+; Allocate 2 pages (8192 bytes) for 128 Request Blocks (structures).\r
+; Then call InitFreeRQB\r
+\r
+PUBLIC InitDynamicRQBs:\r
+\r
+ PUSH 2 ; 2 pages for 128 RQBs\r
+ MOV EAX, OFFSET pRQBs ; Returns ptr to allocated mem in pRQBs\r
+ PUSH EAX ;\r
+ CALL FWORD PTR _AllocOSPage ; Get 'em!\r
+\r
+ XOR EAX, EAX ; Clear allocated memory for RQBs\r
+ MOV ECX, 2048 ; (8192)\r
+ MOV EDI, pRQBs ; where to store 0s\r
+ REP STOSD ; Do it\r
+\r
+ MOV EAX, pRQBs ; Ptr to RQBs\r
+ MOV ECX, nRQBs ; Count of Request Blocks\r
+ MOV EDX, sRQB ; EDX is size of a RQB\r
+ CALL InitFreeRQB ; Init the array of RQBs\r
+ RETN\r
+\r
+;---------------------------------\r
+PUBLIC NewRQB:\r
+; INPUT : NONE\r
+; OUTPUT : EAX\r
+; REGISTERS : EAX,EBX,FLAGS\r
+; MODIFIES : pFreeRQB\r
+;\r
+; This routine returns to the caller a pointer to the next free RQB.\r
+; The data used in this algorithm is the free jcb pointer (pFreeRQB).\r
+; This routine will return in EAX register the address of the next free jcb.\r
+; If none exists, then EAX will contain NIL (0). This routine will also\r
+; update the value of pFreeRQB to point to the next "unused" RQB in\r
+; the free pool.\r
+;\r
+ MOV EAX,pFreeRQB ;Get OS pointer to RQBs\r
+ CMP EAX, 0 ;IF pFreeRQB=NIL THEN Return;\r
+ JE NewRQBDone ;\r
+ MOV EBX,[EAX+pNextRQB] ;Get pointer to next free one\r
+ MOV pFreeRQB,EBX ;Put it in OS pointer\r
+ DEC _nRQBLeft ;\r
+NewRQBDone:\r
+ RETN ;\r
+\r
+;=============================================================================\r
+\r
+PUBLIC DisposeRQB:\r
+; INPUT : EAX\r
+; OUTPUT : NONE\r
+; REGISTERS : EAX, EBX, FLAGS\r
+; MODIFIES : pFreeRQB\r
+;\r
+; This routine will place the RQB pointed to by EAX back into the free\r
+; pool of RQBs pointed to by (pFreeRQB) if EAX is not NIL.\r
+;\r
+ CMP EAX, 0 ; If pJQBin = NIL THEN Return;\r
+ JE DispRQBDone ;\r
+ MOV EBX,pFreeRQB ;EBX has OS ptr to free list\r
+ MOV [EAX+pNextRQB],EBX ;Move it into newly freed RQB\r
+ MOV pFreeRQB,EAX ;Move ptr to newly frred RQB to OS\r
+ INC DWORD PTR _nRQBLeft ;\r
+DispRQBDone:\r
+ RETN ;\r
+\r
+;========================= End of Module =================================\r