Rev 9162 | Rev 9168 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9162 | Rev 9166 | ||
---|---|---|---|
Line 326... | Line 326... | ||
326 | dd ahci_callbacks.end - ahci_callbacks |
326 | dd ahci_callbacks.end - ahci_callbacks |
327 | dd 0 ; no close function |
327 | dd 0 ; no close function |
328 | dd 0 ; no closemedia function |
328 | dd 0 ; no closemedia function |
329 | dd ahci_querymedia |
329 | dd ahci_querymedia |
330 | dd ahci_read |
330 | dd ahci_read |
331 | dd 0;ahci_write |
331 | dd ahci_write |
332 | dd 0 ; no flush function |
332 | dd 0 ; no flush function |
333 | dd 0 ; use default cache size |
333 | dd 0 ; use default cache size |
334 | .end: |
334 | .end: |
335 | hd_name db 'hd', 0, 0, 0 |
335 | hd_name db 'hd', 0, 0, 0 |
336 | hd_counter dd 0 |
336 | hd_counter dd 0 |
Line 979... | Line 979... | ||
979 | ; Wait for command completion |
979 | ; Wait for command completion |
980 | stdcall ahci_port_cmd_wait, edi, eax;, AHCI_PORT_CMD_TIMEOUT |
980 | stdcall ahci_port_cmd_wait, edi, eax;, AHCI_PORT_CMD_TIMEOUT |
Line 981... | Line 981... | ||
981 | 981 | ||
Line 982... | Line 982... | ||
982 | DEBUGF AHCI_DBGLVL, "sata_error register = 0x%x\n", [edi + HBA_PORT.sata_error] |
982 | DEBUGF AHCI_DBGLVL, "sata_error register = 0x%x\n", [edi + HBA_PORT.sata_error] |
Line 983... | Line 983... | ||
983 | 983 | ||
984 | DEBUGF AHCI_DBGLVL, "reading completed\n" |
984 | DEBUGF AHCI_DBGLVL, "R/W completed\n" |
985 | 985 | ||
986 | ; xor ecx, ecx |
986 | ; xor ecx, ecx |
Line 1062... | Line 1062... | ||
1062 | 1062 | ||
1063 | mov ecx, ahci_mutex |
1063 | mov ecx, ahci_mutex |
Line 1064... | Line 1064... | ||
1064 | call mutex_unlock |
1064 | call mutex_unlock |
- | 1065 | ||
- | 1066 | popad |
|
- | 1067 | xor eax, eax |
|
- | 1068 | ret |
|
- | 1069 | endp |
|
- | 1070 | ||
- | 1071 | ; Write sectors |
|
- | 1072 | ; return value: 0 = success, otherwise = error |
|
- | 1073 | proc ahci_write stdcall pdata: dword, buffer: dword, startsector: qword, numsectors_ptr:dword |
|
- | 1074 | locals |
|
- | 1075 | numsectors dd ? |
|
- | 1076 | endl |
|
- | 1077 | ||
- | 1078 | pushad |
|
- | 1079 | ||
- | 1080 | mov ecx, ahci_mutex |
|
- | 1081 | call mutex_lock |
|
- | 1082 | ||
- | 1083 | mov eax, [numsectors_ptr] |
|
- | 1084 | mov eax, [eax] |
|
- | 1085 | mov [numsectors], eax |
|
- | 1086 | DEBUGF AHCI_DBGLVL, " ahci_write: buffer = 0x%x, startsector = 0x%x:%x, numsectors = %u\n", [buffer], [startsector], [startsector + 4], eax |
|
- | 1087 | ||
- | 1088 | xor ecx, ecx ; how many sectors have been read |
|
- | 1089 | .write_loop: |
|
- | 1090 | cmp ecx, [numsectors] |
|
- | 1091 | jae .write_loop_end |
|
- | 1092 | ||
- | 1093 | mov ebx, [numsectors] |
|
- | 1094 | sub ebx, ecx |
|
- | 1095 | stdcall ahci_rw_sectors, [pdata], [buffer], dword [startsector], dword [startsector + 4], ebx, 1 |
|
- | 1096 | ;; TODO check if eax == 0 ? |
|
- | 1097 | ||
- | 1098 | DEBUGF AHCI_DBGLVL, " EAX = 0x%x\n", eax |
|
- | 1099 | ||
- | 1100 | add [buffer], eax |
|
- | 1101 | shr eax, 9 ; /= 512 |
|
- | 1102 | add ecx, eax |
|
- | 1103 | add dword [startsector], eax |
|
- | 1104 | adc dword [startsector + 4], 0 |
|
- | 1105 | ||
- | 1106 | jmp .write_loop |
|
- | 1107 | .write_loop_end: |
|
- | 1108 | ||
- | 1109 | mov ecx, ahci_mutex |
|
- | 1110 | call mutex_unlock |
|
1065 | 1111 | ||
1066 | popad |
1112 | popad |
1067 | xor eax, eax |
1113 | xor eax, eax |
Line 1068... | Line 1114... | ||
1068 | ret |
1114 | ret |