Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DTB file support #145

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion limbo-android-arm/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.limbo.emu.main.arm"
android:versionCode="60001"
android:versionName="6.0.1-arm">
android:versionName="6.0.1-arm-dev">

<application
tools:replace="android:label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@ private void addBootOptions(ArrayList<String> paramsList) {
paramsList.add(initrd);
}

String dtb = getDTB();
if (dtb != null && !dtb.equals("")) {
paramsList.add("-dtb");
paramsList.add(dtb);
}

if (getMachine().getAppend() != null && !getMachine().getAppend().equals("")) {
paramsList.add("-append");
paramsList.add(getMachine().getAppend());
Expand All @@ -521,6 +527,10 @@ private String getInitRd() {
return FileUtils.encodeDocumentFilePath(getMachine().getInitRd());
}

private String getDTB() {
return FileUtils.encodeDocumentFilePath(getMachine().getDTB());
}

private String getKernel() {
return FileUtils.encodeDocumentFilePath(getMachine().getKernel());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ private void requestFieldChange(MachineProperty property, Object value) {
setDriveEnabled(value);
break;
case NON_REMOVABLE_DRIVE:
setDrive(value);
break;
case REMOVABLE_DRIVE:
setDrive(value);
break;
Expand All @@ -162,6 +160,9 @@ private void requestFieldChange(MachineProperty property, Object value) {
case INITRD:
getMachine().setInitRd(convertString(property, value));
break;
case DTB:
getMachine().setDTB(convertString(property, value));
break;
case APPEND:
getMachine().setAppend(convertString(property, value));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class Machine extends Observable {
private String bootDevice = "Default";
private String kernel;
private String initRd;
private String dtb;
private String append;
// net
private String network = null;
Expand Down Expand Up @@ -498,6 +499,19 @@ void setInitRd(String initRd) {

}

public String getDTB() {
return dtb;
}

void setDTB(String DTB) {
if (this.dtb == null || !this.dtb.equals(DTB)) {
this.dtb = DTB;
setChanged();
notifyChanged(MachineProperty.DTB, DTB);
}

}

public String getAppend() {
return append;
}
Expand Down Expand Up @@ -701,7 +715,7 @@ private void notifyChanged(MachineProperty property, Object value) {
public enum FileType {
CDROM, FDA, FDB, SD,
HDA, HDB, HDC, HDD, SHARED_DIR,
KERNEL, INITRD,
KERNEL, INITRD, DTB,
EXPORT_DIR, IMAGE_DIR, LOG_DIR, IMPORT_FILE, IMPORT_BIOS_FILE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public enum MachineProperty {
HDA, HDB, HDC, HDD, SHARED_FOLDER, SHARED_FOLDER_MODE, HDCONFIG,
CDROM, FDA, FDB, SD,
MEDIA_INTERFACE, HDA_INTERFACE, HDB_INTERFACE, HDC_INTERFACE, HDD_INTERFACE, CDROM_INTERFACE,
BOOT_CONFIG, KERNEL, INITRD, APPEND,
BOOT_CONFIG, KERNEL, INITRD, DTB, APPEND,
VGA, SOUNDCARD, NETCONFIG, HOSTFWD, GUESTFWD, NICCONFIG,
NON_REMOVABLE_DRIVE, REMOVABLE_DRIVE, DRIVE_ENABLED,
EXTRA_PARAMS, OTHER
EXTRA_PARAMS, OTHER;
}

Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public class LimboActivity extends AppCompatActivity
private Spinner mMachineType;
private Spinner mCPUNum;
private Spinner mKernel;
private Spinner mDTB;
private Spinner mInitrd;
// HDD
private ImageView mHDAOptions;
Expand Down Expand Up @@ -440,6 +441,26 @@ public void onNothingSelected(AdapterView<?> parentView) {
}
});

mDTB.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
if (getMachine() == null)
return;
String initrd = (String) ((ArrayAdapter<?>) mDTB.getAdapter()).getItem(position);
if (position == 0) {
notifyFieldChange(MachineProperty.DTB, initrd);
} else if (position == 1) {
browseFileType = FileType.DTB;
LimboFileManager.browse(LimboActivity.this, browseFileType, Config.OPEN_IMAGE_FILE_REQUEST_CODE);
mDTB.setSelection(0);
} else if (position > 1) {
notifyFieldChange(MachineProperty.DTB, initrd);
}
}

public void onNothingSelected(AdapterView<?> parentView) {
}
});

mBootDevices.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
if (getMachine() == null)
Expand Down Expand Up @@ -921,6 +942,7 @@ private void disableListeners() {
mBootDevices.setOnItemSelectedListener(null);
mKernel.setOnItemSelectedListener(null);
mInitrd.setOnItemSelectedListener(null);
mDTB.setOnItemSelectedListener(null);
mAppend.setOnFocusChangeListener(null);
mVGAConfig.setOnItemSelectedListener(null);
mSoundCard.setOnItemSelectedListener(null);
Expand Down Expand Up @@ -1017,6 +1039,7 @@ private void setupDiskMapping() {

addDiskMapping(FileType.KERNEL, mKernel, null, MachineProperty.KERNEL);
addDiskMapping(FileType.INITRD, mInitrd, null, MachineProperty.INITRD);
addDiskMapping(FileType.DTB, mDTB, null, MachineProperty.DTB);
}

private void addDiskMapping(FileType fileType, Spinner spinner,
Expand Down Expand Up @@ -1263,6 +1286,7 @@ private void populateDisks() {
//boot
populateDiskAdapter(mKernel, FileType.KERNEL, false);
populateDiskAdapter(mInitrd, FileType.INITRD, false);
populateDiskAdapter(mDTB, FileType.DTB, false);

}

Expand Down Expand Up @@ -1407,6 +1431,7 @@ private void enableNonRemovableDeviceOptions(boolean flag) {
mBootDevices.setEnabled(flag);
mKernel.setEnabled(flag);
mInitrd.setEnabled(flag);
mDTB.setEnabled(flag);
mAppend.setEnabled(flag);

//graphics
Expand Down Expand Up @@ -1635,9 +1660,10 @@ public void setupWidgets() {
mBootDevices = findViewById(R.id.bootfromval);
mKernel = findViewById(R.id.kernelval);
mInitrd = findViewById(R.id.initrdval);
mDTB = findViewById(R.id.DTBval);
mAppend = findViewById(R.id.appendval);

//display
//displayDTB
mVGAConfig = findViewById(R.id.vgacfgval);

//sound
Expand Down Expand Up @@ -1923,6 +1949,7 @@ public void updateBootSummary(boolean clear) {
String text = "Boot from: " + getMachine().getBootDevice();
text = appendDriveFilename(getMachine().getKernel(), text, "kernel", false);
text = appendDriveFilename(getMachine().getInitRd(), text, "initrd", false);
text = appendDriveFilename(getMachine().getDTB(), text, "DTB", false);
text = appendDriveFilename(getMachine().getAppend(), text, "append", false);
mBootSectionSummary.setText(text);
}
Expand Down Expand Up @@ -2851,6 +2878,7 @@ private void updateFavAdapters() {
mSD.getAdapter().getCount();
mKernel.getAdapter().getCount();
mInitrd.getAdapter().getCount();
mDTB.getAdapter().getCount();
}

private void addGenericOperatingSystems() {
Expand Down
33 changes: 33 additions & 0 deletions limbo-android-lib/src/main/res/layout/boot_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,39 @@
android:textSize="15sp" />
</LinearLayout>

<LinearLayout
android:id="@+id/dtbl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingRight="5dp"
android:src="@drawable/sysfile" />

<TextView
android:id="@+id/dtbStr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="DTB: "
android:textSize="15sp" />

<Spinner
android:id="@+id/DTBval"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:singleLine="true"
android:text=""
android:textSize="15sp" />
</LinearLayout>

<LinearLayout
android:id="@+id/appendl"
android:layout_width="fill_parent"
Expand Down