support for PnP disks, part 5: FAT12, ramdisk, floppies

git-svn-id: svn://kolibrios.org@4273 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
CleverMouse 2013-11-21 16:07:16 +00:00
parent 42203528ce
commit 1842871f8f
31 changed files with 2101 additions and 6010 deletions

View File

@ -290,7 +290,6 @@ CMM_PROGRAMS:=\
OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \ OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \
default.skn:DEFAULT.SKN \ default.skn:DEFAULT.SKN \
graph:GRAPH \ graph:GRAPH \
../common/hdread:HDREAD \
settings/icon.ini:SETTINGS/ICON.INI \ settings/icon.ini:SETTINGS/ICON.INI \
../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \ ../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \
kernel.mnt:KERNEL.MNT \ kernel.mnt:KERNEL.MNT \

View File

@ -112,7 +112,6 @@ CPUID /sys/cpuid
Ghost Monitor /sys/gmon Ghost Monitor /sys/gmon
K. Bus disconnected /sys/kbd K. Bus disconnected /sys/kbd
HDD informer /sys/hdd_info HDD informer /sys/hdd_info
Read HDD /sys/hdread
#13 **** WORK WITH FILES **** #13 **** WORK WITH FILES ****
KFAR /sys/File Managers/kfar KFAR /sys/File Managers/kfar
KFM /sys/File Managers/kfm KFM /sys/File Managers/kfm

View File

@ -290,7 +290,6 @@ CMM_PROGRAMS:=\
OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \ OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \
default.skn:DEFAULT.SKN \ default.skn:DEFAULT.SKN \
graph:GRAPH \ graph:GRAPH \
../common/hdread:HDREAD \
settings/icon.ini:SETTINGS/ICON.INI \ settings/icon.ini:SETTINGS/ICON.INI \
../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \ ../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \
kernel.mnt:KERNEL.MNT \ kernel.mnt:KERNEL.MNT \

View File

@ -112,7 +112,6 @@ CPUID /sys/cpuid
Ghost Monitor /sys/gmon Ghost Monitor /sys/gmon
K. Bus disconnected /sys/kbd K. Bus disconnected /sys/kbd
HDD info /sys/hdd_info HDD info /sys/hdd_info
Read HDD /sys/hdread
#13 **** WORK WITH FILES **** #13 **** WORK WITH FILES ****
KFAR /sys/File Managers/kfar KFAR /sys/File Managers/kfar
KFM /sys/File Managers/kfm KFM /sys/File Managers/kfm

View File

@ -289,7 +289,6 @@ CMM_PROGRAMS:=\
OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \ OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \
default.skn:DEFAULT.SKN \ default.skn:DEFAULT.SKN \
graph:GRAPH \ graph:GRAPH \
../common/hdread:HDREAD \
settings/icon.ini:SETTINGS/ICON.INI \ settings/icon.ini:SETTINGS/ICON.INI \
../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \ ../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \
kernel.mnt:KERNEL.MNT \ kernel.mnt:KERNEL.MNT \

View File

@ -111,7 +111,6 @@ CPUID /sys/cpuid
Ghost Monitor /sys/gmon Ghost Monitor /sys/gmon
K. Bus disconnected /sys/kbd K. Bus disconnected /sys/kbd
HDD informer /sys/hdd_info HDD informer /sys/hdd_info
Read HDD /sys/hdread
#13 **** WORK WITH FILES **** #13 **** WORK WITH FILES ****
KFAR /sys/File Managers/kfar KFAR /sys/File Managers/kfar
KFM /sys/File Managers/kfm KFM /sys/File Managers/kfm

View File

@ -283,7 +283,6 @@ CMM_PROGRAMS:=\
OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \ OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \
default.skn:DEFAULT.SKN \ default.skn:DEFAULT.SKN \
graph:GRAPH \ graph:GRAPH \
../common/hdread:HDREAD \
settings/icon.ini:SETTINGS/ICON.INI \ settings/icon.ini:SETTINGS/ICON.INI \
../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \ ../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \
kernel.mnt:KERNEL.MNT \ kernel.mnt:KERNEL.MNT \

View File

@ -116,7 +116,6 @@ CPUID /sys/cpuid
GHOST Monitor /sys/gmon GHOST Monitor /sys/gmon
K. Bus disconnected /sys/kbd K. Bus disconnected /sys/kbd
HDD ¨­ä®à¬¥à /sys/hdd_info HDD ¨­ä®à¬¥à /sys/hdd_info
<EFBFBD>皀⑧<EFBFBD> HDD /sys/hdread
#13 **** ‘¨á⥬  -> <20> ¡®â  á ä ©« ¬¨ **** #13 **** ‘¨á⥬  -> <20> ¡®â  á ä ©« ¬¨ ****
KFM /sys/File Managers/kfm KFM /sys/File Managers/kfm
KFAR /sys/File Managers/kfar KFAR /sys/File Managers/kfar

View File

@ -289,7 +289,6 @@ CMM_PROGRAMS:=\
OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \ OTHER_FILES:=settings/autorun.dat:SETTINGS/AUTORUN.DAT \
default.skn:DEFAULT.SKN \ default.skn:DEFAULT.SKN \
graph:GRAPH \ graph:GRAPH \
../common/hdread:HDREAD \
settings/icon.ini:SETTINGS/ICON.INI \ settings/icon.ini:SETTINGS/ICON.INI \
../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \ ../common/iconstrp.png:ICONSTRP.PNG index_htm:INDEX.HTM \
kernel.mnt:KERNEL.MNT \ kernel.mnt:KERNEL.MNT \

View File

@ -112,7 +112,6 @@ CPUID /sys/cpuid
Ghost Monitor /sys/gmon Ghost Monitor /sys/gmon
K. Bus desconectado /sys/kbd K. Bus desconectado /sys/kbd
Informaci¢n de HDD /sys/hdd_info Informaci¢n de HDD /sys/hdd_info
Leer HDD /sys/hdread
#13 **** ARCHIVOS **** #13 **** ARCHIVOS ****
KFAR /sys/File Managers/kfar KFAR /sys/File Managers/kfar
KFM /sys/File Managers/kfm KFM /sys/File Managers/kfm

View File

@ -1213,7 +1213,39 @@ fs_dyndisk_next_nomedia:
; ecx = partition number, esi+ebp = ASCIIZ name ; ecx = partition number, esi+ebp = ASCIIZ name
fs_dyndisk: fs_dyndisk:
dec ecx ; convert to zero-based partition index dec ecx ; convert to zero-based partition index
pop edx edx edx eax ; edx = pointer to DISK, eax = NULL or edx pop edx edx edx ; edx = pointer to DISK, dword [esp] = NULL or edx
; If the driver does not support insert notifications and we are the only fs
; operation with this disk, ask the driver whether the media
; was inserted/removed/changed. Otherwise, assume that media status is valid.
test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION
jz .media_accurate
push ecx esi
mov esi, edx
cmp dword [esp+8], 0
jz .test_no_media
cmp [esi+DISK.MediaRefCount], 2
jnz .media_accurate_pop
lea edx, [esi+DISK.MediaInfo]
and [edx+DISKMEDIAINFO.Flags], 0
mov al, DISKFUNC.querymedia
stdcall disk_call_driver, edx
test eax, eax
jz .media_accurate_pop
stdcall disk_media_dereference ; drop our reference so that disk_media_changed could close the media
stdcall disk_media_changed, esi, 0
and dword [esp+8], 0 ; no media
.test_no_media:
stdcall disk_media_changed, esi, 1 ; issue fake notification
; if querymedia() inside disk_media_changed returns error, the notification is ignored
cmp [esi+DISK.MediaInserted], 0
jz .media_accurate_pop
lock inc [esi+DISK.MediaRefCount]
mov dword [esp+8], esi
.media_accurate_pop:
mov edx, esi
pop esi ecx
.media_accurate:
pop eax
test eax, eax test eax, eax
jz .nomedia jz .nomedia
.main: .main:
@ -1252,30 +1284,6 @@ fs_dyndisk:
.nomedia: .nomedia:
test ecx, ecx test ecx, ecx
jnz .notfound jnz .notfound
test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION
jz .deverror
; if the driver does not support insert notifications and we are the only fs
; operation with this disk, issue the fake insert notification; if media is
; still not inserted, 'disk_media_changed' will detect this and do nothing
lea ecx, [edx+DISK.MediaLock]
call mutex_lock
cmp [edx+DISK.MediaRefCount], 1
jnz .noluck
call mutex_unlock
push edx
stdcall disk_media_changed, edx, 1
pop edx
lea ecx, [edx+DISK.MediaLock]
call mutex_lock
cmp [edx+DISK.MediaInserted], 0
jz .noluck
lock inc [edx+DISK.MediaRefCount]
call mutex_unlock
xor ecx, ecx
jmp .main
.noluck:
call mutex_unlock
.deverror:
mov dword [esp+32], ERROR_DEVICE mov dword [esp+32], ERROR_DEVICE
mov esi, edx mov esi, edx
call disk_dereference call disk_dereference

View File

@ -21,40 +21,48 @@ fdc_init: ;start with clean tracks.
ret ret
save_image: save_image:
call reserve_flp cmp [ramdisk_actual_size], FLOPPY_CAPACITY
call restorefatchain jnz .fail
pusha pusha
call check_label mov ecx, floppy_mutex
call mutex_lock
mov [flp_number], bl
call floppy_read_bootsector
cmp [FDC_Status], 0 cmp [FDC_Status], 0
jne unnecessary_save_image jne .unnecessary_save_image
mov [FDD_Track], 0; Цилиндр mov [FDD_Track], 0; Цилиндр
mov [FDD_Head], 0; Сторона mov [FDD_Head], 0; Сторона
mov [FDD_Sector], 1; Сектор mov [FDD_Sector], 1; Сектор
mov esi, RAMDISK mov esi, RAMDISK
call SeekTrack call SeekTrack
save_image_1: .save_image_1:
push esi
call take_data_from_application_1 call take_data_from_application_1
pop esi
add esi, 512
call WriteSectWithRetr call WriteSectWithRetr
; call WriteSector ; call WriteSector
cmp [FDC_Status], 0 cmp [FDC_Status], 0
jne unnecessary_save_image jne .unnecessary_save_image
inc [FDD_Sector] inc [FDD_Sector]
cmp [FDD_Sector], 19 cmp [FDD_Sector], 19
jne save_image_1 jne .save_image_1
mov [FDD_Sector], 1 mov [FDD_Sector], 1
inc [FDD_Head] inc [FDD_Head]
cmp [FDD_Head], 2 cmp [FDD_Head], 2
jne save_image_1 jne .save_image_1
mov [FDD_Head], 0 mov [FDD_Head], 0
inc [FDD_Track] inc [FDD_Track]
call SeekTrack call SeekTrack
cmp [FDD_Track], 80 cmp [FDD_Track], 80
jne save_image_1 jne .save_image_1
unnecessary_save_image: .unnecessary_save_image:
cmp [FDC_Status], 0
pushf
mov ecx, floppy_mutex
call mutex_unlock
popf
popa popa
mov [flp_status], 0 jnz .fail
xor eax, eax
ret
.fail:
movi eax, 1
ret ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -20,8 +20,7 @@ $Revision$
; add edi,ecx ; add edi,ecx
give_back_application_data_1: give_back_application_data_1:
mov esi, FDD_BUFF;FDD_DataBuffer ;0x40000 mov esi, FDD_BUFF;FDD_DataBuffer ;0x40000
xor ecx, ecx mov ecx, 128
mov cx, 128
cld cld
rep movsd rep movsd
ret ret
@ -32,8 +31,7 @@ give_back_application_data_1:
; add esi,ecx ; add esi,ecx
take_data_from_application_1: take_data_from_application_1:
mov edi, FDD_BUFF;FDD_DataBuffer ;0x40000 mov edi, FDD_BUFF;FDD_DataBuffer ;0x40000
xor ecx, ecx mov ecx, 128
mov cx, 128
cld cld
rep movsd rep movsd
ret ret
@ -122,6 +120,7 @@ Init_FDC_DMA:
;* AL - выводимый байт. * ;* AL - выводимый байт. *
;*********************************** ;***********************************
FDCDataOutput: FDCDataOutput:
; DEBUGF 1,'K : FDCDataOutput(%x)',al
; pusha ; pusha
push eax ecx edx push eax ecx edx
mov AH, AL ;запомнить байт в AH mov AH, AL ;запомнить байт в AH
@ -137,6 +136,7 @@ FDCDataOutput:
je @@OutByteToFDC je @@OutByteToFDC
loop @@TestRS loop @@TestRS
; Ошибка тайм-аута ; Ошибка тайм-аута
; DEBUGF 1,' timeout\n'
mov [FDC_Status], FDC_TimeOut mov [FDC_Status], FDC_TimeOut
jmp @@End_5 jmp @@End_5
; Вывести байт в порт данных ; Вывести байт в порт данных
@ -144,6 +144,7 @@ FDCDataOutput:
inc DX inc DX
mov AL, AH mov AL, AH
out DX, AL out DX, AL
; DEBUGF 1,' ok\n'
@@End_5: @@End_5:
; popa ; popa
pop edx ecx eax pop edx ecx eax
@ -170,12 +171,14 @@ FDCDataInput:
je @@GetByteFromFDC je @@GetByteFromFDC
loop @@TestRS_1 loop @@TestRS_1
; Ошибка тайм-аута ; Ошибка тайм-аута
; DEBUGF 1,'K : FDCDataInput: timeout\n'
mov [FDC_Status], FDC_TimeOut mov [FDC_Status], FDC_TimeOut
jmp @@End_6 jmp @@End_6
; Ввести байт из порта данных ; Ввести байт из порта данных
@@GetByteFromFDC: @@GetByteFromFDC:
inc DX inc DX
in AL, DX in AL, DX
; DEBUGF 1,'K : FDCDataInput: %x\n',al
@@End_6: @@End_6:
pop DX pop DX
pop ECX pop ECX
@ -185,6 +188,7 @@ FDCDataInput:
;* ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ КОНТРОЛЛЕРА НГМД * ;* ОБРАБОТЧИК ПРЕРЫВАНИЯ ОТ КОНТРОЛЛЕРА НГМД *
;********************************************* ;*********************************************
FDCInterrupt: FDCInterrupt:
; dbgstr 'FDCInterrupt'
; Установить флаг прерывания ; Установить флаг прерывания
mov [FDD_IntFlag], 1 mov [FDD_IntFlag], 1
mov al, 1 mov al, 1
@ -207,12 +211,12 @@ WaitFDCInterrupt:
jnz @@End_7 ;прерывание произошло jnz @@End_7 ;прерывание произошло
mov eax, [timer_ticks] mov eax, [timer_ticks]
sub eax, [TickCounter] sub eax, [TickCounter]
cmp eax, 50 ;25 ;5 ;ожидать 5 тиков cmp eax, 200;50 ;25 ;5 ;ожидать 5 тиков
jb @@TestRS_2 jb @@TestRS_2
; jl @@TestRS_2 ; jl @@TestRS_2
; Ошибка тайм-аута ; Ошибка тайм-аута
; dbgstr 'WaitFDCInterrupt: timeout'
mov [FDC_Status], FDC_TimeOut mov [FDC_Status], FDC_TimeOut
; mov [flp_status],0
@@End_7: @@End_7:
popa popa
ret ret
@ -221,6 +225,7 @@ WaitFDCInterrupt:
;* ВКЛЮЧИТЬ МОТОР ДИСКОВОДА "A:" * ;* ВКЛЮЧИТЬ МОТОР ДИСКОВОДА "A:" *
;********************************* ;*********************************
FDDMotorON: FDDMotorON:
; dbgstr 'FDDMotorON'
pusha pusha
; cmp [fdd_motor_status],1 ; cmp [fdd_motor_status],1
; je fdd_motor_on ; je fdd_motor_on
@ -252,6 +257,20 @@ FDDMotorON_1:
sub eax, [TickCounter] sub eax, [TickCounter]
cmp eax, 50 ;10 cmp eax, 50 ;10
jb @@dT jb @@dT
; Read results of RESET command
push 4
; DEBUGF 1,'K : floppy reset results:'
@@:
mov al, 8
call FDCDataOutput
call FDCDataInput
; DEBUGF 1,' %x',al
call FDCDataInput
; DEBUGF 1,' %x',al
dec dword [esp]
jnz @b
; DEBUGF 1,'\n'
pop eax
cmp [flp_number], 1 cmp [flp_number], 1
jne fdd_motor_on_B jne fdd_motor_on_B
mov [fdd_motor_status], 1 mov [fdd_motor_status], 1
@ -275,8 +294,6 @@ save_timer_fdd_motor:
;* ПРОВЕРКА ЗАДЕРЖКИ ВЫКЛЮЧЕНИЯ МОТОРА * ;* ПРОВЕРКА ЗАДЕРЖКИ ВЫКЛЮЧЕНИЯ МОТОРА *
;***************************************** ;*****************************************
proc check_fdd_motor_status_has_work? proc check_fdd_motor_status_has_work?
cmp [flp_status], 0
jnz .yes
cmp [fdd_motor_status], 0 cmp [fdd_motor_status], 0
jz .no jz .no
mov eax, [timer_ticks] mov eax, [timer_ticks]
@ -303,7 +320,6 @@ check_fdd_motor_status:
call FDDMotorOFF call FDDMotorOFF
mov [fdd_motor_status], 0 mov [fdd_motor_status], 0
end_check_fdd_motor_status_1: end_check_fdd_motor_status_1:
mov [flp_status], 0
end_check_fdd_motor_status: end_check_fdd_motor_status:
ret ret
@ -311,6 +327,7 @@ end_check_fdd_motor_status:
;* ВЫКЛЮЧИТЬ МОТОР ДИСКОВОДА * ;* ВЫКЛЮЧИТЬ МОТОР ДИСКОВОДА *
;********************************** ;**********************************
FDDMotorOFF: FDDMotorOFF:
; dbgstr 'FDDMotorOFF'
push AX push AX
push DX push DX
cmp [flp_number], 1 cmp [flp_number], 1
@ -323,8 +340,8 @@ FDDMotorOFF_2:
pop DX pop DX
pop AX pop AX
; сброс флагов кеширования в связи с устареванием информации ; сброс флагов кеширования в связи с устареванием информации
mov [root_read], 0 or [floppy_media_flags+0], FLOPPY_MEDIA_NEED_RESCAN
mov [flp_fat], 0 or [floppy_media_flags+1], FLOPPY_MEDIA_NEED_RESCAN
ret ret
FDDMotorOFF_A: FDDMotorOFF_A:
@ -343,8 +360,11 @@ FDDMotorOFF_B:
;* РЕКАЛИБРОВКА ДИСКОВОДА "A:" * ;* РЕКАЛИБРОВКА ДИСКОВОДА "A:" *
;******************************* ;*******************************
RecalibrateFDD: RecalibrateFDD:
; dbgstr 'RecalibrateFDD'
pusha pusha
call save_timer_fdd_motor call save_timer_fdd_motor
; Сбросить флаг прерывания
mov [FDD_IntFlag], 0
; Подать команду "Рекалибровка" ; Подать команду "Рекалибровка"
mov AL, 07h mov AL, 07h
call FDCDataOutput call FDCDataOutput
@ -352,10 +372,18 @@ RecalibrateFDD:
call FDCDataOutput call FDCDataOutput
; Ожидать завершения операции ; Ожидать завершения операции
call WaitFDCInterrupt call WaitFDCInterrupt
; cmp [FDC_Status],0 cmp [FDC_Status], 0
; je no_fdc_status_error jne .fail
; mov [flp_status],0 ; Read results of RECALIBRATE command
;no_fdc_status_error: ; DEBUGF 1,'K : floppy recalibrate results:'
mov al, 8
call FDCDataOutput
call FDCDataInput
; DEBUGF 1,' %x',al
call FDCDataInput
; DEBUGF 1,' %x',al
; DEBUGF 1,'\n'
.fail:
call save_timer_fdd_motor call save_timer_fdd_motor
popa popa
ret ret
@ -368,6 +396,7 @@ RecalibrateFDD:
;* Результат операции заносится в FDC_Status. * ;* Результат операции заносится в FDC_Status. *
;***************************************************** ;*****************************************************
SeekTrack: SeekTrack:
; dbgstr 'SeekTrack'
pusha pusha
call save_timer_fdd_motor call save_timer_fdd_motor
; Сбросить флаг прерывания ; Сбросить флаг прерывания
@ -402,17 +431,20 @@ SeekTrack:
cmp AL, [FDD_Track] cmp AL, [FDD_Track]
jne @@Err jne @@Err
; Номер головки совпадает с заданным? ; Номер головки совпадает с заданным?
mov AL, [FDC_ST0] ; The H bit (Head Address) in ST0 will always return a "0" (c) 82077AA datasheet,
and AL, 100b ; description of SEEK command. So we can not verify the proper head.
shr AL, 2 ; mov AL, [FDC_ST0]
cmp AL, [FDD_Head] ; and AL, 100b
jne @@Err ; shr AL, 2
; cmp AL, [FDD_Head]
; jne @@Err
; Операция завершена успешно ; Операция завершена успешно
; dbgstr 'SeekTrack: FDC_Normal'
mov [FDC_Status], FDC_Normal mov [FDC_Status], FDC_Normal
jmp @@Exit jmp @@Exit
@@Err: ; Трек не найден @@Err: ; Трек не найден
; dbgstr 'SeekTrack: FDC_TrackNotFound'
mov [FDC_Status], FDC_TrackNotFound mov [FDC_Status], FDC_TrackNotFound
; mov [flp_status],0
@@Exit: @@Exit:
call save_timer_fdd_motor call save_timer_fdd_motor
popa popa
@ -429,6 +461,7 @@ SeekTrack:
;* содержимое сектора будет занесено в FDD_DataBuffer. * ;* содержимое сектора будет занесено в FDD_DataBuffer. *
;******************************************************* ;*******************************************************
ReadSector: ReadSector:
; dbgstr 'ReadSector'
pushad pushad
call save_timer_fdd_motor call save_timer_fdd_motor
; Сбросить флаг прерывания ; Сбросить флаг прерывания
@ -468,11 +501,12 @@ ReadSector:
call GetStatusInfo call GetStatusInfo
test [FDC_ST0], 11011000b test [FDC_ST0], 11011000b
jnz @@Err_1 jnz @@Err_1
; dbgstr 'ReadSector: FDC_Normal'
mov [FDC_Status], FDC_Normal mov [FDC_Status], FDC_Normal
jmp @@Exit_1 jmp @@Exit_1
@@Err_1: @@Err_1:
; dbgstr 'ReadSector: FDC_SectorNotFound'
mov [FDC_Status], FDC_SectorNotFound mov [FDC_Status], FDC_SectorNotFound
; mov [flp_status],0
@@Exit_1: @@Exit_1:
call save_timer_fdd_motor call save_timer_fdd_motor
popad popad
@ -511,12 +545,10 @@ ReadSectWithRetr:
inc [RecalRepCounter] inc [RecalRepCounter]
cmp [RecalRepCounter], 3 cmp [RecalRepCounter], 3
jb @@TryAgain jb @@TryAgain
; mov [flp_status],0
@@Exit_2: @@Exit_2:
popa popa
ret ret
@@Err_3: @@Err_3:
mov [flp_status], 0
popa popa
ret ret
@ -531,6 +563,7 @@ ReadSectWithRetr:
;* содержимое FDD_DataBuffer будет занесено в сектор. * ;* содержимое FDD_DataBuffer будет занесено в сектор. *
;******************************************************* ;*******************************************************
WriteSector: WriteSector:
; dbgstr 'WriteSector'
pushad pushad
call save_timer_fdd_motor call save_timer_fdd_motor
; Сбросить флаг прерывания ; Сбросить флаг прерывания
@ -616,7 +649,6 @@ WriteSectWithRetr:
popa popa
ret ret
@@Err_4: @@Err_4:
mov [flp_status], 0
popa popa
ret ret
@ -642,3 +674,276 @@ GetStatusInfo:
pop AX pop AX
ret ret
; Interface for disk subsystem.
; Assume fixed capacity for 1.44M.
FLOPPY_CAPACITY = 2880 ; in sectors
iglobal
align 4
floppy_functions:
dd .size
dd 0 ; no close() function
dd 0 ; no closemedia() function
dd floppy_querymedia
dd floppy_read
dd floppy_write
dd 0 ; no flush() function
dd 0 ; no adjust_cache_size() function
.size = $ - floppy_functions
endg
uglobal
floppy_media_flags rb 2
n_sector dd 0 ; temporary save for sector value
flp_number db 0 ; 1- Floppy A, 2-Floppy B
old_track db 0 ; old value track
flp_label rb 15*2 ; Label and ID of inserted floppy disk
align 4
; Hardware does not allow to work with two floppies in parallel,
; so there is one mutex guarding access to any floppy.
floppy_mutex MUTEX
endg
; Meaning of bits in floppy_media_flags
FLOPPY_MEDIA_PRESENT = 1 ; media was present when last asked
FLOPPY_MEDIA_NEED_RESCAN = 2 ; media was possibly changed, need to rescan
FLOPPY_MEDIA_LABEL_CHANGED = 4 ; temporary state
iglobal
floppy1_name db 'fd',0
floppy2_name db 'fd2',0
endg
; This function is called in boot process.
; It creates filesystems /fd and/or /fd2, if the system has one/two floppy drives.
proc floppy_init
mov ecx, floppy_mutex
call mutex_init
; First floppy is present if [DRIVE_DATA] and 0xF0 is nonzero.
test byte [DRIVE_DATA], 0xF0
jz .no1
stdcall disk_add, floppy_functions, floppy1_name, 1, DISK_NO_INSERT_NOTIFICATION
.no1:
; Second floppy is present if [DRIVE_DATA] and 0x0F is nonzero.
test byte [DRIVE_DATA], 0x0F
jz .no2
stdcall disk_add, floppy_functions, floppy2_name, 2, DISK_NO_INSERT_NOTIFICATION
.no2:
ret
endp
; Returns information about disk media.
; Floppy drives do not support insert notifications,
; DISK_NO_INSERT_NOTIFICATION is set,
; the disk subsystem calls this function before each filesystem operation.
; If the media has changed, return error for the first call as signal
; to finalize work with old media and the true geometry for the second call.
; Assume that media is (possibly) changed anytime when motor is off.
proc floppy_querymedia
virtual at esp+4
.userdata dd ?
.info dd ?
end virtual
; 1. Acquire the global lock.
mov ecx, floppy_mutex
call mutex_lock
mov edx, [.userdata] ; 1 for /fd, 2 for /fd2
; 2. If the media was reported and has been changed, forget it and report an error.
mov al, [floppy_media_flags+edx-1]
and al, FLOPPY_MEDIA_PRESENT + FLOPPY_MEDIA_NEED_RESCAN
cmp al, FLOPPY_MEDIA_PRESENT + FLOPPY_MEDIA_NEED_RESCAN
jnz .not_reported
.no_media:
mov [floppy_media_flags+edx-1], 0
.return_no_media:
mov ecx, floppy_mutex
call mutex_unlock
mov eax, DISK_STATUS_NO_MEDIA
retn 8
.not_reported:
; 3. If we are in the temporary state LABEL_CHANGED, this is the second call
; after intermediate DISK_STATUS_NO_MEDIA due to media change;
; clear the flag and return the current geometry without rereading the bootsector.
cmp [floppy_media_flags+edx-1], FLOPPY_MEDIA_LABEL_CHANGED
jz .report_geometry
; 4. Try to read the bootsector.
mov [flp_number], dl
mov [FDC_Status], 0
call floppy_read_bootsector
; 5. If reading bootsector failed, assume that media is not present.
mov edx, [.userdata]
cmp [FDC_Status], 0
jnz .no_media
; 6. Check whether the previous status is "present". If not, go to 10.
push esi edi
imul edi, edx, 15
add edi, flp_label-15
mov esi, FDD_BUFF+39
mov ecx, 15
test [floppy_media_flags+edx-1], FLOPPY_MEDIA_PRESENT
jz .set_label
; 7. Compare the old label with the current one.
rep cmpsb
; 8. If the label has not changed, go to 11.
jz .ok
; 9. If the label has changed, store it, enter temporary state LABEL_CHANGED
; and report DISK_STATUS_NO_MEDIA.
; dbgstr 'floppy label changed'
add esi, ecx
add edi, ecx
mov ecx, 15
sub esi, ecx
sub edi, ecx
rep movsb
mov [floppy_media_flags+edx-1], FLOPPY_MEDIA_LABEL_CHANGED
pop edi esi
jmp .return_no_media
.set_label:
; 10. The previous state was "not present". Copy the label.
rep movsb
.ok:
pop edi esi
.report_geometry:
; 11. Fill DISKMEDIAINFO structure.
mov ecx, [.info]
and [ecx+DISKMEDIAINFO.Flags], 0
mov [ecx+DISKMEDIAINFO.SectorSize], 512
mov dword [ecx+DISKMEDIAINFO.Capacity], FLOPPY_CAPACITY
and dword [ecx+DISKMEDIAINFO.Capacity+4], 0
; 12. Update state: media is present, data are actual.
mov [floppy_media_flags+edx-1], FLOPPY_MEDIA_PRESENT
; 13. Release the global lock and return successful status.
mov ecx, floppy_mutex
call mutex_unlock
xor eax, eax
retn 8
endp
proc floppy_read_bootsector
pushad
mov [FDD_Track], 0; Цилиндр
mov [FDD_Head], 0; Сторона
mov [FDD_Sector], 1; Сектор
call FDDMotorON
call RecalibrateFDD
cmp [FDC_Status], 0
jne .nothing
call SeekTrack
cmp [FDC_Status], 0
jne .nothing
call ReadSectWithRetr
.nothing:
popad
ret
endp
read_chs_sector:
call calculate_chs
call ReadSectWithRetr
ret
save_chs_sector:
call calculate_chs
call WriteSectWithRetr
ret
calculate_chs:
mov bl, [FDD_Track]
mov [old_track], bl
mov ebx, 18
xor edx, edx
div ebx
inc edx
mov [FDD_Sector], dl
mov edx, eax
shr eax, 1
and edx, 1
mov [FDD_Track], al
mov [FDD_Head], dl
mov dl, [old_track]
cmp dl, [FDD_Track]
je no_seek_track_1
call SeekTrack
no_seek_track_1:
ret
; Writes one or more sectors to the device.
proc floppy_write
mov dl, 1
jmp floppy_read_write
endp
; Reads one or more sectors from the device.
proc floppy_read
mov dl, 0
endp
; Common part of floppy_read and floppy_write.
proc floppy_read_write userdata:dword, buffer:dword, start_sector:qword, numsectors_ptr:dword
virtual at ebp-8
.sectors_todo dd ?
.operation db ?
end virtual
push edx ; save operation code to [.operation]
; 1. Get number of sectors to read/write
; and zero number of sectors that were actually read/written.
mov eax, [numsectors_ptr]
push dword [eax] ; initialize [.sectors_todo]
and dword [eax], 0
push ebx esi edi ; save used registers to be stdcall
; 2. Acquire the global lock.
mov ecx, floppy_mutex
call mutex_lock
; 3. Set floppy number for this operation.
mov edx, [userdata]
mov [flp_number], dl
; 4. Read/write sector-by-sector.
.operation_loop:
; 4a. Check that the sector is inside the media.
cmp dword [start_sector+4], 0
jnz .end_of_media
mov eax, dword [start_sector]
cmp eax, FLOPPY_CAPACITY
jae .end_of_media
; 4b. For read operation, call read_chs_sector and then move data from FDD_BUFF to [buffer].
; For write operation, move data from [buffer] to FDD_BUFF and then call save_chs_sector.
cmp [.operation], 0
jz .read
mov esi, [buffer]
mov edi, FDD_BUFF
mov ecx, 512/4
rep movsd
mov [buffer], esi
call save_chs_sector
jmp @f
.read:
call read_chs_sector
mov esi, FDD_BUFF
mov edi, [buffer]
mov ecx, 512/4
rep movsd
mov [buffer], edi
@@:
; 4c. If there was an error, propagate it to the caller.
cmp [FDC_Status], 0
jnz .fail
; 4d. Otherwise, increment number of sectors processed and continue the loop.
mov eax, [numsectors_ptr]
inc dword [eax]
inc dword [start_sector]
dec [.sectors_todo]
jnz .operation_loop
; 5. Release the global lock and return with the correct status.
push 0
.return:
mov ecx, floppy_mutex
call mutex_unlock
pop eax
pop edi esi ebx ; restore used registers to be stdcall
ret ; this translates to leave/retn N and purges local variables
.fail:
push -1
jmp .return
.end_of_media:
push DISK_STATUS_END_OF_MEDIA
jmp .return
endp

View File

@ -47,6 +47,10 @@ hd0_data HD_DATA ?, 0, 1
hd1_data HD_DATA ?, 0x10, 2 hd1_data HD_DATA ?, 0x10, 2
hd2_data HD_DATA ?, 0, 3 hd2_data HD_DATA ?, 0, 3
hd3_data HD_DATA ?, 0x10, 4 hd3_data HD_DATA ?, 0x10, 4
hd_address_table:
dd 0x1f0, 0x00, 0x1f0, 0x10
dd 0x170, 0x00, 0x170, 0x10
endg endg
uglobal uglobal
@ -645,14 +649,6 @@ hd_write_error:
end if end if
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
hd_lba_error:
if lang eq sp
DEBUGF 1,"K : FS - HD error en LBA\n"
else
DEBUGF 1,"K : FS - HD LBA error\n"
end if
jmp LBA_read_ret
;-----------------------------------------------------------------------------
align 4 align 4
wait_for_hd_idle: wait_for_hd_idle:
push eax edx push eax edx

File diff suppressed because it is too large Load Diff

View File

@ -13,16 +13,19 @@ saverd_fileinfo:
dd 2 ; subfunction: write dd 2 ; subfunction: write
dd 0 ; (reserved) dd 0 ; (reserved)
dd 0 ; (reserved) dd 0 ; (reserved)
dd 1440*1024 ; size 1440 Kb .size:
dd 0
dd RAMDISK dd RAMDISK
db 0 db 0
.name: .name:
dd ? dd ?
endg endg
sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only) sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only)
call restorefatchain
mov ebx, saverd_fileinfo mov ebx, saverd_fileinfo
mov [saverd_fileinfo.name], ecx mov [ebx+21], ecx
mov eax, [ramdisk_actual_size]
shl eax, 9
mov [ebx+12], eax
pushad pushad
call file_system_lfn_protected ;in ebx call file_system_lfn_protected ;in ebx
popad popad

View File

@ -659,10 +659,6 @@ terminate: ; terminate application
jnz @f jnz @f
call free_cd_channel call free_cd_channel
and [cd_status], 0 and [cd_status], 0
@@:
cmp [flp_status], esi
jnz @f
and [flp_status], 0
@@: @@:
pop esi pop esi
cmp [bgrlockpid], esi cmp [bgrlockpid], esi

View File

@ -7,20 +7,6 @@
$Revision$ $Revision$
; Old style system call converter
align 16
cross_order:
; load all registers in crossed order
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, esi
mov esi, edi
movzx edi, byte[esp+28 + 4]
sub edi, 53
call dword [servetable+edi*4]
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; SYSENTER ENTRY ;; ;; SYSENTER ENTRY ;;
@ -109,24 +95,6 @@ iglobal
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SYSTEM FUNCTIONS TABLE ;; ;; SYSTEM FUNCTIONS TABLE ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
servetable:
dd 0
dd 0
dd 0
dd 0
dd 0
dd file_system ; 58-Common file system interface
dd 0
dd 0
dd 0
dd 0
dd 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NEW SYSTEM FUNCTIONS TABLE ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4 align 4
servetable2: servetable2:
@ -136,7 +104,7 @@ iglobal
dd sys_clock ; 3-GetTime dd sys_clock ; 3-GetTime
dd syscall_writetext ; 4-WriteText dd syscall_writetext ; 4-WriteText
dd delay_hs_unprotected ; 5-DelayHs dd delay_hs_unprotected ; 5-DelayHs
dd syscall_openramdiskfile ; 6-OpenRamdiskFile dd undefined_syscall ; 6-deprecated OpenRamdiskFile
dd syscall_putimage ; 7-PutImage dd syscall_putimage ; 7-PutImage
dd syscall_button ; 8-DefineButton dd syscall_button ; 8-DefineButton
dd sys_cpuusage ; 9-GetProcessInfo dd sys_cpuusage ; 9-GetProcessInfo
@ -188,7 +156,7 @@ iglobal
dd sound_interface ; 55-Sound interface dd sound_interface ; 55-Sound interface
dd undefined_syscall ; 56-reserved dd undefined_syscall ; 56-reserved
dd sys_pcibios ; 57-PCI BIOS32 dd sys_pcibios ; 57-PCI BIOS32
dd cross_order ; 58-Common file system interface dd undefined_syscall ; 58-deprecated Common file system interface
dd undefined_syscall ; 59-reserved dd undefined_syscall ; 59-reserved
dd sys_IPC ; 60-Inter Process Communication dd sys_IPC ; 60-Inter Process Communication
dd sys_gs ; 61-Direct graphics access dd sys_gs ; 61-Direct graphics access

View File

@ -51,7 +51,7 @@ keymap_alt:
if lang eq ru if lang eq ru
boot_initirq cp866 'Инициализация IRQ',0 boot_initirq cp866 'Инициализация IRQ',0
boot_picinit cp866 'Инициализация PIC',0 boot_picinit cp866 'Инициализация PIC',0
boot_v86machine cp866 'Инициализация системы V86 машины',0 boot_v86machine cp866 'Инициализация системной V86 машины',0
boot_inittimer cp866 'Инициализация системного таймера (IRQ0)',0 boot_inittimer cp866 'Инициализация системного таймера (IRQ0)',0
boot_initapic cp866 'Попытка инициализации APIC',0 boot_initapic cp866 'Попытка инициализации APIC',0
boot_enableirq cp866 'Включить прерывания 2, 13',0 boot_enableirq cp866 'Включить прерывания 2, 13',0
@ -69,6 +69,7 @@ if lang eq ru
boot_cpuid cp866 'Чтение CPUIDs',0 boot_cpuid cp866 'Чтение CPUIDs',0
; boot_devices cp866 'Поиск устройств',0 ; boot_devices cp866 'Поиск устройств',0
boot_timer cp866 'Установка таймера',0 boot_timer cp866 'Установка таймера',0
boot_initramdisk cp866 'Инициализация рамдиска',0
boot_irqs cp866 'Переопределение IRQ',0 boot_irqs cp866 'Переопределение IRQ',0
boot_setmouse cp866 'Установка мыши',0 boot_setmouse cp866 'Установка мыши',0
boot_windefs cp866 'Установка настроек окон по умолчанию',0 boot_windefs cp866 'Установка настроек окон по умолчанию',0
@ -98,6 +99,7 @@ else
boot_picinit db 'Initialize PIC',0 boot_picinit db 'Initialize PIC',0
boot_v86machine db 'Initialize system V86 machine',0 boot_v86machine db 'Initialize system V86 machine',0
boot_inittimer db 'Initialize system timer (IRQ0)',0 boot_inittimer db 'Initialize system timer (IRQ0)',0
boot_initramdisk db 'Initialize ramdisk',0
boot_initapic db 'Try to initialize APIC',0 boot_initapic db 'Try to initialize APIC',0
boot_enableirq db 'Enable interrupts 2, 13',0 boot_enableirq db 'Enable interrupts 2, 13',0
boot_disabling_ide db 'Disable interrupts in IDE controller',0 boot_disabling_ide db 'Disable interrupts in IDE controller',0
@ -172,7 +174,13 @@ end if
vmode db '/sys/drivers/VMODE.MDR',0 vmode db '/sys/drivers/VMODE.MDR',0
;vrr_m db 'VRR_M',0 ;vrr_m db 'VRR_M',0
kernel_file db 'KERNEL MNT' kernel_file_load:
; load kernel.mnt to 0x7000:0
dd 0 ; subfunction
dq 0 ; offset in file
dd 0x30000 ; number of bytes to read
dd 0x70000 ; buffer for data
db '/RD/1/KERNEL.MNT',0
dev_data_path db '/RD/1/DRIVERS/DEVICES.DAT',0 dev_data_path db '/RD/1/DRIVERS/DEVICES.DAT',0
@ -570,8 +578,7 @@ end if
org (OS_BASE+0x0100000) org (OS_BASE+0x0100000)
RAMDISK: rb 2880*512 RAMDISK: rb 2880*512
RAMDISK_FAT: rb 2856*2 rb 2856*4 ; not used
FLOPPY_FAT: rb 2856*2
_CLEAN_ZONE: _CLEAN_ZONE:

View File

@ -2,6 +2,7 @@
boot_picinit latin1 'Algväärtustan PIC',0 boot_picinit latin1 'Algväärtustan PIC',0
boot_v86machine latin1 'Algväärtustan süsteemi V86 masinat',0 boot_v86machine latin1 'Algväärtustan süsteemi V86 masinat',0
boot_inittimer latin1 'Algväärtustan süsteemi taimerit (IRQ0)',0 boot_inittimer latin1 'Algväärtustan süsteemi taimerit (IRQ0)',0
boot_initramdisk latin1 'Initialize ramdisk',0
boot_initapic latin1 'Proovin Algväärtustada APIC',0 boot_initapic latin1 'Proovin Algväärtustada APIC',0
boot_enableirq latin1 'Luban katkestused 2, 13',0 boot_enableirq latin1 'Luban katkestused 2, 13',0
boot_disabling_ide latin1 'Keelan IDE kontrolleri katkestused',0 boot_disabling_ide latin1 'Keelan IDE kontrolleri katkestused',0

View File

@ -2,6 +2,7 @@
boot_picinit: cp850 'Inicializar PIC',0 boot_picinit: cp850 'Inicializar PIC',0
boot_v86machine: cp850 'Inicializar sistema V86',0 boot_v86machine: cp850 'Inicializar sistema V86',0
boot_inittimer: cp850 'Inicializar reloj del sistema (IRQ0)',0 boot_inittimer: cp850 'Inicializar reloj del sistema (IRQ0)',0
boot_initramdisk cp850 'Initialize ramdisk',0
boot_initapic: cp850 'Prueba inicializar APIC',0 boot_initapic: cp850 'Prueba inicializar APIC',0
boot_enableirq: cp850 'Habilitar interrupciones 2, 13',0 boot_enableirq: cp850 'Habilitar interrupciones 2, 13',0
boot_disabling_ide:cp850 'Habiliar interrupciones en controladores IDE',0 boot_disabling_ide:cp850 'Habiliar interrupciones en controladores IDE',0

View File

@ -33,5 +33,6 @@ wait_cmos:
stdcall attach_int_handler, 6, FDCInterrupt, 0 stdcall attach_int_handler, 6, FDCInterrupt, 0
DEBUGF 1, "K : Set IDE IRQ6 return code %x\n", eax DEBUGF 1, "K : Set IDE IRQ6 return code %x\n", eax
call floppy_init
@@: @@:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
dir0:
db 'KÕVAKETAS '
db 'MÄLUKETAS '
db 'FLOPPIKETAS'
db 0
dir1:
db 'ESIMENE '
db 'TEINE '
db 'KOLAMS '
db 'NELJAS '
db 0

View File

@ -1,13 +0,0 @@
dir0:
db 'DISCO DURO '
db 'UNIDAD RAM '
db 'DISQUETE '
db 0
dir1:
db 'PRIMERO '
db 'SEGUNDO '
db 'TERCERO '
db 'CUARTO '
db 0

View File

@ -1,682 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ;;
;; System service for filesystem call ;;
;; (C) 2004 Ville Turjanmaa, License: GPL ;;
;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout (for LBA) - Mario79 ;;
;; 15.01.2005 get file size/attr/date, ;;
;; file_append (only for hd) - ATV ;;
;; 23.11.2004 test if hd/partition is set - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;;
;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
iglobal
if lang eq sp
include 'fs/fs-sp.inc'
else if lang eq et
include 'fs/fs-et.inc'
else
dir0:
db 'HARDDISK '
db 'RAMDISK '
db 'FLOPPYDISK '
db 0
dir1:
db 'FIRST '
db 'SECOND '
db 'THIRD '
db 'FOURTH '
db 0
end if
not_select_IDE db 0
hd_address_table:
dd 0x1f0,0x00,0x1f0,0x10
dd 0x170,0x00,0x170,0x10
endg
file_system:
; IN:
;
; eax = 0 ; read file /RamDisk/First 6
; eax = 8 ; lba read
; eax = 15 ; get_disk_info
;
; OUT:
;
; eax = 0 : read ok
; eax = 1 : no hd base and/or partition defined
; eax = 2 : function is unsupported for this FS
; eax = 3 : unknown FS
; eax = 4 : partition not defined at hd
; eax = 5 : file not found
; eax = 6 : end of file
; eax = 7 : memory pointer not in application area
; eax = 8 : disk full
; eax = 9 : fat table corrupted
; eax = 10 : access denied
; eax = 11 : disk error
;
; ebx = size
; \begin{diamond}[18.03.2006]
; for subfunction 16 (start application) error codes must be negative
; because positive values are valid PIDs
; so possible return values are:
; eax > 0 : process created, eax=PID
; -0x10 <= eax < 0 : -eax is filesystem error code:
; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined
; eax = -3 = 0xFFFFFFFD : unknown FS
; eax = -5 = 0xFFFFFFFB : file not found
; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file)
; eax = -9 = 0xFFFFFFF7 : fat table corrupted
; eax = -10 = 0xFFFFFFF6 : access denied
; -0x20 <= eax < -0x10: eax is process creation error code:
; eax = -0x20 = 0xFFFFFFE0 : too many processes
; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable
; eax = -0x1E = 0xFFFFFFE2 : no memory
; ebx is not changed
; \end{diamond}[18.03.2006]
; Extract parameters
; add eax, std_application_base_address ; abs start of info block
cmp dword [eax+0], 15; GET_DISK_INFO
je fs_info
cmp dword [CURRENT_TASK], 1; no memory checks for kernel requests
jz no_checks_for_kernel
mov edx, eax
cmp dword [eax+0], 1
jnz .usual_check
mov ebx, [eax+12]
; add ebx,std_application_base_address
mov ecx, [eax+8]
call check_region
test eax, eax
jnz area_in_app_mem
.error_output:
mov esi, buffer_failed
call sys_msg_board_str
; mov eax,7
mov dword [esp+36], 7
ret
iglobal
buffer_failed db 'K : Buffer check failed',13,10,0
endg
.usual_check:
cmp dword [eax+0], 0
mov ecx, 512
jnz .small_size
mov ecx, [eax+8]
shl ecx, 9
.small_size:
mov ebx, [eax+12]
; add ebx,std_application_base_address
call check_region
test eax, eax
jz .error_output
area_in_app_mem:
mov eax, edx
no_checks_for_kernel:
fs_read:
mov ebx, [eax+20] ; program wants root directory ?
test bl, bl
je fs_getroot
test bh, bh
jne fs_noroot
fs_getroot:
; \begin{diamond}[18.03.2006]
; root - only read is allowed
; other operations return "access denied", eax=10
; (execute operation returns eax=-10)
cmp dword [eax], 0
jz .read_root
mov dword [esp+36], 10
ret
.read_root:
; \end{diamond}[18.03.2006]
mov esi, dir0
mov edi, [eax+12]
; add edi,std_application_base_address
mov ecx, 11
push ecx
; cld ; already is
rep movsb
mov al, 0x10
stosb
add edi, 32-11-1
pop ecx
rep movsb
stosb
and dword [esp+36], 0; ok read
mov dword [esp+24], 32*2; size of root
ret
fs_info: ;start of code - Mihasik
push eax
cmp [eax+21], byte 'r'
je fs_info_r
cmp [eax+21], byte 'R'
je fs_info_r
mov eax, 3 ;if unknown disk
xor ebx, ebx
xor ecx, ecx
xor edx, edx
jmp fs_info1
fs_info_r:
call ramdisk_free_space;if ramdisk
mov ecx, edi ;free space in ecx
shr ecx, 9 ;free clusters
mov ebx, 2847 ;total clusters
mov edx, 512 ;cluster size
xor eax, eax ;always 0
fs_info1:
pop edi
mov [esp+36], eax
mov [esp+24], ebx ; total clusters on disk
mov [esp+32], ecx ; free clusters on disk
mov [edi], edx ; cluster size in bytes
ret ;end of code - Mihasik
fs_noroot:
push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run
push dword [eax+4] ; 512 block number to read
push dword [eax+8] ; bytes to write/append or 512 blocks to read
mov ebx, [eax+12]
; add ebx,std_application_base_address
push ebx ; abs start of return/save area
lea esi, [eax+20] ; abs start of dir + filename
mov edi, [eax+16]
; add edi,std_application_base_address ; abs start of work area
call expand_pathz
push edi ; dir start
push ebx ; name of file start
mov eax, [edi+1]
cmp eax, 'RD '
je fs_yesramdisk
cmp eax, 'RAMD'
jne fs_noramdisk
fs_yesramdisk:
cmp byte [edi+1+11], 0
je fs_give_dir1
mov eax, [edi+1+12]
cmp eax, '1 '
je fs_yesramdisk_first
cmp eax, 'FIRS'
jne fs_noramdisk
fs_yesramdisk_first:
cmp dword [esp+20], 8; LBA read ramdisk
jne fs_no_LBA_read_ramdisk
mov eax, [esp+16] ; LBA block to read
mov ecx, [esp+8] ; abs pointer to return area
call LBA_read_ramdisk
jmp file_system_return
fs_no_LBA_read_ramdisk:
cmp dword [esp+20], 0; READ
jne fs_noramdisk_read
mov eax, [esp+4] ; fname
add eax, 2*12+1
mov ebx, [esp+16] ; block start
inc ebx
mov ecx, [esp+12] ; block count
mov edx, [esp+8] ; return
mov esi, [esp+0]
sub esi, eax
add esi, 12+1 ; file name length
call fileread
jmp file_system_return
fs_noramdisk_read:
fs_noramdisk:
;********************************************************************
mov eax, [edi+1]
cmp eax, 'FD '
je fs_yesflpdisk
cmp eax, 'FLOP'
jne fs_noflpdisk
fs_yesflpdisk:
call reserve_flp
cmp byte [edi+1+11], 0
je fs_give_dir1
mov eax, [edi+1+12]
cmp eax, '1 '
je fs_yesflpdisk_first
cmp eax, 'FIRS'
je fs_yesflpdisk_first
cmp eax, '2 '
je fs_yesflpdisk_second
cmp eax, 'SECO'
jne fs_noflpdisk
jmp fs_yesflpdisk_second
fs_yesflpdisk_first:
mov [flp_number], 1
jmp fs_yesflpdisk_start
fs_yesflpdisk_second:
mov [flp_number], 2
fs_yesflpdisk_start:
cmp dword [esp+20], 0; READ
jne fs_noflpdisk_read
mov eax, [esp+4] ; fname
add eax, 2*12+1
mov ebx, [esp+16] ; block start
inc ebx
mov ecx, [esp+12] ; block count
mov edx, [esp+8] ; return
mov esi, [esp+0]
sub esi, eax
add esi, 12+1 ; file name length
call floppy_fileread
jmp file_system_return
fs_noflpdisk_read:
fs_noflpdisk:
;*****************************************************************
old_path_harddisk:
mov eax, [edi+1]
cmp eax, 'HD '
je fs_yesharddisk
cmp eax, 'HARD'
jne fs_noharddisk
fs_yesharddisk:
cmp dword [esp+20], 8; LBA read
jne fs_no_LBA_read
mov eax, [esp+16] ; LBA block to read
lea ebx, [edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH
mov ecx, [esp+8] ; abs pointer to return area
call LBA_read
jmp file_system_return
fs_no_LBA_read:
hd_err_return:
fs_noharddisk:
; \begin{diamond}[18.03.2006]
mov eax, 5 ; file not found
; а может быть, возвращать другой код ошибки?
mov ebx, [esp+24+24]; do not change ebx in application
; \end{diamond}[18.03.2006]
file_system_return:
add esp, 24
mov [esp+36], eax
mov [esp+24], ebx
ret
fs_give_dir1:
; \begin{diamond}[18.03.2006]
; /RD,/FD,/HD - only read is allowed
; other operations return "access denied", eax=10
; (execute operation returns eax=-10)
cmp dword [esp+20], 0
jz .read
add esp, 20
pop ecx
mov dword [esp+36], 10
ret
.read:
; \end{diamond}[18.03.2006]
mov al, 0x10
mov ebx, 1
mov edi, [esp+8]
mov esi, dir1
fs_d1_new:
mov ecx, 11
; cld
rep movsb
stosb
add edi, 32-11-1
dec ebx
jne fs_d1_new
add esp, 24
and dword [esp+36], 0; ok read
mov dword [esp+24], 32*1; dir/data size
ret
LBA_read_ramdisk:
cmp [lba_read_enabled], 1
je lbarrl1
xor ebx, ebx
mov eax, 2
ret
lbarrl1:
cmp eax, 18*2*80
jb lbarrl2
xor ebx, ebx
mov eax, 3
ret
lbarrl2:
pushad
call restorefatchain
mov edi, ecx
mov esi, eax
shl esi, 9
add esi, RAMDISK
mov ecx, 512/4
; cld
rep movsd
popad
xor ebx, ebx
xor eax, eax
ret
LBA_read:
; IN:
;
; eax = LBA block to read
; ebx = pointer to FIRST/SECOND/THIRD/FOURTH
; ecx = abs pointer to return area
cmp [lba_read_enabled], 1
je lbarl1
mov eax, 2
ret
lbarl1:
pushad
mov ecx, ide_mutex
call mutex_lock
popad
push eax
push ecx
mov edi, hd_address_table
mov esi, dir1
mov eax, [ebx]
mov edx, '1 '
mov ecx, 4
blar0:
cmp eax, [esi]
je blar2
cmp eax, edx
je blar2
inc edx
add edi, 8
add esi, 11
dec ecx
jnz blar0
mov eax, 1
mov ebx, 1
jmp LBA_read_ret
blar2:
mov eax, [edi+0]
mov ebx, [edi+4]
mov [hdbase], eax
mov [hdid], ebx
call wait_for_hd_idle
cmp [hd_error], 0
jne hd_lba_error
; eax = hd port
; ebx = set for primary (0x00) or slave (0x10)
cli
mov edx, eax
inc edx
xor eax, eax
out dx, al
inc edx
inc eax
out dx, al
inc edx
mov eax, [esp+4]
out dx, al
shr eax, 8
inc edx
out dx, al
shr eax, 8
inc edx
out dx, al
shr eax, 8
inc edx
and al, 1+2+4+8
add al, bl
add al, 128+64+32
out dx, al
inc edx
mov al, 20h
out dx, al
sti
call wait_for_sector_buffer
cmp [hd_error], 0
jne hd_lba_error
cli
mov edi, [esp+0]
mov ecx, 256
sub edx, 7
cld
rep insw
sti
xor eax, eax
xor ebx, ebx
LBA_read_ret:
mov [hd_error], 0
mov [hd1_status], 0
add esp, 2*4
pushad
mov ecx, ide_mutex
call mutex_unlock
popad
ret
expand_pathz:
; IN:
; esi = asciiz path & file
; edi = buffer for path & file name
; OUT:
; edi = directory & file : / 11 + / 11 + / 11 - zero terminated
; ebx = /file name - zero terminated
; esi = pointer after source
push eax
push ecx
push edi;[esp+0]
pathz_start:
mov byte [edi], '/'
inc edi
mov al, 32
mov ecx, 11
cld
rep stosb ; clear filename area
sub edi, 11
mov ebx, edi ; start of dir/file name
pathz_new_char:
mov al, [esi]
inc esi
cmp al, 0
je pathz_end
cmp al, '/'
jne pathz_not_path
cmp edi, ebx ; skip first '/'
jz pathz_new_char
lea edi, [ebx+11] ; start of next directory
jmp pathz_start
pathz_not_path:
cmp al, '.'
jne pathz_not_ext
lea edi, [ebx+8] ; start of extension
jmp pathz_new_char
pathz_not_ext:
cmp al, 'a'
jb pathz_not_low
cmp al, 'z'
ja pathz_not_low
sub al, 0x20 ; char to uppercase
pathz_not_low:
mov [edi], al
inc edi
mov eax, [esp+0] ; start_of_dest_path
add eax, 512 ; keep maximum path under 512 bytes
cmp edi, eax
jb pathz_new_char
pathz_end:
cmp ebx, edi ; if path end with '/'
jnz pathz_put_zero ; go back 1 level
sub ebx, 12
pathz_put_zero:
mov byte [ebx+11], 0
dec ebx ; include '/' char into file name
pop edi
pop ecx
pop eax
ret
;*******************************************
;* string to number
;* input eax - 4 byte string
;* output eax - number
;*******************************************
StringToNumber:
; ПЕРЕВОД СТРОКОВОГО ЧИСЛА В ЧИСЛОВОЙ ВИД
; Вход:
; EDI - адрес строки с числом. Конец числа отмечен кодом 0Dh
; Выход:
; CF - индикатор ошибок:
; 0 - ошибок нет;
; 1 - ошибка
; Если CF=0, то AX - число.
push bx
push cx
push dx
push edi
mov [partition_string], eax
mov edi, partition_string
xor cx, cx
i1:
mov al, [edi]
cmp al, 32;13
je i_exit
; cmp al,'0'
; jb err
; cmp al,'9'
; ja err
sub al, 48
shl cx, 1
jc error
mov bx, cx
shl cx, 1
jc error
shl cx, 1
jc error
add cx, bx
jc error
cbw
add cx, ax
jc error
i3:
inc edi
jmp i1
i_exit:
mov ax, cx
clc
i4:
movzx eax, ax
pop edi
pop dx
pop cx
pop bx
ret
error:
stc
jmp i4
partition_string:
dd 0
db 32

View File

@ -30,18 +30,6 @@ image_of_ebx EQU esp+20
iglobal iglobal
; in this table names must be in lowercase ; in this table names must be in lowercase
rootdirs: rootdirs:
db 2,'rd'
dd fs_OnRamdisk
dd fs_NextRamdisk
db 7,'ramdisk'
dd fs_OnRamdisk
dd fs_NextRamdisk
db 2,'fd'
dd fs_OnFloppy
dd fs_NextFloppy
db 10,'floppydisk'
dd fs_OnFloppy
dd fs_NextFloppy
;********************************************** ;**********************************************
db 3,'cd0' db 3,'cd0'
dd fs_OnCd0 dd fs_OnCd0
@ -60,10 +48,6 @@ rootdirs:
virtual_root_query: virtual_root_query:
dd fs_HasRamdisk
db 'rd',0
dd fs_HasFloppy
db 'fd',0
;********************************************** ;**********************************************
dd fs_HasCd0 dd fs_HasCd0
db 'cd0',0 db 'cd0',0
@ -436,72 +420,10 @@ file_system_lfn:
; ebp = 0 or pointer to rest of name from folder addressed by esi ; ebp = 0 or pointer to rest of name from folder addressed by esi
; out: [image_of_eax]=image of eax, [image_of_ebx]=image of ebx ; out: [image_of_eax]=image of eax, [image_of_ebx]=image of ebx
fs_OnRamdisk:
cmp ecx, 1
jnz file_system_lfn.notfound
mov eax, [ebx]
cmp eax, fs_NumRamdiskServices
jae .not_impl
mov ecx, [ebx+12]
mov edx, [ebx+16]
; add edx, std_application_base_address
add ebx, 4
call dword [fs_RamdiskServices + eax*4]
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
.not_impl:
mov dword [image_of_eax], 2 ; not implemented
ret
fs_NotImplemented: fs_NotImplemented:
mov eax, 2 mov eax, 2
ret ret
fs_RamdiskServices:
dd fs_RamdiskRead
dd fs_RamdiskReadFolder
dd fs_RamdiskRewrite
dd fs_RamdiskWrite
dd fs_RamdiskSetFileEnd
dd fs_RamdiskGetFileInfo
dd fs_RamdiskSetFileInfo
dd 0
dd fs_RamdiskDelete
dd fs_RamdiskCreateFolder
fs_NumRamdiskServices = ($ - fs_RamdiskServices)/4
fs_OnFloppy:
cmp ecx, 2
ja file_system_lfn.notfound
mov eax, [ebx]
cmp eax, fs_NumFloppyServices
jae fs_OnRamdisk.not_impl
call reserve_flp
mov [flp_number], cl
mov ecx, [ebx+12]
mov edx, [ebx+16]
; add edx, std_application_base_address
add ebx, 4
call dword [fs_FloppyServices + eax*4]
and [flp_status], 0
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
fs_FloppyServices:
dd fs_FloppyRead
dd fs_FloppyReadFolder
dd fs_FloppyRewrite
dd fs_FloppyWrite
dd fs_FloppySetFileEnd
dd fs_FloppyGetFileInfo
dd fs_FloppySetFileInfo
dd 0
dd fs_FloppyDelete
dd fs_FloppyCreateFolder
fs_NumFloppyServices = ($ - fs_FloppyServices)/4
;******************************************************* ;*******************************************************
fs_OnCd0: fs_OnCd0:
call reserve_cd call reserve_cd
@ -583,16 +505,6 @@ fs_CdServices:
dd fs_NotImplemented dd fs_NotImplemented
fs_NumCdServices = ($ - fs_CdServices)/4 fs_NumCdServices = ($ - fs_CdServices)/4
;*******************************************************
fs_HasRamdisk:
mov al, 1 ; we always have ramdisk
ret
fs_HasFloppy:
cmp byte [DRIVE_DATA], 0
setnz al
ret
;******************************************************* ;*******************************************************
fs_HasCd0: fs_HasCd0:
test byte [DRIVE_DATA+1], 10000000b test byte [DRIVE_DATA+1], 10000000b
@ -617,36 +529,6 @@ fs_HasCd3:
; out: CF=1 => no more partitions ; out: CF=1 => no more partitions
; CF=0 => eax=next partition number ; CF=0 => eax=next partition number
fs_NextRamdisk:
; we always have /rd/1
test eax, eax
stc
jnz @f
mov al, 1
clc
@@:
ret
fs_NextFloppy:
; we have /fd/1 iff (([DRIVE_DATA] and 0xF0) != 0) and /fd/2 iff (([DRIVE_DATA] and 0x0F) != 0)
test byte [DRIVE_DATA], 0xF0
jz .no1
test eax, eax
jnz .no1
inc eax
ret ; CF cleared
.no1:
test byte [DRIVE_DATA], 0x0F
jz .no2
cmp al, 2
jae .no2
mov al, 2
clc
ret
.no2:
stc
ret
;******************************************************* ;*******************************************************
fs_NextCd: fs_NextCd:
; we always have /cdX/1 ; we always have /cdX/1

View File

@ -759,9 +759,10 @@ no_mode_0x12:
; Initialize system timer (IRQ0) ; Initialize system timer (IRQ0)
call PIT_init call PIT_init
; CALCULATE FAT CHAIN FOR RAMDISK ; Register ramdisk file system
mov esi, boot_initramdisk
call calculatefatchain call boot_log
call ramdisk_init
mov esi, boot_initapic mov esi, boot_initapic
call boot_log call boot_log
@ -1333,8 +1334,8 @@ proc osloop_has_work?
jnz .yes jnz .yes
call stack_handler_has_work? call stack_handler_has_work?
jnz .yes jnz .yes
; call check_fdd_motor_status_has_work? call check_fdd_motor_status_has_work?
; jnz .yes jnz .yes
call check_ATAPI_device_event_has_work? call check_ATAPI_device_event_has_work?
jnz .yes jnz .yes
call check_lights_state_has_work? call check_lights_state_has_work?
@ -2673,29 +2674,14 @@ endg
align 4 align 4
sys_cachetodiskette: sys_cachetodiskette:
cmp ebx, 1 cmp ebx, 1
jne .no_floppy_a_save jb .no_floppy_save
mov [flp_number], 1
jmp .save_image_on_floppy
;--------------------------------------
align 4
.no_floppy_a_save:
cmp ebx, 2 cmp ebx, 2
jne .no_floppy_b_save ja .no_floppy_save
mov [flp_number], 2
;--------------------------------------
align 4
.save_image_on_floppy:
call save_image call save_image
mov [esp + 32], dword 0 mov [esp + 32], eax
cmp [FDC_Status], 0 ret
je .yes_floppy_save .no_floppy_save:
;--------------------------------------
align 4
.no_floppy_b_save:
mov [esp + 32], dword 1 mov [esp + 32], dword 1
;--------------------------------------
align 4
.yes_floppy_save:
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
uglobal uglobal
@ -5266,19 +5252,6 @@ align 4
align 4 align 4
syscall_openramdiskfile: ; OpenRamdiskFile
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, esi
mov esi, 12
call fileread
mov [esp+32], eax
ret
align 4
syscall_drawrect: ; DrawRect syscall_drawrect: ; DrawRect
mov edi, edx ; color + gradient mov edi, edx ; color + gradient
@ -5783,12 +5756,11 @@ yes_shutdown_param:
cli cli
if ~ defined extended_primary_loader if ~ defined extended_primary_loader
mov eax, kernel_file ; load kernel.mnt to 0x7000:0 ; load kernel.mnt to 0x7000:0
movi esi, 12 mov ebx, kernel_file_load
xor ebx, ebx pushad
or ecx, -1 call file_system_lfn
mov edx, OS_BASE+0x70000 popad
call fileread
mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0
mov edi, OS_BASE+0x40000 mov edi, OS_BASE+0x40000
@ -5802,8 +5774,6 @@ end if
; cld ; cld
; rep movsd ; rep movsd
call restorefatchain
call IRQ_mask_all call IRQ_mask_all
if 0 if 0

View File

@ -185,11 +185,9 @@ include "gui/button.inc"
include "blkdev/disk.inc" ; support for plug-n-play disks include "blkdev/disk.inc" ; support for plug-n-play disks
include "blkdev/disk_cache.inc" ; caching for plug-n-play disks include "blkdev/disk_cache.inc" ; caching for plug-n-play disks
include "fs/fs.inc" ; syscall
include "fs/fat32.inc" ; read / write for fat32 filesystem
include "fs/ntfs.inc" ; read / write for ntfs filesystem
include "fs/fat12.inc" ; read / write for fat12 filesystem
include "blkdev/rd.inc" ; ramdisk read /write include "blkdev/rd.inc" ; ramdisk read /write
include "fs/fat.inc" ; read / write for fat filesystem
include "fs/ntfs.inc" ; read / write for ntfs filesystem
include "fs/fs_lfn.inc" ; syscall, version 2 include "fs/fs_lfn.inc" ; syscall, version 2
include "fs/iso9660.inc" ; read for iso9660 filesystem CD include "fs/iso9660.inc" ; read for iso9660 filesystem CD
include "fs/ext2/ext2.asm" ; read / write for ext2 filesystem include "fs/ext2/ext2.asm" ; read / write for ext2 filesystem

View File

@ -198,8 +198,7 @@
; 0x800A0000 -> AFFFF screen access area ; 0x800A0000 -> AFFFF screen access area
; 0x800B0000 -> FFFFF bios rest in peace -area (320k) ? ; 0x800B0000 -> FFFFF bios rest in peace -area (320k) ?
; 0x80100000 -> 27FFFF diskette image (1m5) ; 0x80100000 -> 27FFFF diskette image (1m5)
; 0x80280000 -> 281FFF ramdisk fat (8k) ; 0x80280000 -> 283FFF free (16k)
; 0x80282000 -> 283FFF floppy fat (8k)
; ;
; 0x80284000 -> 28BFFF HDD DMA AREA (32k) ; 0x80284000 -> 28BFFF HDD DMA AREA (32k)
; 0x8028C000 -> 297FFF free (48k) ; 0x8028C000 -> 297FFF free (48k)