Subversion Repositories Kolibri OS

Rev

Rev 8089 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
5363 yogev_ezra 3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
$Revision: 8091 $
9
 
10
 
3742 clevermous 11
read_ramdisk:
4772 mario79 12
; READ RAMDISK IMAGE FROM HD (only for IDE0, IDE1, IDE2, IDE3)
2288 clevermous 13
 
8089 dunkaist 14
        cmp     byte [BOOT.rd_load_from], RD_LOAD_FROM_HD
4772 mario79 15
        jne     no_sys_on_hd.1
2288 clevermous 16
 
3742 clevermous 17
        xor     ebp, ebp
18
.hd_loop:
19
        lea     eax, [ebp+'0']
20
        mov     [read_image_fsinfo.name_digit], al
21
        movzx   eax, byte [DRIVE_DATA+2+ebp]
22
        test    eax, eax
23
        jz      .next_hd
24
        push    eax
25
        mov     esi, 1
26
.partition_loop:
27
        mov     eax, esi
28
        push    -'0'
29
@@:
30
        xor     edx, edx
31
        div     [_10]
32
        push    edx
33
        test    eax, eax
34
        jnz     @b
35
        mov     edi, read_image_fsinfo.partition
36
@@:
37
        pop     eax
38
        add     al, '0'
39
        stosb
40
        jnz     @b
41
        mov     byte [edi-1], '/'
42
        push    esi edi
43
        mov     esi, bootpath1
44
        mov     ecx, bootpath1.len
45
        rep movsb
2288 clevermous 46
        call    read_image
47
        test    eax, eax
3742 clevermous 48
        jz      .yes
49
        cmp     eax, 6
50
        jz      .yes
51
        pop     edi
52
        push    edi
53
        mov     esi, bootpath2
54
        mov     ecx, bootpath2.len
55
        rep movsb
2288 clevermous 56
        call    read_image
57
        test    eax, eax
3742 clevermous 58
        jz      .yes
59
        cmp     eax, 6
60
        jz      .yes
61
        pop     edi esi
62
        inc     esi
63
        cmp     esi, [esp]
64
        jbe     .partition_loop
65
        pop     eax
66
.next_hd:
67
        inc     ebp
68
        cmp     ebp, 4
69
        jb      .hd_loop
70
        jmp     no_sys_on_hd
71
.yes:
4772 mario79 72
        DEBUGF 1, "K : RD found: %s\n", read_image_fsinfo.name
3742 clevermous 73
        pop     edi esi eax
4772 mario79 74
 
75
        call    register_ramdisk
3742 clevermous 76
        jmp     yes_sys_on_hd
4772 mario79 77
;-----------------------------------------------------------------------------
2643 clevermous 78
iglobal
79
align 4
80
read_image_fsinfo:
81
        dd      0               ; function: read
82
        dq      0               ; offset: zero
3744 clevermous 83
        dd      1474560         ; size
2643 clevermous 84
        dd      RAMDISK         ; buffer
4772 mario79 85
.name   db      '/hd'
3742 clevermous 86
.name_digit db  '0'
87
        db      '/'
88
.partition:
89
        rb      64      ; should be enough for '255/KOLIBRI/KOLIBRI.IMG'
90
 
91
bootpath1       db      'KOLIBRI.IMG',0
92
.len = $ - bootpath1
93
bootpath2       db      'KOLIBRI/KOLIBRI.IMG',0
94
.len = $ - bootpath2
2643 clevermous 95
endg
96
 
2288 clevermous 97
read_image:
2643 clevermous 98
        mov     ebx, read_image_fsinfo
99
        pushad
3296 clevermous 100
        call    file_system_lfn_protected
2643 clevermous 101
        popad
2288 clevermous 102
        ret
103
 
104
no_sys_on_hd:
4772 mario79 105
        DEBUGF 1, "K : RD not found\n"
106
.1:
2288 clevermous 107
        ; test_to_format_ram_disk (need if not using ram disk)
8089 dunkaist 108
        cmp     byte [BOOT.rd_load_from], RD_LOAD_FROM_FORMAT
2288 clevermous 109
        jne     not_format_ram_disk
110
        ; format_ram_disk
111
        mov     edi, RAMDISK
112
        mov     ecx, 0x1080
113
        xor     eax, eax
114
@@:
115
        stosd
116
        loop    @b
117
 
118
        mov     ecx, 0x58F7F
119
        mov     eax, 0xF6F6F6F6
120
@@:
121
        stosd
122
        loop    @b
123
 
124
        mov     [RAMDISK+0x200], dword 0xFFFFF0         ; fat table
125
        mov     [RAMDISK+0x4200], dword 0xFFFFF0
126
 
127
not_format_ram_disk:
128
yes_sys_on_hd: