Change userspace by partition type

Userspace should be on the first Linux partition found
This commit is contained in:
Mathieu Maret 2024-02-15 23:35:51 +01:00 committed by Mathieu Maret
parent 70366fa7be
commit 9713f527a8
3 changed files with 15 additions and 1 deletions

View File

@ -46,7 +46,7 @@ void idleThread(void *arg)
#define FILE_MAX_SIZE 64 // In nb of sectors
void loadUserSpace()
{
struct ata_partition *part = ATAGetPartition(1);
struct ata_partition *part = ATAGetPartitionByType(PART_TYPE_LINUX);
if (part == NULL) {
printf("No user partition found\n");

View File

@ -521,6 +521,19 @@ struct ata_partition *ATAGetPartition(int id)
return NULL;
}
struct ata_partition *ATAGetPartitionByType(uint type)
{
struct ata_partition *part;
int count;
list_foreach(partitions, part, count)
{
if (part->type == type)
return part;
}
return NULL;
}
struct ata_partition *ATAPartitionCreate(uint type, uint size, uint32_t lba,
struct ata_device *dev)
{

View File

@ -104,5 +104,6 @@ int ATAReadPartitionSector(struct ata_partition *part, int offset, uint nbSector
int ATAReadSector(struct ata_device *dev, int lba, uint nbSector, void *buf);
int ATAWriteSector(struct ata_device *dev, int lba, uint nbSector, void *buf);
struct ata_device *ATAGetDevice(int ctlId, int devId);
struct ata_partition *ATAGetPartitionByType(uint type);
int ATAReadPartition(struct ata_device *dev);
struct ata_partition *ATAGetPartition(int id);