From 5db3c3adc1f5ca333bc71830082664f463162367 Mon Sep 17 00:00:00 2001
From: "Andrey Halyavin (halyavin)" <halyavin@land.ru>
Date: Tue, 21 Mar 2006 11:46:13 +0000
Subject: [PATCH] Kernel now waits only 5 seconds in order to deliver message
 to debugger. Fixed hd reservation and release. Changes from diamond.

git-svn-id: svn://kolibrios.org@63 a494cfbc-eb01-0410-851d-a64ba20cac60
---
 kernel/trunk/core/debug.inc |  4 ++++
 kernel/trunk/fs/fat32.inc   |  1 +
 kernel/trunk/fs/fs.inc      | 13 ++++++++-----
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/kernel/trunk/core/debug.inc b/kernel/trunk/core/debug.inc
index 5b4edf6189..3de3a3de2b 100644
--- a/kernel/trunk/core/debug.inc
+++ b/kernel/trunk/core/debug.inc
@@ -290,6 +290,8 @@ debugger_notify:
 ; interrupts remain disabled
 	mov	ebp, eax
 	shl	eax, 8
+	mov	edi, [timer_ticks]
+	add	edi, 500	; 5 sec timeout
 .1:
 	mov	edx, [0x80000+eax+0xBC]
 	test	edx, edx
@@ -313,6 +315,8 @@ debugger_notify:
 	pop	ecx
 	pop	ecx
 	pop	ecx
+	cmp	[timer_ticks], edi
+	jae	.ret
 	sti
 	call	change_task
 	cli
diff --git a/kernel/trunk/fs/fat32.inc b/kernel/trunk/fs/fat32.inc
index 79f0f607db..2a9fd2cdeb 100644
--- a/kernel/trunk/fs/fat32.inc
+++ b/kernel/trunk/fs/fat32.inc
@@ -1671,6 +1671,7 @@ file_read:
     jnz   fat_ok_for_reading
     xor   ebx,ebx
     mov   eax,ERROR_UNKNOWN_FS
+    mov   [hd1_status], ebx
     ret
 
   fat_ok_for_reading:
diff --git a/kernel/trunk/fs/fs.inc b/kernel/trunk/fs/fs.inc
index 7201e9df12..7d21821f84 100644
--- a/kernel/trunk/fs/fs.inc
+++ b/kernel/trunk/fs/fs.inc
@@ -523,8 +523,6 @@ choice_necessity_partition_1:
     jne   fs_noharddisk
 
   fs_yesharddisk:
-    call  reserve_hd1
-
     cmp   dword [esp+20],8      ; LBA read
     jne   fs_no_LBA_read
     mov   eax,[esp+16]          ; LBA block to read
@@ -537,6 +535,7 @@ choice_necessity_partition_1:
 
     cmp   byte [edi+1+11],0     ; directory read
     je    fs_give_dir1
+    call  reserve_hd1
  fs_for_new_semantic:
     call  choice_necessity_partition 
 
@@ -547,9 +546,13 @@ choice_necessity_partition_1:
 	neg	eax
 @@:	mov	ebx, [esp+24+24]
     cmp   [hdpos],0             ; is hd base set?
-    jz    file_system_return    ; no
+    jz    hd_err_return
     cmp   [fat32part],0         ; is partition set?
-    jz    file_system_return    ; no
+    jnz   @f
+hd_err_return:
+    and   [hd1_status], 0
+    jmp   file_system_return
+@@:
 
     cmp   dword [esp+20],0      ; READ
     jne   fs_noharddisk_read
@@ -899,7 +902,7 @@ LBA_read:
 
   lbarl1:
 
-;    call  reserve_hd1
+    call  reserve_hd1
 
     push  eax
     push  ecx