forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Memory Stick info?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Tue May 20, 2008 6:08 pm    Post subject: Memory Stick info? Reply with quote

Hi Guys,
I'm chasing any method of finding any Memory Stick info besides
the obvious free space and scanning files to calculate space consumed.
Then there's the sum of both to estimate the total capacity.

Particularly, there must be an easy way for the PSP to gain some device
information prior to formatting any Memory Stick.
Art.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Wed May 21, 2008 10:03 pm    Post subject: Reply with quote

About capacity did you try to open it as a block device and do a sceIoLseek ? (to have the exact size)

[edit] and multiply the result by 512[/edit]
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Thu May 22, 2008 12:01 am    Post subject: Reply with quote

Well, there is a way.... This is a little library for the MS we used for some various applications (Credits to C+D and Booster, and various places i took constants and structs from) as well as a 1.5 test (you just need to make a PRX for 3.x) application which reads out the MS Pro attributes to memory stick and shows the MS name and unique ID on the screen:
ms_drv.h:
Code:

#define WSBW(d) ((((d)&0x000000ff) << 24) | (((d)&0x0000ff00) << 8) | (((d)&0x00ff0000) >> 8) | (((d)&0xff000000) >> 24))
#define WSBH(d) ((((d)&0x00ff) << 8) | (((d)&0xff00) >> 8))

#define MSPRO_DEVINFOID_SYSINFO                         (0x10)
#define MSPRO_DEVINFOID_MODELNAME                       (0x15)
#define MSPRO_DEVINFOID_MBR                             (0x20)
#define MSPRO_DEVINFOID_PBR16                           (0x21)
#define MSPRO_DEVINFOID_PBR32                           (0x22)
#define MSPRO_DEVINFOID_SPECFILEVALUES1                 (0x25)
#define MSPRO_DEVINFOID_SPECFILEVALUES2                 (0x26)
#define MSPRO_DEVINFOID_IDENTIFYDEVINFO                 (0x30)

typedef struct tag_wbmspro_attribute {
        u16 signature;
        u16 version;
        u8 device_information_entry_count;
        u8 reserved[11];
} __attribute__ ((packed)) wbmspro_attribute_t;

typedef struct tag_wbmspro_device_info_entry_item {
        u32 address;
        u32 size;
        u8 info_id;
        u8 reserved[3];
} __attribute__ ((packed)) wbmspro_device_info_entry_item_t;

typedef struct tag_wbmspro_sys_info {
        u8 class;               // must be ?
        u8 reserved;            // see below
        u16 block_size;         // n KB
        u16 block_count;        // number of physical block
        u16 user_block_count;   // number of logical block
        u16 page_size;          // must be 0x200
        u8 reserved1[2];        // MS original Extra data size and format reserved
        u8 assembly_date[8];
        u32 serial_number;
        u8 assembly_maker_code;
        u8 assembly_model_code[3];
        u16 memory_maker_code;
        u16 memory_model_code;
        u8 reserved2[4];        //reserved[6]
        u8 vcc;
        u8 vpp;
        u16 controller_number;
        u16 controller_function;
        u16 start_sector;
        u16 unit_size;
        u8 ms_sub_class;
        u8 reserved3[4];
        u8 interface_type;
        u16 controller_code;
        u8 format_type;
        u8 reserved4;;
        u8 device_type;
        u8 reserved5[7];
        u8 mspro_id[16];
        u8 reserved6[16];
} __attribute__ ((packed)) wbmspro_sys_info_t;

#define SHOW_READ_DATA     0
#define SHOW_ERR_MSG       0
#define SHOW_SECTOR_ACCESS 0
#define SHOW_STATUS_REG    0

#define IO_MEM_STICK_CMD *((volatile int*)(0xBD200030))
#define IO_MEM_STICK_DATA *((volatile int*)(0xBD200034))
#define IO_MEM_STICK_STATUS *((volatile int*)(0xBD200038))
#define IO_MEM_STICK_SYS *((volatile int*)(0xBD20003C))

#define MSRST 0x8000

#define MS_FIFO_RW 0x4000
#define MS_RDY 0x1000
#define MS_TIME_OUT 0x100
#define MS_CRC_ERROR 0x200


#define READ_PAGE_DATA 0x2000
#define READ_REG 0x4000
#define GET_INT 0x7000
#define SET_RW_REG_ADRS 0x8000
#define EX_SET_CMD 0x9000

#define WRITE_REG               (0xB000)
#define SET_CMD                 (0xE000)

#define INT_REG_CED   0x80
#define INT_REG_ERR   0x40
#define INT_REG_BREQ  0x20
#define INT_REG_CMDNK 0x01
/*
;NORM_COMP       = (ced && !err)
;CMD_ERR_TER     = (ced && err)
;NORM_DATA_TRANS = (!err && breq)
;DATA_REQ_ERR    = (err && breq)
;CMD_EXE         = (!ced && !breq)
;CMD_NOT_EXE     = cmdnk
*/
//PROTOTYPES:
void pspMsBootStart();
int pspMsInit(void);
int pspMsReadSector(int sector, void *addr);
int pspMsReadAttrB(int attr, void *addr);
int pspMsWriteSector(int sector, void *addr);


ms_drv.c:
Code:

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include "ms_drv.h"

/****************************************************************************
****************************************************************************/
static int ms_wait_ready(void)
{
        int status;
//Kprintf("ms_wait_ready\n");
        do{
                status = IO_MEM_STICK_STATUS;
        }while(!(status & MS_RDY));

        if (status & (MS_CRC_ERROR|MS_TIME_OUT))
        {
#if SHOW_ERR_MSG
Kprintf("err:ms_wait_ready %08X\n",status);
#endif
                return -1;
        }
        return 0;
}

/****************************************************************************
****************************************************************************/
static int send_data_and_sync(int arg1, int arg2)
{
  int ret;
  IO_MEM_STICK_DATA = arg1;
  IO_MEM_STICK_DATA = arg2;
  ret = ms_wait_ready();
  return ret;
}
/****************************************************************************
****************************************************************************/
static int ms_get_reg_int(void)
{
  int ret, dummy, status;

  IO_MEM_STICK_CMD = GET_INT | 0x1;

  do{
    status = IO_MEM_STICK_STATUS;
    if(status & MS_TIME_OUT)
    {
#if SHOW_ERR_MSG
Kprintf("err:get_reg_int timeout\n");
#endif
         return -1;
        }
  }while(!(status & MS_FIFO_RW));

  ret = IO_MEM_STICK_DATA;
  dummy = IO_MEM_STICK_DATA;

  do{
    status = IO_MEM_STICK_STATUS;
    if(status & MS_TIME_OUT)
    {
#if SHOW_ERR_MSG
Kprintf("err:get_reg_int timeout\n");
#endif
         return -1;
        }
  }while(!(status & MS_RDY));

  return ret & 0xff;
}
/****************************************************************************
****************************************************************************/
static int read_data(void *addr, int count)
{
  int i;
  int status;
  for(i = 0; i<count; i+= 4){
    do{
      status = IO_MEM_STICK_STATUS;
      if (status & MS_TIME_OUT) return -1;
    }while(!(status & MS_FIFO_RW));
    *((volatile int*)(addr + i)) = IO_MEM_STICK_DATA;

#if SHOW_READ_DATA
Kprintf("%08X ",*((volatile int*)(addr + i)));
if( (i%0x20) ==0x1c) Kprintf("\n");
#endif

  }
  return 0;
}

static int write_data(void *addr, int count)
{
  int i;
  int status;
  for(i = 0; i<count; i+= 4){
    do{
      status = IO_MEM_STICK_STATUS;
      if (status & MS_TIME_OUT) return -1;
    }while(!(status & MS_FIFO_RW));
    IO_MEM_STICK_DATA = *((volatile int*)(addr + i));

#if SHOW_READ_DATA
Kprintf("%08X ",*((volatile int*)(addr + i)));
if( (i%0x20) ==0x1c) Kprintf("\n");
#endif

  }
  return 0;
}

/****************************************************************************
****************************************************************************/
static int ms_get_reg(void *buffer, int reg){
  int ret;

//Kprintf("READ_REG\n");
  IO_MEM_STICK_CMD = READ_REG | reg;
  ret = read_data(buffer, reg);

  return ret;
}


/****************************************************************************
****************************************************************************/
static void ms_wait_unk1(void)
{
        while(!(IO_MEM_STICK_STATUS & 0x2000));
}

/****************************************************************************
****************************************************************************/
static void ms_wait_ced(void)
{
        int result;
//Kprintf("wait CED\n");
        do{
                result = ms_get_reg_int();
        }while((result < 0) || ( (result & INT_REG_CED) == 0));
}
/****************************************************************************
        setup & check status register
****************************************************************************/
static int ms_check_status(void)
{
        int ret;
        u8 sts[8];

        //set rw reg addrs of type reg (?)
        IO_MEM_STICK_CMD = SET_RW_REG_ADRS | 0x4;
#if 1
        ret = send_data_and_sync(0x06100800,0x00000000);
#else
        IO_MEM_STICK_DATA = 0x06100800;
        IO_MEM_STICK_DATA = 0x00000000;
        ret = ms_wait_ready();
#endif
        if (ret != 0) return -1;

        ms_get_reg(sts, 8);
#if SHOW_STATUS_REG
Kprintf("STATUS %02X CHK[%02X] %02X %02X PRO[%02X] %02X %02X %02X \n",sts[0],sts[1],sts[2],sts[3],sts[4],sts[5],sts[6],sts[7]);
#endif

#if 1
        if(sts[4] != 0x01)
        {
#if SHOW_ERR_MSG
Kprintf("PRE-IPL Supported MS Pro only!\n");
#endif
                return -1;
        }

        if( (sts[2] & 0x15) != 0) return -1;
#else
        // status 0 to 7
        u32 val_a = *((volatile int*)(&sts[0]));
        u32 val_b = *((volatile int*)(&sts[4]));

        // STS[02]
        if ((val_a >> 16) & 0x15 != 0) return -1;
#endif
        return 0;
}

/****************************************************************************
****************************************************************************/
int pspMsInit(void)
{
//Kprintf("_ms_init\n");

  //initialize the hardware
        *((volatile int*)(0xBC100054)) |= 0x00000100;
        *((volatile int*)(0xBC100050)) |= 0x00000400;
        *((volatile int*)(0xBC100078)) |= 0x00000010;
        *((volatile int*)(0xBC10004C)) &= 0xFFFFFEFF;

printf("reset\n");

        //reset the controller
        IO_MEM_STICK_SYS = MSRST;
        while(IO_MEM_STICK_SYS & MSRST);

printf("check status\n");
        ms_check_status();
        printf("wait ready status\n");
        ms_wait_ready();
        printf("wait ced\n");
        //ms_wait_ced();

        return 0;
}
/****************************************************************************
****************************************************************************/
int pspMsReadSector(int sector, void *addr)
{
        int ret;

#if SHOW_SECTOR_ACCESS
Kprintf("ms_read_sector(%08X,%08X)\n",sector,addr);
#endif

/*
MS format
SYS_PARAM_REG           (0x10)
BLOCK_ADD_REG2          (0x11)
BLOCK_ADD_REG1          (0x12)
BLOCK_ADD_REG0          (0x13)
CMD_PARAM_REG           (0x14)
PAGE_ADD_REG            (0x15)
OVER_WR_FLAG_REG        (0x16)

MSPro format
//size = 1;
buf[0] = mode; // 0x10
buf[1] = (size & 0xFF00) >> 8;
buf[2] = (size & 0xFF);
buf[3] = (address & 0xFF000000) >> 24;
buf[4] = (address & 0x00FF0000) >> 16;
buf[5] = (address & 0x0000FF00) >> 8;
buf[6] = (address & 0x000000FF);
buf[7] = 0x00;

*/
  //send a command with 8 bytes of params, reverse endian. (0x200001XX 0xYYYYYY00) => READ_DATA
  IO_MEM_STICK_CMD = EX_SET_CMD | 0x7;
  ret = send_data_and_sync(0x010020 | (sector>>24)<<24, ((sector>>16)&0xff) | (sector&0xff00) | ((sector<<16)&0xff0000) );
  if (ret < 0) return -1;

  ms_wait_unk1();

//Kprintf("wait BREQ\n");
  do{
    ret = ms_get_reg_int();
    if (ret < 0) return -1;
  }while((ret & INT_REG_BREQ) == 0);

  if (ret & INT_REG_ERR)
  {
#if SHOW_ERR_MSG
Kprintf("err:ms wait int\n");
#endif
     return -1;
  }

//Kprintf("READ_PAGE_DATA\n");

        //send command to read data and get the data.
        IO_MEM_STICK_CMD = READ_PAGE_DATA | 512;
        ret = read_data(addr, 512);
        if (ret < 0) return -1;

        if (ms_wait_ready() < 0) return -1;
        ms_wait_unk1();
        ms_wait_ced();

  return 0;
}

int pspMsReadAttrB(int attr, void *addr)
{
        int ret;


  IO_MEM_STICK_CMD = EX_SET_CMD | 0x7;
  ret = send_data_and_sync(0x010024 | (attr>>24)<<24, ((attr>>16)&0xff) | (attr&0xff00) | ((attr<<16)&0xff0000) );
  if (ret < 0) return -1;

  ms_wait_unk1();

//Kprintf("wait BREQ\n");
  do{
    ret = ms_get_reg_int();
    if (ret < 0) return -1;
  }while((ret & INT_REG_BREQ) == 0);

  if (ret & INT_REG_ERR)
  {
#if SHOW_ERR_MSG
Kprintf("err:ms wait int\n");
#endif
     return -1;
  }
        IO_MEM_STICK_CMD = READ_PAGE_DATA | 512;
        ret = read_data(addr, 512);
        if (ret < 0) return -1;

        if (ms_wait_ready() < 0) return -1;
        ms_wait_unk1();
        ms_wait_ced();

  return 0;
}

int pspMsWriteSector(int sector, void *addr)
{
        int ret;

#if SHOW_SECTOR_ACCESS
Kprintf("ms_read_sector(%08X,%08X)\n",sector,addr);
#endif

/*
MS format
SYS_PARAM_REG           (0x10)
BLOCK_ADD_REG2          (0x11)
BLOCK_ADD_REG1          (0x12)
BLOCK_ADD_REG0          (0x13)
CMD_PARAM_REG           (0x14)
PAGE_ADD_REG            (0x15)
OVER_WR_FLAG_REG        (0x16)

MSPro format
//size = 1;
buf[0] = mode; // 0x10
buf[1] = (size & 0xFF00) >> 8;
buf[2] = (size & 0xFF);
buf[3] = (address & 0xFF000000) >> 24;
buf[4] = (address & 0x00FF0000) >> 16;
buf[5] = (address & 0x0000FF00) >> 8;
buf[6] = (address & 0x000000FF);
buf[7] = 0x00;

*/
  //send a command with 8 bytes of params, reverse endian. (0x200001XX 0xYYYYYY00) => READ_DATA
  IO_MEM_STICK_CMD = EX_SET_CMD | 0x7;
  ret = send_data_and_sync(0x010021 | (sector>>24)<<24, ((sector>>16)&0xff) | (sector&0xff00) | ((sector<<16)&0xff0000) );
  if (ret < 0) return -1;

  ms_wait_unk1();

//Kprintf("wait BREQ\n");
  do{
    ret = ms_get_reg_int();
    if (ret < 0) return -1;
  }while((ret & INT_REG_BREQ) == 0);

  if (ret & INT_REG_ERR)
  {
#if SHOW_ERR_MSG
Kprintf("err:ms wait int\n");
#endif
     return -1;
  }

//Kprintf("READ_PAGE_DATA\n");

        //send command to read data and get the data.
        IO_MEM_STICK_CMD = 0xD000 | 512;
        ret = write_data(addr, 512);
        if (ret < 0) return -1;

        if (ms_wait_ready() < 0) return -1;
        ms_wait_unk1();
        ms_wait_ced();

  return 0;
}

static int send_data_and_syncw(int arg1)
{
  int ret;
  IO_MEM_STICK_DATA = arg1;
  ret = ms_wait_ready();
  return ret;
}

int pspMsEraseBlock()
{
        int ret;

#if SHOW_SECTOR_ACCESS
Kprintf("ms_read_sector(%08X,%08X)\n",sector,addr);
#endif
/*
MS format
SYS_PARAM_REG           (0x10)
BLOCK_ADD_REG2          (0x11)
BLOCK_ADD_REG1          (0x12)
BLOCK_ADD_REG0          (0x13)
CMD_PARAM_REG           (0x14)
PAGE_ADD_REG            (0x15)
OVER_WR_FLAG_REG        (0x16)

MSPro format
//size = 1;
buf[0] = mode; // 0x10
buf[1] = (size & 0xFF00) >> 8;
buf[2] = (size & 0xFF);
buf[3] = (address & 0xFF000000) >> 24;
buf[4] = (address & 0x00FF0000) >> 16;
buf[5] = (address & 0x0000FF00) >> 8;
buf[6] = (address & 0x000000FF);
buf[7] = 0x00;

*/
  //send a command with 8 bytes of params, reverse endian. (0x200001XX 0xYYYYYY00) => READ_DATA
  IO_MEM_STICK_CMD = EX_SET_CMD | 0x7;
  ret = send_data_and_sync(0x26, 0);
  if (ret < 0) return -1;

  ms_wait_unk1();

        if (ms_wait_ready() < 0) return -1;


  return 0;
}

u32 FindProc(const char* szMod, const char* szLib, u32 nid)
{
        struct SceLibraryEntryTable *entry;
        SceModule *pMod;
        void *entTab;
        int entLen;

        pMod = sceKernelFindModuleByName(szMod);

        if (!pMod)
        {
                printf("Cannot find module %s\n", szMod);
                return 0;
        }

        int i = 0;

        entTab = pMod->ent_top;
        entLen = pMod->ent_size;
        //***printf("entTab %p - entLen %d\n", entTab, entLen);
        while(i < entLen)
    {
                int count;
                int total;
                unsigned int *vars;

                entry = (struct SceLibraryEntryTable *) (entTab + i);

        if(entry->libname && !strcmp(entry->libname, szLib))
                {
                        total = entry->stubcount + entry->vstubcount;
                        vars = entry->entrytable;

                        if(entry->stubcount > 0)
                        {
                                for(count = 0; count < entry->stubcount; count++)
                                {
                                        if (vars[count] == nid)
                                                return vars[count+total];
                                }
                        }
                }

                i += (entry->len * 4);
        }

        printf("Funtion not found.\n");
        return 0;
}
void *FindSysregFunction(u32 nid)
{
        return (void *)FindProc("sceSYSREG_Driver", "sceSysreg_driver", nid);
}

void pspMsBootStart(){
        int (* sceSysregMsifClkDisable)(int);
        int (* sceSysregMsifBusClockDisable)(int);
        int (* sceSysregMsifResetEnable)(int);
        int (* sceSysregMsifResetDisble)(int);
        int (* sceSysregMsifClkEnable)(int);
        int (* sceSysregMsifBusClockEnable)(int);
        int (* sceSysregMsifIoEnable)(int);

        int (* sceSysconCtrlMsPower)(int);

        sceSysregMsifClkDisable = FindSysregFunction(0x8E2D835D);
        sceSysregMsifBusClockDisable = FindSysregFunction(0x826430C0);
        sceSysregMsifResetEnable = FindSysregFunction(0x00C2628E);
        sceSysregMsifResetDisble = FindSysregFunction(0xEC4BF81F);
        sceSysregMsifClkEnable = FindSysregFunction(0x31154490);
        sceSysregMsifBusClockEnable = FindSysregFunction(0x4716E71E);
        sceSysconCtrlMsPower = (void *)FindProc("sceSYSCON_Driver", "sceSyscon_driver", 0x99BBB24C);
        sceSysregMsifIoEnable = FindSysregFunction(0xD74F1D48);
        //======================================================
        sceSysregMsifClkDisable(0);
        sceSysregMsifBusClockDisable(0);
        sceSysregMsifResetEnable(0);
        sceSysregMsifResetDisble(0);
        sceSysregMsifClkEnable(0);
        sceSysregMsifBusClockEnable(0);
        sceSysregMsifIoEnable(0);

        printf("About to power.\n");

        sceSysconCtrlMsPower(1);
        printf("About to do stuff.\n");
        sceKernelDelayThread(10000);

        pspMsInit();
}


test.c:
Code:

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include "ms_drv.h"

PSP_MODULE_INFO("MemStickTest", 0x1000, 1, 0);

PSP_MAIN_THREAD_ATTR(0);

#define printf  pspDebugScreenPrintf


void ErrorExit(int milisecs, char *fmt, ...)
{
        va_list list;
        char msg[256];

        va_start(list, fmt);
        vsprintf(msg, fmt, list);
        va_end(list);

        printf(msg);

        sceKernelDelayThread(milisecs*1000);
        sceKernelExitGame();
}



u8      buffer[1024*1024];
int main()
{
        int i;
        u32 sysinfo_addr = 0;
        u32 modname_addr = 0;
        wbmspro_attribute_t *ptr_attr = 0;
        wbmspro_device_info_entry_item_t *ptr_entry = 0;
        wbmspro_sys_info_t* s_info = 0;

        pspDebugScreenInit();
        printf("This program makes attr0.bin on the root of the memory stick.\n");

        printf("result for sector 0 = %08X\n", pspMsReadAttrB(0, buffer));
        printf("result for sector 1 = %08X\n", pspMsReadAttrB(1, buffer + 512));
        printf("result for sector 2 = %08X\n", pspMsReadAttrB(2, buffer + 1024));
        printf("read from attributes and... ");
        int fd = sceIoOpen("ms0:/attr0.bin", PSP_O_WRONLY | PSP_O_CREAT, 0777);
        sceIoWrite(fd, buffer, 3*512);
        sceIoClose(fd);
        printf("wrote to file! \n");

        ptr_attr = (wbmspro_attribute_t*) buffer;
        printf("Signature: %04X (should be 0xA5C3)\n", WSBH(ptr_attr->signature));
        printf("Version: %04X\n", WSBH(ptr_attr->version));
        printf("Number of entries: %02X\n", ptr_attr->device_information_entry_count);
        for (i = 0; i < ptr_attr->device_information_entry_count; i++){
                ptr_entry = (wbmspro_device_info_entry_item_t*) (buffer+ 0x10 + 0xC*i);
                printf("Entry %d, ID is %01X\n", i, ptr_entry->info_id);
                printf("Address is %08X, size is %08X\n", (unsigned int)WSBW(ptr_entry->address), (unsigned int)WSBW(ptr_entry->size));

                switch (ptr_entry->info_id){
                        case 0x10: sysinfo_addr = (int)buffer + WSBW(ptr_entry->address); break;
                        case 0x15: modname_addr = (int)buffer + WSBW(ptr_entry->address); break;
                        default: break;
                }
        }
        s_info = (wbmspro_sys_info_t*) sysinfo_addr;
        printf("====================================================================\n");
        printf("Serial number: %08X\n", (unsigned int)s_info->serial_number);
        printf("MSProID:\n");
        printf("0x");
        for(i = 0; i< 0x10; i++){
                printf("%02X", s_info->mspro_id[i]);
        }
        printf("\nModel name: \"%s\"\n", (char*)modname_addr);
        ErrorExit(37000, "\nFinished.\n");

        return 0;
}


Makefile:
Code:

TARGET = mstest
OBJS = main.o ms_drv.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = MemStick Test

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak


If you look at wbmspro_sys_info_t declaration in ms_drv.h, you'll see that you can get the size, block size, assembly date...

Have fun :)
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Thu May 22, 2008 3:22 am    Post subject: Reply with quote

thank you for sharing
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Thu May 22, 2008 5:05 am    Post subject: Reply with quote

Try this Art:

Code:
#include <pspkernel.h>
#include <pspdebug.h>

PSP_MODULE_INFO("MS Test", PSP_MODULE_USER, 1, 1);

typedef struct
{
   unsigned long   max_clusters;
   unsigned long   free_clusters;
   int            unk1;
   int            sector_size;
   int            sector_count;
   
} sDevCtl;

typedef struct
{
   sDevCtl *p_dev_inf;
   
} sDevCommand;

int main(void)
{
   pspDebugScreenInit();
   
   sDevCtl dev_ctl;
   sDevCommand   command;

   command.p_dev_inf = &dev_ctl;

   sceIoDevctl("ms0:", 0x02425818, &command, sizeof(sDevCommand), NULL, 0);
   
   u64 freespace = (dev_ctl.free_clusters * dev_ctl.sector_count) * dev_ctl.sector_size;
   
   u64 mssize = (dev_ctl.max_clusters * dev_ctl.sector_count) * dev_ctl.sector_size;
   
   pspDebugScreenPrintf("Free size: %0.2f\n", (float)freespace/1024.0f/1024.0f);
   
   pspDebugScreenPrintf("MS size: %0.2f\n", (float)mssize/1024.0f/1024.0f);
   
   sceKernelDelayThread(5*1000*1000);
   
   sceKernelExitGame();
   
   return 0;
}


I'm not sure how it will handle sticks > 4gb so you may need to test that.
Back to top
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Thu May 22, 2008 5:29 am    Post subject: Reply with quote

That would work too :)
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Thu May 22, 2008 6:03 am    Post subject: Reply with quote

pspZorba wrote:
About capacity did you try to open it as a block device and do a sceIoLseek ? (to have the exact size)

[edit] and multiply the result by 512[/edit]


You don't have to multiply by 512, as the msstor driver uses the byte as unit (despite the fact that it cannot write or seek anything that is not multiple of 512, I don't know why Sony did it in that stupid way).
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Thu May 22, 2008 6:24 am    Post subject: Reply with quote

For sure that's very strange, I would have expected the same behavior as the umd ...
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Thu May 22, 2008 8:46 am    Post subject: Reply with quote

Ah, thanks guys for the goodies :)
Will get to testing them out immediately.
edit,,,
Quote:
(you just need to make a PRX for 3.x)

The whole thing appears to work under 1.50 kernel,
and works with my 8Gb, but the same eboot won't run from
a 32Mb that came with the PSP value pack.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Thu May 22, 2008 5:04 pm    Post subject: Reply with quote

Ah... it's for MSPro only :) It uses the READ_ATRB command which is not there in normal memory stick ^^' But who uses 32MB memory sticks nowadays?
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Thu May 22, 2008 7:11 pm    Post subject: Reply with quote

Well I guess I can't use it with my 8Mb Memory Stick either then.
That's the one I keep the ISO collection on.
(yes there is an 8Mb MS!).
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group