Esempio n. 1
0
File: frame.c Progetto: eXeC64/piker
void frame_init()
{
    /* All frames are free to begin with */
    for(uint32_t i = 0; i < 4096; ++i) {
        frames_bitmap[i] = 0x00000000;
    }

    /* Now lets mark the kernel's frames as taken */
    uintptr_t kstart = V2P((uintptr_t)&_start);
    uintptr_t kend   = V2P((uintptr_t)&_end);

    for(uintptr_t i = kstart; i < kend; i += 0x1000) {
        frame_set(i, 1);
    }

    /* We also need to mark the GPU's frames as taken */
    /* For now we're assuming we have 512MB of memory
     * and 64 MB of it is allocated to the GPU */

    /* 64 MB */
    uintptr_t gpu_size = 0x04000000;
    uintptr_t gpu_end =  0x20000000;
    uintptr_t gpu_start =  gpu_end - gpu_size;

    for(uintptr_t i = gpu_start; i < gpu_end; i += 0x1000) {
        frame_set(i, 1);
    }

    /* Mark frame 0 as taken, so null pointers *NEVER* point to anything */
    frame_set(0, 1);
}
Esempio n. 2
0
LPTR EXPORT grabber_frame_ptr( int Depth, int x, int y, BOOL bModify )
/************************************************************************/
{
	if (Depth == -1)
		return(FramePointerRaw(frame_set(NULL), x, y, bModify));
	else
		return(FramePointer(frame_set(NULL), x, y, bModify));
}
Esempio n. 3
0
NIL_type Environment_Local_Set(EXP_type Value_expression,
                               NBR_type Offset_number)
  { UNS_type offset;
    offset = get_NBR(Offset_number);
    frame_set(Current_frame,
              offset,
              Value_expression); }
Esempio n. 4
0
File: frame.c Progetto: eXeC64/piker
size_t frame_alloc_mult_contig(uintptr_t* frames, size_t num)
{
    /* Iterate over all the frames */
    for(uint32_t i = 0; i < 131072; ++i) {
        if(frame_get(i * 0x1000) == 0) {
            uint8_t enough = TRUE;

            for(uint32_t j = 0; j < num; ++j) {
                if(frame_get(i + j * 0x1000) == 1) {
                    enough = FALSE;
                    break;
                }
            }

            if(enough == TRUE) {
                for(uint32_t j = 0; j < num; ++j) {
                    frame_set(i + j * 0x1000, 1);
                    frames[j] = P2V(i + j * 0x1000);
                }
                return num;
            }
        }
    }
    return 0;
}
Esempio n. 5
0
BOOL HistoInit()
/************************************************************************/
    {
    LPFRAME lpFrame;
    int x, y, i;
    LPTR lpLine;
    RGBS rgb;
    
    lpFrame = frame_set(NULL);
    if (!lpFrame)
        return(FALSE);
    lpRHisto = AllocPtr(256 * sizeof(long));
    lpGHisto = AllocPtr(256 * sizeof(long));
    lpBHisto = AllocPtr(256 * sizeof(long));
    if (!lpRHisto || !lpGHisto || !lpBHisto)
        {
        HistoDone();
        return(FALSE);
        }
    clr(lpRHisto, 256 * sizeof(long));
    clr(lpGHisto, 256 * sizeof(long));
    clr(lpBHisto, 256 * sizeof(long));
    
    AstralWaitCursor();
    for (y = 0; y < lpFrame->Ysize; ++y)
        {
        AstralClockCursor(y, lpFrame->Ysize, TRUE);
        lpLine = CachePtr(0, 0, y, NO);
        for (x = 0; x < lpFrame->Xsize; ++x, lpLine += DEPTH)
            {
            frame_getRGB( lpLine, &rgb );
            ++lpRHisto[rgb.red];
            ++lpGHisto[rgb.green];
            ++lpBHisto[rgb.blue];
            }
        }
    change_cursor(0);
    TotalHisto = (long)lpFrame->Ysize * (long)lpFrame->Xsize;
    MaxHisto = 0;
    for (i = 0; i < 256; ++i)
        {
        if (lpRHisto[i] > MaxHisto)
            MaxHisto = lpRHisto[i];
        if (lpGHisto[i] > MaxHisto)
            MaxHisto = lpGHisto[i];
        if (lpBHisto[i] > MaxHisto)
            MaxHisto = lpBHisto[i];
        }
    for (i = 0; i < 8; ++i)
        grayPat[i] = (i & 1) ? 0x55 : 0xAA;
        
    for (i = 0; i < QTONEPOINTS; ++i)
        QTone.QTmoved[i] = NO;
    MapInit();
    QTone.ActiveMark = 0;
    HistoValue = PNTX(QT(QTone.ActiveMark));
    
    return(TRUE);
    }
Esempio n. 6
0
struct frame *frame_dup(struct frame *frame) {
  struct frame *new_frame;

  frame_malloc(&new_frame);
  frame_set(new_frame, frame->begin_y, frame->begin_x);

  return(new_frame);
}
Esempio n. 7
0
void test_frame_dup() {
  struct frame *frame_0, *frame_1;
  const int begin_y = 5, begin_x = 10;

  frame_malloc(&frame_0);
  frame_set(frame_0, begin_y, begin_x);
  frame_1 = frame_dup(frame_0);

  assert(frame_0 != frame_1);
  assert(frames_equal(frame_0, frame_1));
}
Esempio n. 8
0
void card_set(struct card *card,
              enum value value,
              enum suit suit,
              enum face face,
              int begin_y,
              int begin_x) {
  frame_set(card->frame, begin_y, begin_x);
  card->value = value;
  card->suit = suit;
  card->face = face;
}
Esempio n. 9
0
NIL_type Environment_Global_Set(EXP_type Value_expression,
                                NBR_type Scope_number,
                                NBR_type Offset_number)
  { UNS_type offset,
             scope;
    FRM_type frame;
    scope = get_NBR(Scope_number);
    offset = get_NBR(Offset_number);
    frame = get_frame(Current_environment,
                      scope);
    frame_set(frame,
              offset,
              Value_expression); }
Esempio n. 10
0
void test_frame_set() {
  struct frame *frame;
  int begin_y = 5;
  int begin_x = 10;

  frame_malloc(&frame);
  frame_init(frame);
  frame_set(frame, begin_y, begin_x);

  assert(frame->begin_y == begin_y);
  assert(frame->begin_x == begin_x);

  frame_free(frame);
}
Esempio n. 11
0
void frame_alloc(struct page* page, page_flags_t flags)
{
    if (page->frame) {
        return; /* Already allocated. */
    }
    uint32_t i = frame_get_first_free();
    if (i >= ((uint32_t)-1)) {
        panic("%s: out of memory", __func__);
    }
    frame_set(i * PAGE_SIZE);
    page->present = TEST_FLAG(flags, PAGE_FLAGS_PRESENT)   ? 1 : 0;
    page->rw      = TEST_FLAG(flags, PAGE_FLAGS_WRITEABLE) ? 1 : 0;
    page->user    = TEST_FLAG(flags, PAGE_FLAGS_USER_MODE) ? 1 : 0;
    page->frame   = i;
}
bool VideoReaderUnit::PostProcess(list<FrameSetPtr>* append) {
  if (used_as_root_) {
    VideoFrame* next_frame = ReadNextFrame();
    if (next_frame != nullptr) {
      // Make new frameset and push VideoFrame.
      FrameSetPtr frame_set (new FrameSet());
      frame_set->push_back(shared_ptr<VideoFrame>(next_frame));
      append->push_back(frame_set);
      ++frame_num_;
      return true;
    } else {
      return false;
    }
  }
  return false;
}
Esempio n. 13
0
static pgentry_t pg_clone_page(pgentry_t page) {
	uint32_t flags  = (uint32_t)PTE_FLAGS(page);
	paddr_t pgframe = (paddr_t)PTE_ADDR(page);

	if ((flags & PAGE_PRESENT) == 0) {
		// Page not present, but some flags are set
		return page;
	}

	if ((flags & PAGE_LINK) != 0) {
		return page;
	}

	paddr_t newpgframe = frame_alloc();
	frame_set(newpgframe);
	frame_copy(pgframe, newpgframe);

	return PAGE_ENTRY(newpgframe, flags);
}
Esempio n. 14
0
File: frame.c Progetto: eXeC64/piker
int8_t frame_alloc_aligned(uintptr_t* frame, uint32_t alignment)
{
    uint32_t mask = alignment - 1;

    /* Iterate over all the frames */
    for(uint32_t i = 0; i < 4096; ++i) {
        if(frames_bitmap[i] ^ 0xFFFFFFFF) {
            /* There's a free frame here */

            /* For each bit in this part of the bitmap */
            for(uintptr_t f = i * 32 * 0x1000; f < (i+1) * 32 * 0x1000; f += 0x1000) {

                /* If the frame is free */
                if(0 == frame_get(f) && (f & mask) == 0) {
                    frame_set(f, 1);
                    *frame = P2V(f);
                    return 0;
                }
            }
        }
    }
    return -ENOMEM;
}
Esempio n. 15
0
NIL_type Environment_Global_Frame_Set(EXP_type Value_expression,
                                      UNS_type Offset)
  { frame_set(Global_frame,
              Offset,
              Value_expression); }
Esempio n. 16
0
File: frame.c Progetto: eXeC64/piker
void frame_free(uintptr_t frame)
{
    frame_set(V2P(frame), 0); /* convert from virt address */
}
Esempio n. 17
0
void grabber( LPSTR lpExtName, int port, HINSTANCE hInstance, HWND hWindow )
{

	HWND hWnd;
/*
	special conditions:
		hand scan interface --	
			with hand scanners the dialog box has a scan
			frame which gets filled with image data.  the
			dialog box must remain up during reads, so we
			use the exported frame_open, cacheptr, and
			frame_close to create the frame instead of 
			device reads.  Devopen just returns devcaps,
			devstart does everything else.
	
		special willow gs --	
			the gs board has 4 different buffers, which
			contain the following: 0-even pix/even lines,
			1-odd pix/even lines, 2-even pix/odd lines,
			3-odd pix/odd lines.
			each call to devread will layer the data so
			that the buffers will be combined correctly.
	
	Device Requirements Byte Decoding:

		XXXXXXX1b =  need to take over display
		XXXXXXX0b =  no need to take over display
		XXXXXX1Xb =  special willow gs read
		XXXXXX0Xb =  no special read 
		XXXX00XXb =  image depth, special case palette color 8-bit
		XXXX01XXb =  depth == 1
		XXXX10XXb =  depth == 2
		XXXX11XXb =  depth == 3
		X1XXXXXXb = special hand scan i/f 
		X0XXXXXXb = standard grab i/f
		XX1XXXXXb = don't free DLL after exit
		XX0XXXXXb = free DLL after exit 
		1XXXXXXXb = putting data from cache to external device
		0XXXXXXXb = putting data from external device into cache
		*/

	BYTE devreq; // device requirements
	LPFRAME lpFrame, lpOldFrame;
	BYTE depth;
	int lncnt,Datatype;
	HMODULE hDLL;
	LPIMAGE lpImage;

	if ( !(hDLL = (HMODULE)LoadGrabberLibrary(lpExtName)) ) {
		Message( IDS_EBADDRIVER, NULL );
		return;
	}

	if ( !(lpImage = GetActiveImage()))
		lpFrame = NULL;
	else
		lpFrame = ImgGetBaseEditFrame(lpImage);

   lpfnDevName     = (DEVNAMEPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(301));
   lpfnDevOpen     = (DEVOPENPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(302));
   lpfnDevCall     = (DEVCALLPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(303));
   lpfnDevClose    = (DEVCLOSEPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(304));
   lpfnAcquireProc = (DLGPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(305));

	/* get device's intentions -- is this a put to or read from cache */
	DevInfo.hInst = hInstance;  /* set the data structures */
	DevInfo.hPw = hWindow;
	DevInfo.bFile_is_open = ( lpFrame != NULL );

	if(DevInfo.bFile_is_open)
		{
		DevInfo.bImg_type = (lpImage->DataType==IDC_SAVECT ? TRUE : FALSE);
		/* pass the current filename */
		lstrcpy(DevInfo.cfname, lpImage->CurFile); 
		}

	if(!DevOpen(&DevInfo)) {
		DevCall(DEV_MSG, (LPTR)&DevMsg);
		
		/* if MsgNo == 0, then user cancelled */
		if(DevMsg.MsgNo) {
			if(DevMsg.MsgNo > 0) {
				Message( DevMsg.MsgNo );
			} else {
				/* print the driver's message */
				Print("%ls", (LPTR)DevMsg.szMsg);
			}
		}
		return; 
	}

	bKeepDLL = (DevInfo.device_caps & 0x20);
	devreq = DevInfo.device_caps;
	
	/* doing a put cache to an external device */
	if(!(devreq & 0x80)) {
		/* fill up the device info data structure */
		DevInfo.npix = FrameXSize( lpFrame );
		DevInfo.nlin = FrameYSize( lpFrame );
		DevInfo.bpl =  FrameXSize( lpFrame );
		DevInfo.xres = DevInfo.yres = FrameResolution( lpFrame );
		DevInfo.bpp = 8;
	} else {
		DevInfo.port = port; /* set the port for devices which require it */
#ifndef WIN32
		DevInfo.vgaaddr = GetA000H(); /* set the VGA buffer address */
#endif
	}

	/* see if we need to take over display */
	if(devreq & 1) {
		/* Hide the Cursor */
		ShowCursor( FALSE );

		/* Create the acquire window: it doesn't have the visable bit set */
		AstralDlg( YES, hInstance, hWindow, IDD_GRAB, AcquireProc);
		AstralDlgShow( IDD_GRAB );

		/* Enter the picture window command processor */
		SetCapture( AstralDlgGet( IDD_GRAB ) );

		/* set the data structures */
		DevInfo.hInst = hInstance;  
		DevInfo.hPw   = AstralDlgGet( IDD_GRAB );

		/* call display driver disable */
#ifndef WIN32
		PicwinOn((LPSTR)palette1);
#endif
	}

	if(devreq & 0x40) { // devstart does everything
		DevInfo.FpPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_ptr, DevInfo.hInst);

		DevInfo.FoPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_open, DevInfo.hInst);

		DevInfo.FsPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_set, DevInfo.hInst);

		DevInfo.FcPtr = (LPROC)MakeProcInstance(
			(FARPROC)grabber_frame_close, DevInfo.hInst);

		DevInfo.CcPtr = (LPROC)MakeProcInstance(
			(FARPROC)grabber_AstralClockCursor, DevInfo.hInst);
	}

	DevInfo.bLineArtAsGray = Control.LineArtAsGray;
 
	if(!DevCall(DEV_START, (LPTR)&DevInfo)) { /* if get, fill struct */
		back_to_windows(devreq & 1); /* restore if true */

		DevCall(DEV_MSG, (LPTR)&DevMsg);

		/* if MsgNo == 0, then user cancelled */
		if(DevMsg.MsgNo) {
			if(DevMsg.MsgNo > 0) {
				Message( DevMsg.MsgNo );
			} else {
				/* print the driver's message */
				Print("%ls", (LPTR)DevMsg.szMsg);
			}
		}

		if(devreq & 0x40) { // devstart does everything
			FreeProcInstance((FARPROC)DevInfo.FpPtr);
			FreeProcInstance((FARPROC)DevInfo.FoPtr);
			FreeProcInstance((FARPROC)DevInfo.FsPtr);
			FreeProcInstance((FARPROC)DevInfo.FcPtr);
			FreeProcInstance((FARPROC)DevInfo.CcPtr);
		}

		DevClose(); /* close the device */
		return;
	}

	/* DEV_START returned ok, now get or put image data if not done */

	if((devreq & 0xc0) == 0x80) { // putting data into the cache with devreads
		if(((devreq & 4) == 4) || ((devreq & 0x0c) == 0)) {
			depth = 1;
		} else {
			if((devreq & 8) == 8) {
				depth = 2;
			} else {
				if((devreq & 0x0c) == 0x0c) {
					depth = 3;
				}
			}
		}

		lpOldFrame = frame_set( NULL );
	
		if(!(lpFrame = FrameOpen(
				(FRMDATATYPE)depth,DevInfo.npix,DevInfo.nlin,DevInfo.xres))) {

			back_to_windows(devreq & 1); /* Restore if true */
	
			FrameError(IDS_EIMAGEOPEN);
			return;
		}
	
		frame_set(lpFrame);
	
		if(!(devreq & 2))	{
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt++ ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ, (LPTR)&DevData)) {
		         back_to_windows(devreq & 1); /* Restore if true */
					DevCall(DEV_MSG, (LPTR)&DevMsg);
	
					/* if MsgNo == 0, then user cancelled */
					if(DevMsg.MsgNo) {
						Print("Unable to get data from device");
					} else {
						DevInfo.nlin = lncnt;  // hand scanner, get total lines
					}
					return;
				}
			}
		} else { /* special willow gs reader */
	
			/* read even bytes, even lines */
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ0, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read odd bytes, even lines */
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 1, lncnt, YES);
				if(!DevCall(DEV_READ1, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read even bytes, odd lines */
			for ( lncnt=1; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ2, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read odd bytes, odd lines */
			for ( lncnt=1; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 1, lncnt, YES);
				if(!DevCall(DEV_READ3, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
		}
		
		FrameClose( lpOldFrame );
	
		back_to_windows(devreq & 1); /* Restore if true */
	
		if(DevInfo.bpp == 1) {
			Datatype = IDC_SAVELA;
		} else {
			if(DevInfo.bpp == 8) {
				Datatype = IDC_SAVECT;
			} else {
				Datatype = IDC_SAVE24BITCOLOR;
			}
		}
	
		/* Setup the new image and bring up the new image window */
        LPIMAGE lpNewImage = CreateImage(NULL, lpFrame, NULL, 
           NULL, Control.DefaultFileType, Datatype, 
           IMG_DOCUMENT, NULL);
        if (lpNewImage)
        {
            if (PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
               lpNewImage))         
            {
               	/* only version of image is in the cache */
            	/* so insure user is asked about saving when done */
                lpNewImage->fChanged = TRUE;
            }
            else
                DestroyImage(lpNewImage);
        }
	
		DevClose(); /* close the device */
	} else {
        LPIMAGE lpNewImage = NULL;

		/* enable the frame created by DevStart */
		lpFrame = frame_set(NULL);

		/* putting data to external device with DevWrites */
		if((devreq & 0xc0) == 0) {
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt++ ) {
				AstralClockCursor( lncnt, DevInfo.nlin, NO );
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, NO);
				if(!DevCall(DEV_WRITE, (LPTR)&DevData)) {
					Print("Unable to put data to device");
					return;
				}
			}
		} else {
			/* devstart has created a frame with image data */
			FreeProcInstance((FARPROC)DevInfo.FpPtr);
			FreeProcInstance((FARPROC)DevInfo.FoPtr);
			FreeProcInstance((FARPROC)DevInfo.FsPtr);
			FreeProcInstance((FARPROC)DevInfo.FcPtr);

			if(DevInfo.bpp == 1) {
				Datatype = IDC_SAVELA;
			} else {
				if(DevInfo.bpp == 8) {
					Datatype = IDC_SAVECT;
				} else {
					Datatype = IDC_SAVE24BITCOLOR;
				}
			}

			back_to_windows(devreq & 1); /* Restore if true */

			/* enable the frame created by DevStart */
			lpFrame = frame_set(NULL);

			/* DevInfo.nlin returns the actual line count */
			if(FrameYSize(lpFrame) <= DevInfo.nlin) {
				/* Setup the new image and bring up the new image window */
            {
                lpNewImage = CreateImage(NULL, lpFrame, NULL, 
                   NULL, Control.DefaultFileType, Datatype, 
                   IMG_DOCUMENT, NULL);
                if (lpNewImage)
                {
                    if (!PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
                       lpNewImage))         
                    {
                        DestroyImage(lpNewImage);
                        lpNewImage = NULL;
                    }
                }
            }

			} else {
				/* create a new frame of the right size and copy  */
				/* the right number of lines to it */

				lpOldFrame = FrameOpen(
					FrameType(lpFrame),
					FrameXSize(lpFrame), 
					DevInfo.nlin,
					FrameResolution(lpFrame));

				AstralCursor( IDC_WAIT );

				for(lncnt=0; lncnt<DevInfo.nlin; lncnt++) {
					FrameCopyLine(lpFrame, lpOldFrame, lncnt);
				}

				FrameClose(lpFrame);
				lpFrame = lpOldFrame;
				AstralCursor( NULL );
				/* Setup the new image and bring up the new image window */
                lpNewImage = CreateImage(NULL, lpFrame, NULL, 
                   NULL, Control.DefaultFileType, Datatype, 
                   IMG_DOCUMENT, NULL);
                if (lpNewImage)
                {
                    if (!PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
                       lpNewImage))         
                    {
                        DestroyImage(lpNewImage);
                        lpNewImage = NULL;
                    }
                }

			}
			/* only version of image is in the cache */
			/* so insure user is asked about saving when done */
            if (lpNewImage)    
                lpNewImage->fChanged = TRUE;

			DevClose(); /* close the device */
		}
	}
}
Esempio n. 18
0
LPTR EXPORT grabber_frame_set( LPTR lpFrame )
/************************************************************************/
{
return((LPTR)frame_set((LPFRAME)lpFrame));
}
Esempio n. 19
0
void card_unmark(struct card *card) {
  frame_set(card->frame, card->frame->begin_y - 1, card->frame->begin_x);
}
Esempio n. 20
0
NIL_type Environment_Frame_Set(FRM_type Frame,
                               UNS_type Offset,
                               EXP_type Value_expression)
  { frame_set(Frame,
              Offset,
              Value_expression); }