From 7dbba040179325c623f3fad5f17f26fec223a85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Wed, 3 Nov 2004 00:32:19 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20rajout=20de=20la=20fonction=20mbclean?= =?UTF-8?q?=20permettant=20de=20fusionner=20les=20espaces=20libres=20et=20?= =?UTF-8?q?cela=20de=20maniere=20systematique=20lors=20d'une=20liberation?= =?UTF-8?q?=20de=20m=C3=A9moire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noyau/mcb.asm | 74 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/noyau/mcb.asm b/noyau/mcb.asm index 0027064..a35ae65 100644 --- a/noyau/mcb.asm +++ b/noyau/mcb.asm @@ -9,7 +9,7 @@ include ..\include\mem.h include ..\include\divers.h start: -maxfunc equ 8 +maxfunc equ 9 jmp tsr ;Saute à la routine résidente nameed db 'MB' ;Nom drivers @@ -62,9 +62,66 @@ tables dw MBinit ;Table qui contient les adresses de toutes les fonctions de VI dw MBFind dw MBChown dw MBAlloc + dw MBclean FirstMB dw 0 +;Mise a nivo de la mémoire (jonction de blocs libre) +MBclean: + push ax bx dx es gs + mov bx,cs:firstmb + dec bx + dec bx + xor ax,ax + xor dx,dx +searchfree3: + mov gs,bx + cmp gs:[MB.Check],'NH' + jne erroronsearch + inc bx + inc bx + add bx,gs:[MB.Sizes] + cmp word ptr gs:[MB.Sizes],0 + je erroronsearch + cmp gs:[MB.Reference],Free + jne notfreeatall + cmp ax,0 + je notmeetafree + add dx,gs:[MB.Sizes] + mov word ptr gs:[MB.Check],0 + mov dword ptr gs:[MB.Names],0 + mov dword ptr gs:[MB.Names+4],0 + inc dx + inc dx + jmp nottrigered +notmeetafree: + xor dx,dx + mov ax,gs + jmp nottrigered +notfreeatall: + cmp ax,0 + je nottrigered + mov es,ax + add es:[MB.Sizes],dx + xor ax,ax +nottrigered: + cmp gs:[MB.IsNotLast],true + je searchfree3 + cmp ax,0 + je reallyfinish + mov es,ax + add es:[MB.Sizes],dx + mov es:[MB.IsNotLast],False +reallyfinish: + clc + pop gs es dx bx ax + ret +erroronsearch: + stc + pop gs es dx bx ax + ret + + ;Initialise les blocs de mémoire en prenant memorystart pour segment de base MBinit: push ax cx es @@ -95,7 +152,7 @@ notforfree: ;Libère le bloc de mémoire GS MBFree: - push bx es + push ax bx es mov bx,gs mov ax,bx dec bx @@ -129,12 +186,19 @@ searchtofree: mov dword ptr gs:[MB.Names+4],0 nottofree: cmp gs:[MB.IsNotLast],true - je searchtofree - pop es bx + je searchtofree + call MBclean + pop es bx ax ret wasfree: +pushad + mov ah,0Dh + mov cx,16 + mov dx,1999h + int 47h +popad stc - pop es bx + pop es bx ax ret ;Change le proprietaire de GS a dx