001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.jikesrvm.objectmodel;
014
015import org.vmmagic.unboxed.Address;
016import org.vmmagic.unboxed.Word;
017
018/**
019 * Interface of BootImage that is used to define object model classes.
020 */
021public interface BootImageInterface {
022
023  /**
024   * Allocate space in data portion of bootimage. Moral equivalent of
025   * memory managers allocating raw storage at runtime.
026   * @param size the number of bytes to allocate
027   * @param align the alignment requested; must be a power of 2.
028   * @param offset the offset at which the alignment is desired.
029   * @return start address of the allocated memory
030   */
031  Address allocateDataStorage(int size, int align, int offset);
032
033  /**
034   * Allocate space in code portion of bootimage. Moral equivalent of
035   * memory managers allocating raw storage at runtime.
036   * @param size the number of bytes to allocate
037   * @param align the alignment requested; must be a power of 2.
038   * @param offset the offset at which the alignment is desired.
039   * @return start address of the allocated memory
040   */
041  Address allocateCodeStorage(int size, int align, int offset);
042
043  /**
044   * Fill in 1 byte of bootimage.
045   *
046   * @param offset offset of target from start of image, in bytes
047   * @param value value to write
048   */
049  void setByte(Address offset, int value);
050
051  /**
052   * Fill in 2 bytes of bootimage.
053   *
054   * @param offset offset of target from start of image, in bytes
055   * @param value value to write
056   */
057  void setHalfWord(Address offset, int value);
058
059  /**
060   * Fill in 4 bytes of bootimage, as numeric.
061   *
062   * @param offset offset of target from start of image, in bytes
063   * @param value value to write
064   */
065  void setFullWord(Address offset, int value);
066
067  /**
068   * Fill in 4/8 bytes of bootimage, as object reference.
069   *
070   * @param offset offset of target from start of image, in bytes
071   * @param value value to write
072   * @param objField true if this word is an object field (as opposed
073   * to a static, or tib, or some other metadata)
074   * @param root Does this slot contain a possible reference into the heap? (objField must also be true)
075   */
076  void setAddressWord(Address offset, Word value, boolean objField, boolean root);
077
078  /**
079   * Fill in 4 bytes of bootimage, as null object reference.
080   *
081   * @param offset offset of target from start of image, in bytes
082   * @param objField true if this word is an object field (as opposed
083   * to a static, or tib, or some other metadata)
084   * @param root Does this slot contain a possible reference into the heap? (objField must also be true)
085   */
086  void setNullAddressWord(Address offset, boolean objField, boolean root);
087
088  /**
089   * Fill in 8 bytes of bootimage.
090   *
091   * @param offset offset of target from start of image, in bytes
092   * @param value value to write
093   */
094  void setDoubleWord(Address offset, long value);
095}