Esempio n. 1
0
int do_root(char *name, char *size)
{
  if (debug) printf("%s\n", __func__);

  diskPartition       = malloc(FILESYSTEM_SIZE);                          // Allocates memory for diskPartition
  //diskPartition       = calloc(1, FILESYSTEM_SIZE);                          // Allocates memory for diskPartition
  pcb                 = (PartitionControlBlock *) diskPartition;          // Casts diskPartiton to type PartitionControlBlock
  pcb->freeBlockCount = NUM_BLOCKS;                                       // Initializes the freeBlockCount to NUM_BLOCKS

  if (debug) printf("PCB MEMORY: %p\n", pcb);


  for(int i=0; i < NUM_BLOCKS; i++)                                       // Initializes the Bitmap to all 0s
    setBitmap(i,0);

  setBitmap(0,1);                                                         // Sets the first block of the bitmap to 1
 
  directoryTable = diskPartition + sizeof(PartitionControlBlock);         // Finds the starting location for the Directory Table
  dtb            = (DirectoryTable *) directoryTable;                     // Creates the directory table
  
  if (debug) printf("DTB MEMORY: %p\n", dtb);


  pwd = &((*dtb).directoryEntries[0]);

  int returnValue;
  returnValue = do_mkdir("root", NULL);                                                 // Creates the root directory

  if (debug) printf("Return Value: %d\n", returnValue);
   
  if (debug) printf("DoRoot: SubDirIndex(PWD): %d\n",(*pwd).subdirectoryIndex);   

  return 0;
}
Esempio n. 2
0
void* splitUntil(void* freeBuffer, int bufferSize, int desiredBufferSize)
{
  int newBufferSize = bufferSize/2;
  // split and get two pointers
  void* smallerBufferOne = freeBuffer;
  void* smallerBufferTwo = (void*)((BYTE*) freeBuffer + newBufferSize);
  // remove from free list
  removeFromFreeList(freeBuffer, bufferSize);
  // add later pointer to smaller free list
  insertIntoFreeList(smallerBufferTwo, newBufferSize);
  
  // either return or recursively call function
  if (newBufferSize == desiredBufferSize)
  {
    setBitmap(smallerBufferOne, desiredBufferSize);
    bufferData_t* bufferData = (bufferData_t*)smallerBufferOne;
    bufferData->nextFreeBuffer = NULL;
    bufferData->bufferSize = desiredBufferSize;
    
    return smallerBufferOne;
  }
  else
  {
    return splitUntil(smallerBufferOne, newBufferSize, desiredBufferSize);
  }
}
Esempio n. 3
0
GlyphLayerBitmap::GlyphLayerBitmap(const std::string& path):
GlyphLayer (CAIRO_FORMAT_ARGB32),
_repeatX   (1), 
_repeatY   (1),
_pattern   (0) {
	setBitmap(path);
}
Esempio n. 4
0
bool GuiBitmapCtrl::onWake()
{
   if (! Parent::onWake())
      return false;
   setActive(true);
   setBitmap(mBitmapName);
   return true;
}
Esempio n. 5
0
void* getMemoryPointer(int bufferSize)
{
  // check that free list, if space, set bits, change freeList, and return pointer
  int freeBufferIndex = getFreeBufferIndex(bufferSize);
  void** freeBufferList = getFreeBufferPointer(freeBufferIndex);
  int currentBufferIndex = freeBufferIndex;
  int currentBufferSize = bufferSize;
  while (*freeBufferList == NULL && currentBufferIndex < NUM_BUFFER_SIZES)
  {
    freeBufferList = freeBufferList + 1;
    currentBufferIndex = currentBufferIndex + 1;
    currentBufferSize = currentBufferSize * 2;
  }

  if (currentBufferIndex == NUM_BUFFER_SIZES)
  {
    // need new page
    // add to 8196 free list
    // set freeListPointer to this list
    kma_page_t* page;
    page = get_page();
    size_t nextPage = getNextPageNumber();
    assert(nextPage > 0);
    startOfManagedMemory->pages[nextPage].pageData = page;
    bufferData_t* buffer = (bufferData_t*)page->ptr;
    buffer->nextFreeBuffer = NULL;
    buffer->bufferSize = PAGESIZE;

    currentBufferIndex = currentBufferIndex - 1;
    freeBufferList = getFreeBufferPointer(currentBufferIndex); // 8192 list
    *freeBufferList = page->ptr;
    currentBufferSize = PAGESIZE;
    // now able to continue with below logic

  }

  // have pointer to free list  
  if (currentBufferIndex > freeBufferIndex)
  {
    // need to split
    return splitUntil(*freeBufferList,currentBufferSize, bufferSize);
  }

  // have perfect sized free list
  void* freeBuffer = *freeBufferList;

  // set bitmap
  setBitmap(freeBuffer, bufferSize);

  // take buffer out of free list
  *freeBufferList = ((bufferData_t*)freeBuffer)->nextFreeBuffer;

  // record buffer size
  ((bufferData_t*)freeBuffer)->bufferSize = bufferSize;
  

  return freeBuffer;
}
Esempio n. 6
0
void LaptopButton::reset(unsigned long changed)
{
    if (changed&DecorationReset || changed&ManualReset || changed&SizeChange || changed&StateChange) {
        switch (type() ) {
            case CloseButton:
                setBitmap(close_bits);
                break;
            case HelpButton:
                setBitmap(question_bits);
                break;
            case MinButton:
                setBitmap(iconify_bits);
                break;
            case MaxButton:
                if (isChecked() ) {
                    setBitmap(isLeft() ? l_minmax_bits : r_minmax_bits);
                } else {
                    setBitmap(maximize_bits);
                }
                break;
            case OnAllDesktopsButton:
                setBitmap( isChecked() ? unsticky_bits : sticky_bits );
                break;
            default:
                setBitmap(0);
                break;
        }

        this->update();
    }
}
Esempio n. 7
0
//////////////////
// Create memory DC from bitmap
// 
WPMemDC::WPMemDC(WPDevContext *dc, WPBitmap *bm)
{
	hdc = CreateCompatibleDC(GetHDC(dc));
	assert(hdc);
	if (bm)
		setBitmap(bm);
	if (dc)
		mapMode(dc->mapMode());
}
Esempio n. 8
0
NextButton::NextButton(NextClient *parent, const char *name,
                       const unsigned char *bitmap, int bw, int bh,
                       const QString& tip, const int realizeBtns)
    : QButton(parent->widget(), name),
      deco(NULL), client(parent), last_button(NoButton)
{
    realizeButtons = realizeBtns;

    setBackgroundMode( NoBackground );
    resize(titleHeight, titleHeight);
    setFixedSize(titleHeight, titleHeight);

    if(bitmap)
        setBitmap(bitmap, bw, bh);

    QToolTip::add(this, tip);
}
Esempio n. 9
0
void QuartzButton::reset(unsigned long changed)
{
    if(changed & DecorationReset || changed & ManualReset || changed & SizeChange || changed & StateChange)
    {
        switch(type())
        {
        case CloseButton:
            setBitmap(close_bits);
            break;
        case HelpButton:
            setBitmap(question_bits);
            break;
        case MinButton:
            setBitmap(iconify_bits);
            break;
        case MaxButton:
            setBitmap(isOn() ? minmax_bits : maximize_bits);
            break;
        case OnAllDesktopsButton:
            setBitmap(0);
            break;
        case ShadeButton:
            setBitmap(isOn() ? shade_on_bits : shade_off_bits);
            break;
        case AboveButton:
            setBitmap(isOn() ? above_on_bits : above_off_bits);
            break;
        case BelowButton:
            setBitmap(isOn() ? below_on_bits : below_off_bits);
            break;
        default:
            setBitmap(0);
            break;
        }

        this->update();
    }
}
Esempio n. 10
0
MTS_NAMESPACE_BEGIN

GPUTexture::GPUTexture(const std::string &name, Bitmap *bitmap)
 : m_name(name) {
	m_filterType = EMipMapLinear;
	m_wrapTypeU = m_wrapTypeV = EClampToEdge;
	m_mipmapped = true;
	m_maxAnisotropy = 0.0f;
	m_fbType = ENone;
	m_samples = 1;
	m_depthMode = ECompare;
	m_borderColor = Color3(static_cast<Float>(0));
	m_size = Point3i(0);

	if (bitmap != NULL) {
		setBitmap(0, bitmap);
	} else {
		m_type = ETexture2D;
		m_pixelFormat = ERGB;
		m_componentFormat = EUInt8;
	}
}
Esempio n. 11
0
void initPage(kma_page_t* startOfNewPage)
{
    // cast pointer to pointer for buddySystemStruct_t
    startOfManagedMemory = (buddySystemStruct_t*)startOfNewPage->ptr;

    // clear or 0 all memory
    int i,j;
    for (i=0; i < NUM_BUFFER_SIZES; i++)
    {
       startOfManagedMemory->freeList.freeBufferList[i] = NULL;
    }
    for (i=0; i < MAX_BUDDY_SYSTEM_PAGES; i++)
    {
      startOfManagedMemory->pages[i].pageData = NULL;
      for (j=0; j < BITMAP_SIZE; j++)
      {
        startOfManagedMemory->pages[i].bitmap[j] = 0;
      }
    } 

    // store pointer to page data in pages array
    startOfManagedMemory->pages[0].pageData = startOfNewPage;

    // need to update bitmap
    setBitmap((void*) startOfManagedMemory, PAGESIZE/2);

    // now need to split block into buffers because used half
    int bufferListIndex = getFreeBufferIndex(PAGESIZE/2);

    void** bufferPtr = getFreeBufferPointer(bufferListIndex);
    // make free list point to first free block
    *bufferPtr = (void*)((char*)startOfManagedMemory + PAGESIZE/2); 
    bufferData_t* bufferData = (bufferData_t*)*bufferPtr;
    bufferData->nextFreeBuffer = NULL;
    bufferData->bufferSize = PAGESIZE/2;
}
Esempio n. 12
0
int do_mkdir(char *name, char *size)
{
  int fob;
  fob = 0;
  if (debug) printf("%s\n", __func__);

  int i;
  for(i=0; i < MAX_DIRECTORY_ENTRIES; i++)                                        // Loop to find the first open index for a directory entry
  {
     if(dtb->directoryEntries[i] == (DirectoryEntry*) NULL)                             // This index [i] is open
     {

        /* CREATE SOME SORT OF DirectoryEntry and put it into the proper position in memory */
        //DirectoryEntry *tempDir = &((*dtb).directoryEntries[i]);
        DirectoryEntry *tempDir = pwd + sizeof(DirectoryEntry) * i;
        if (debug) printf("mkdir: i: %d pointer %p\n", i, tempDir);

        //dtb->directoryEntries[i] = &tempDir;  
        //dtb->directoryEntries[i] = (DirectoryEntry *) tempDir;                                         // FIX THIS

        //if (debug) printf("TEMPDIR MEMORY: %p\n", tempDir);
        
        if (debug) printf("name: %p\n", name);
        if (debug) printf("size: %p\n", size);


        if (debug) printf("LINE 240\n");

        if(strlen(name) < MAX_NAME_LENGTH)                                            // Check to make sure that name is less than the max
        {
           
           char* nameError;
                   if (debug) printf("dtb->directoryEntries[i]->directoryName: %p\n", dtb->directoryEntries[i]->directoryName);
                   if (debug) printf("name: %s\n", name);
if (debug) printf("pwd->directoryName: %p\n", (*tempDir).directoryName);
                   if (debug) printf("pwd->directoryName: %s\n", (*tempDir).directoryName);
                   if (debug) printf("(*tempDir).directoryName: %s\n", (*tempDir).directoryName);
              
           //nameError = strncpy(dtb->directoryEntries[i]->directoryName, &name, MAX_NAME_LENGTH - 1);                     // Copy name into the DirectoryEntry
                   //nameError = strncpy((*pwd).directoryName, name, MAX_NAME_LENGTH - 1);
                   nameError = strncpy((*tempDir).directoryName, name, MAX_NAME_LENGTH - 1);
                   if (debug) printf("pwd->directoryName: %p\n", (*tempDir).directoryName);
                   if (debug) printf("pwd->directoryName: %s\n", (*tempDir).directoryName);
                        if (debug) printf("dtb->directoryEntries[i]->directoryName: %p\n", dtb->directoryEntries[i]->directoryName);

                if (debug) printf("NAME IF STATEMENT RETURN: \"%d\"\n", nameError);
                if (debug) printf("NAME IF STATEMENT RETURN: \"%p\"\n", nameError);
                if (debug) printf("NAME IF STATEMENT RETURN: \"%s\"\n", nameError);
                if (debug) printf("name: %p\n", name);
                if (debug) printf("size: %p\n", size);


        }

        if (debug) printf("LINE 244\n");
        //if (debug) printf("dtb->directoryEntries[i]->directoryName: %p\n", dtb->directoryEntries[i]->directoryName);
        //if (debug) printf("272 dtb->directoryEntries[i]->directoryName: %s\n", dtb->directoryEntries[i]->directoryName);
if (debug) printf("name: %p\n", name);
if (debug) printf("size: %p\n", size);

        else
        {
          printf("ERROR: %s is too large of a name.\n", name);                        // Print an error to stdout
          return -1; 
        }

                if (debug) printf("LINE 250\n");
                //if (debug) printf("dtb->directoryEntries[i]->directoryTableIndex: %d\n", dtb->directoryEntries[i]->directoryTableIndex);
                //if (debug) printf("dtb->directoryEntries[i]->directoryTableIndex: %p\n", dtb->directoryEntries[i]->directoryTableIndex);

                if (debug) printf("i = %d\n", i);

        (*tempDir).directoryTableIndex = i;                            // Set the DirectoryEntry directoryTableIndex
        //if (debug) printf("dtb->directoryEntries[i]->directoryTableIndex: %d\n", dtb->directoryEntries[i]->directoryTableIndex);
                if (debug) printf("LINE 254\n");
                if (debug) printf("name: %p\n", name);
                if (debug) printf("size: %p\n", size);


        fob = firstOpenBlock();                                                   // Find the first open block  

                        if (debug) printf("LINE 259\n");
                        if (debug) printf("name: %p\n", name);
                        if (debug) printf("size: %p\n", size);
       
        if(fob > 0)                                                                   // Check to see if this is a valid open block
           setBitmap(fob,1);                                                          // Set this block to being used
        
                if (debug) printf("LINE 264\n");
                if (debug) printf("name: %p\n", name);
                if (debug) printf("size: %p\n", size);

                if (debug) printf("FOB: %d\n", fob);
                //if (debug) printf(" dtb->directoryEntries[i]->startingBlock: %p\n",  dtb->directoryEntries[i]->startingBlock);
                //NAME IS OVERWRITEN
                if (debug) printf("Starting Block: %d\n", (*tempDir).startingBlock);
        (*tempDir).startingBlock = 3;
        if (debug) printf("Starting Block: %p\n", &(*tempDir).startingBlock);
        if (debug) printf("subdirectory: %p\n", &(*pwd).subdirectoryIndex);
        //if (debug) printf(" dtb->directoryEntries[i]->startingBlock: %p\n",  dtb->directoryEntries[i]->startingBlock);
        
        //(*tempDir).directoryTableIndex = i;                            // set directory table index

        /*  Set the rest of the parameters  */
         if (debug) printf("LINE 271\n");
         if (debug) printf("size: %p\n", size);
if (debug) printf("name: %p\n", name);

         if(i == 0) // this is root
         {
            if (debug) printf("I am in root\n");
            if (debug) printf("name: %p\n", name);
            if (debug) printf("size: %p\n", size);
            (*tempDir).subdirectoryIndex = -1;                         // since this is root initialize all values to -1
            (*tempDir).nextSiblingSubdirectory = -1;   
            if (debug) printf("SubDirIndex(PWD): %d\n",(*pwd).subdirectoryIndex);  
            if (debug) printf("SubDirIndex(tempDir): %d\n",(*tempDir).subdirectoryIndex);                 
            (*tempDir).previousSiblingSubdirectory = -1;               
            (*tempDir).parentDirectory = -1;
            if (debug) printf("size: %p\n", size);
         }
         else // not the root
         {
            if (debug) printf("Not Root: SubDirIndex(PWD): %d\n",(*pwd).subdirectoryIndex);   
            if (debug) printf("I am not in root\n");
            (*tempDir).parentDirectory = (*pwd).directoryTableIndex;     // set parent to current working dir
            (*tempDir).subdirectoryIndex = -1;                         // no subdirectory exists when first created
             if (debug) printf("358\n");
             if (debug) printf("PWD: %d\n",(*pwd).subdirectoryIndex);

            if((*pwd).subdirectoryIndex == -1)                                          // case: no subdirectory exists
            { 
              if (debug) printf("361\n");
              (*pwd).subdirectoryIndex = i;                             // intialize parent subdirectory list
              (*tempDir).nextSiblingSubdirectory = -1;                 // no sibling dirs
              (*tempDir).previousSiblingSubdirectory = -1;
            }
            else
            {
              int j;
              if (debug) printf("369\n");
              // Worst line ever. If it works were going to leave it. If not... well it wont be here
              for(j = (*pwd).subdirectoryIndex; dtb->directoryEntries[j]->nextSiblingSubdirectory != -1;
                                 j = dtb->directoryEntries[j]->nextSiblingSubdirectory){}                        // iterate through subdirectories in pwd
                                                                                                                 // to find last entry              
              DirectoryEntry *prevDir = &((*dtb).directoryEntries[j]);
              (*tempDir).previousSiblingSubdirectory = j;              // set the previous subdirectory to the last entry
              (*prevDir).nextSiblingSubdirectory = i;                  // set the "nextdirectory" for the last entry
              (*tempDir).nextSiblingSubdirectory = -1;                 // no next sibling dirs
            }



         }
         if (debug) printf("goodbye\n");
         if (debug) printf("size: %p\n", size);

        break;
      }
  }
  return 0;
}