text
stringlengths
0
234
return;
end if;
Read_Rsp136 (This, W0, W1, W2, W3);
Convert_Card_Specific_Data_Register
(W0, W1, W2, W3, Info.Card_Type, Info.SD_CSD);
Info.Card_Capacity :=
Compute_Card_Capacity (Info.SD_CSD, Info.Card_Type);
Info.Card_Block_Size :=
Compute_Card_Block_Size (Info.SD_CSD, Info.Card_Type);
-- CMD7: SELECT
Send_Cmd (This, Select_Card, Rca, Status);
if Status /= OK then
return;
end if;
-- CMD13: STATUS
Send_Cmd (This, Send_Status, Rca, Status);
if Status /= OK then
return;
end if;
-- Bus size
case Info.Card_Type is
when STD_Capacity_SD_Card_V1_1
| STD_Capacity_SD_Card_v2_0
| High_Capacity_SD_Card =>
Send_ACmd (This, SD_App_Set_Bus_Width, Info.RCA, 2, Status);
if Status /= OK then
return;
else
Set_Bus_Size (This, Wide_Bus_4B);
end if;
when others =>
null;
end case;
if (Info.SD_CSD.Card_Command_Class and 2**10) /= 0 then
-- Class 10 supported.
declare
subtype Switch_Status_Type is UInt32_Array (1 .. 16);
Switch_Status : Switch_Status_Type;
begin
-- CMD6
Read_Cmd (This, Cmd_Desc (Switch_Func), 16#00_fffff0#,
Switch_Status, Status);
if Status /= OK then
return;
end if;
-- Handle endianness
for I in Switch_Status'Range loop
Switch_Status (I) := BE32_To_Host (Switch_Status (I));
end loop;
-- Switch tp 50Mhz if possible.
if (Switch_Status (4) and 2**(16 + 1)) /= 0 then
Read_Cmd (This, Cmd_Desc (Switch_Func), 16#80_fffff1#,
Switch_Status, Status);
if Status /= OK then
return;
end if;
-- Switch to 50Mhz
Set_Clock (This, 50_000_000);
end if;
Function Definition: function Convert is new Ada.Unchecked_Conversion (HALFS.Status_Code, Status_Code);
Function Body: function Convert is new Ada.Unchecked_Conversion (File_Mode, HALFS.File_Mode);
function Convert is new Ada.Unchecked_Conversion (File_Size, HALFS.File_Size);
function Convert is new Ada.Unchecked_Conversion (HALFS.File_Size, File_Size);
function Convert is new Ada.Unchecked_Conversion (Seek_Mode, HALFS.Seek_Mode);
type Mount_Record is record
Is_Free : Boolean := True;
Name : String (1 .. Max_Mount_Name_Length);
Name_Len : Positive;
FS : Any_Filesystem_Driver;
end record;
subtype Mount_Index is Integer range 0 .. Max_Mount_Points;
subtype Valid_Mount_Index is Mount_Index range 1 .. Max_Mount_Points;
type Mount_Array is array (Valid_Mount_Index) of Mount_Record;
type VFS_Directory_Handle is new Directory_Handle with record
Is_Free : Boolean := True;
Mount_Id : Mount_Index;
end record;
overriding function Get_FS
(Dir : VFS_Directory_Handle) return Any_Filesystem_Driver;
-- Return the filesystem the handle belongs to.
overriding function Read
(Dir : in out VFS_Directory_Handle;
Handle : out Any_Node_Handle) return HALFS.Status_Code;
-- Reads the next directory entry. If no such entry is there, an error
-- code is returned in Status.